]> git.donarmstrong.com Git - cran2deb.git/blob - trunk/exec/web
Circumvented bug in hwriter that cannot write empty tables. Using getopt package...
[cran2deb.git] / trunk / exec / web
1 #!/usr/bin/env r
2 ## DOC: cran2deb web
3 ## DOC:     generate cran2deb status web pages
4 ## DOC:
5
6 suppressPackageStartupMessages(library(cran2deb))
7 library(hwriter)
8 library(getopt)
9
10 opt<-getopt(matrix(c(
11         'verbose','v', 0, "logical",
12         'debug',  'd', 0, "logical",
13         'help',   'h', 0, "logical",
14         'root',   'r', 2, "character"   
15 ),byrow=TRUE,ncol=4))
16
17 .Last <- function() { if (!is.null(opt$verbose)) {cat("Printing the traceback, just to be sure:\n"); print(traceback())} }
18
19 web.cran2deb.root<-"/var/www/cran2deb"
20 if (!is.null(opt$root)) {
21         web.cran2deb.root <- opt$root
22 }
23
24 if (!is.null(opt$debug)) {
25         cat("Settings:\n")
26         cat(" * root: ",web.cran2deb.root,"\n",sep="")
27         cat("\n")
28         print(opt)
29         q()
30 }
31
32
33 if (!is.null(opt$verbose)) cat("building banned_packages.html\n")
34 banned_builds_path=paste(web.cran2deb.root,"banned_packages.html",sep="/")
35
36 if (!is.null(opt$verbose)) cat("building todays_packages.html\n")
37 todays_builds_path=paste(web.cran2deb.root,"todays_packages.html",sep="/")
38
39 if (!is.null(opt$verbose)) cat("building latest_packages.html\n")
40 latest_builds_path=paste(web.cran2deb.root,"latest_packages.html",sep="/")
41
42 if (!is.null(opt$verbose)) cat("building failed_packages.html\n")
43 failed_builds_path=paste(web.cran2deb.root,"failed_packages.html",sep="/")
44
45 links <- function(p) {
46     hwrite(c(
47             hwrite('Packages built today',link='todays_packages.html')
48            ,hwrite('Successful packages',link='latest_packages.html')
49            ,hwrite('Failed packages',link='failed_packages.html')
50            ,hwrite('Banned packages',link='banned_packages.html')
51            ),p,center=TRUE,border=0,style='padding: 6px 6px 6px 12px')
52     if (!is.null(opt$verbose)) cat("Wrote links for ",p,".\n",sep="")
53 }
54
55 page <- function(content,path,title) {
56     title <- paste('cran2deb:',title)
57     p <- openPage(path,title=title)
58     hwrite(title,p,heading=1)
59     hwrite('Install instructions',p,center=TRUE,link='/')
60     links(p)
61     if (nrow(content)>0) {
62             hwrite(content,p,center=TRUE,border=1
63                   ,table.style='border-collapse: collapse; padding: 0; margin: 0'
64                   ,row.names=FALSE,row.bgcolor='#ffaaaa')
65             links(p)
66     } else {
67             hwrite("None",p,center=TRUE)
68     }
69     closePage(p)
70 }
71
72 page(db_blacklist_reasons(),banned_builds_path,'Banned packages')
73 page(db_todays_builds(),todays_builds_path,'Packages built today')
74 page(db_successful_builds(),latest_builds_path,'Latest successfully built packages')
75 page(db_failed_builds(),failed_builds_path,'Recent failed packages')
76