[Rd] Creating a private CRAN with webpages

Dirk Eddelbuettel edd at debian.org
Fri Jun 9 13:34:58 CEST 2017

On 9 June 2017 at 02:44, Joshua Bradley wrote:
| repo. I like the CRAN web pages that allow a user to browse the various
| packages from a browser without having to first install them. I want to
| duplicate the process that CRAN goes through when it generate the webpages.

As your initial email correctly identified, none of miniCRAN, drat, ... do
this currently.

So this is how open source works: you identified a need, now you can go off
and fill it. ;-) You have the PACKAGES{,.gz,.rds} files from your repo. So
accessing packageDescription() for each package is a given.  I do so in
CRANberries for new packages, and while that (ugly) code is (still) not
public, the relevant function for that is

writeNewBlogEntry <- function(curPkg, curVer, reposurl) {
    ## and compute some sort of output for new package -- maybe get description ? NB does NOT work for BioC
    blogpost <- file.path(blogInputDir, "new", paste(curPkg, "_", curVer, ".txt", sep=""))
    con <- file(blogpost, "wt")
    cat("New package", curPkg, "with initial version", curVer,"\n\n", file=con)
    dcf <- read.dcf( url(getDescriptionUrl(curPkg, reposurl)) )
    for (i in 1:ncol(dcf)) {
        cat("<strong>", colnames(dcf)[i], "</strong>: ", htmlEscape(dcf[1,i]), "<br>\n", sep="", file=con)
    closeBlogPost(con, reposurl, curPkg)

(The read.dcf() off the package URL is no longer needed with CRAN_package_db().)

A corresponding file for the most recent 'new' package:

New package Risk with initial version 1.0 

<strong>Package</strong>: Risk<br>
<strong>Type</strong>: Package<br>
<strong>Title</strong>: Computes 26 Financial Risk Measures for Any Continuous
<strong>Version</strong>: 1.0<br>
<strong>Date</strong>: 2017-06-05<br>
<strong>Author</strong>: Saralees Nadarajah, Stephen Chan<br>
<strong>Maintainer</strong>: Saralees Nadarajah <mbbsssn2 at manchester.ac.uk><br>
<strong>Depends</strong>: R (>= 3.0.1)<br>
<strong>Description</strong>: Computes 26 financial risk measures for any continuous distribution.  The 26 financial risk measures  include value at risk, expected shortfall due to Artzner et al. (1999) <DOI:10.1007/s10957-011-9968-2>, tail conditional median due to Kou et al. (2013) <DOI:10.1287/moor.1120.0577>, expectiles due to Newey and Powell (1987) <DOI:10.2307/1911031>, beyond value at risk due to Longin (2001) <DOI:10.3905/jod.2001.319161>, expected proportional shortfall due to Belzunce et al. (2012) <DOI:10.1016/j.insmatheco.2012.05.003>, elementary risk measure due to Ahmadi-Javid (2012) <DOI:10.1007/s10957-011-9968-2>, omega due to Shadwick and Keating (2002), sortino ratio due to Rollinger and Hoffman (2013), kappa  due to Kaplan and Knowles  (2004), Wang (1998)'s <DOI:10.1080/10920277.1998.10595708> risk measures, Stone (1973)'s <DOI:10.2307/2978638> risk measures, Luce (1980)'s <DOI:10.1007/BF00135033> risk measures, Sarin (1987)'s <DOI:10.1007/BF00126387> risk measures, Bronshtein and Kurelenkova (2009)'s risk measures.<br>
<strong>License</strong>: GPL (>= 2)<br>
<strong>Packaged</strong>: 2017-06-08 13:57:28 UTC; mbbsssn2<br>
<strong>NeedsCompilation</strong>: no<br>
<strong>Repository</strong>: CRAN<br>
<strong>Date/Publication</strong>: 2017-06-08 15:19:54 UTC<br>

<a href="https://cran.r-project.org/package=Risk">More information about Risk at CRAN</a>

If I did it today, I'd start with markdown, but you get the idea.  The page
is the (current) top of http://dirk.eddelbuettel.com/cranberries/cran/new/

I write these as minimal html (as I wrote that code ~ 10 years ago in the
pre-pandoc days) which then get fed into the blog engine.  That helps keeping
content and presentation (css, ...) separate.

I think you have everything you need in the PACKAGES.rds which you get back
as a (large) data.frame from tools::CRAN_package_db().

Hope this helps,  Dirk

http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org

More information about the R-devel mailing list