markup.reposDF <- function(x=reposDF, outFile="/tmp/reposPage.tex",
shim="./StatSoft/Rpacks/", style=c("hyperlatex","html")[1])
{
# this function
# marks up some data from a reposDF for putting in a web page.
# when channing CVS comes back up it can be illustrated on
# my web pages. basic idea is that you want a bulleted list
# with title of each package and reference to the target file
#
# of course this is unnecessary when the whole world is using
# install.packages2 .. that may be a while off. also, we
# may want to have the reposDF marked up so that when the
# user hits a link on the page the browser tells R to run install.packages2
#
# only odd thing is 'shim' which lets you specify a path from
# the dir where the main html will live to the actual package files
#
# defining tags with some abstraction (startLink, midLink, endLink,
# startList, endList) works OK for hyperlatex and html
# -- just waiting for a nice dtd ...
#
hyLatTags <- c(startLink=" \\xlink{", item="\\item ", midLink="}{",
endLink="}\n", startList="\\begin{itemize}\n", endList="\\end{itemize}\n")
htmlTags <- c(startLink="",
endLink="", startList="
")
#
if (style == "hyperlatex") tags <- hyLatTags
else tags <- htmlTags
require(reposTools)
# togz <- function(pname,vers) {paste(pname,"_",vers,".tar.gz",sep="")}
packs <- x[,"Package"]
vstrings <- unlist(lapply(x[,"Version"],function(z)stringRep(z)))
titles <- x[,"Title"]
descs <- x[,"Description"]
oss <- unlist(lapply(x[,"OSspecific"], function(x) x[[1]]$File ))
oss.src <- lapply(x[,"OSspecific"], function(x) x[["Source"]]$File )
oss.win <- lapply(x[,"OSspecific"], function(x) x[["Win32"]]$File )
npacks <- length(packs)
nimgs <- sum(oscount <- unlist(lapply(x[,"OSspecific"],length)))
cat("% generated by markup.reposDF.R, VJ Carey, 2002\n", file=outFile)
cat(tags["startList"], file=outFile, append=TRUE)
for (i in 1:npacks)
{
cat(tags["item"]," ", titles[i], file=outFile, append=TRUE, sep="")
#tgz <- togz(packs[i], vstrings[i])
# oddly the anchor and annotation are reversed in hyperlatex relative to HTML
if (style == "hyperlatex")
{
if( !is.null(oss.src[[i]])) cat(tags["startLink"]," ",oss.src[[i]],tags["midLink"], shim, oss.src[[i]],
tags["endLink"], file=outFile, append=TRUE, sep="")
if( !is.null(oss.win[[i]])) cat(tags["startLink"]," ",oss.win[[i]],tags["midLink"], shim, oss.win[[i]],
tags["endLink"], file=outFile, append=TRUE, sep="")
}
else
{
if (!is.null(oss.src[[i]])) cat(tags["startLink"],shim,oss.src[[i]],tags["midLink"], oss.src[[i]],
tags["endLink"], file=outFile, append=TRUE, sep="")
if (!is.null(oss.win[[i]])) cat(tags["startLink"],shim,oss.win[[i]],tags["midLink"], oss.win[[i]],
tags["endLink"], file=outFile, append=TRUE, sep="")
}
}
cat(tags["endList"], file=outFile, append=TRUE)
}