make site: add support for help pop-ups on generated download page

original commit: 61a78d00e9244f469f57f75812d6a1d0734916c4
This commit is contained in:
Matthew Flatt 2013-11-11 05:18:02 -07:00
parent 5de41c4bc1
commit aec79d1db5
5 changed files with 69 additions and 9 deletions

View File

@ -121,4 +121,5 @@
"pdf-doc/")
#:dest (build-path dest-dir
"index.html")
#:help-table (hash-ref config '#:site-help (hash))
#:git-clone (current-directory))

View File

@ -147,6 +147,7 @@
[(#:source-pkgs?) (boolean? val)]
[(#:mac-pkg?) (boolean? val)]
[(#:site-dest) (path-string? val)]
[(#:site-help) (hash? val)]
[(#:pdf-doc?) (boolean? val)]
[(#:max-snapshots) (real? val)]
[(#:pause-before) (and (real? val) (not (negative? val)))]

View File

@ -306,6 +306,13 @@ Top keywords (recognized only in the configuration top-level):
supply non-#f `#:smtp-user' and `#:smtp-password' when
authentication is required by the server
#:site-help <hash-table> --- hash table of extra "help" information
for entries on a web page created by the `site' and
`snapshot-site' makefile targets; the hash keys are strings for
row labels in the download table (after splitting on "|" and
removing "{...}"), and the values are X-expressions for the help
content
More precisely, the `distro-build/config' language is like
`racket/base' except that the module body must have exactly one
expression (plus any number of definitions, etc.) that produces a

View File

@ -1,4 +1,4 @@
#lang racket/base
#lang at-exp racket/base
(require racket/format
racket/path
racket/system
@ -60,6 +60,7 @@
#:title [title "Racket Downloads"]
#:current-rx [current-rx #f]
#:git-clone [git-clone #f]
#:help-table [site-help (hash)]
#:post-content [post-content null])
(define base-table (get-installers-table table-file))
@ -122,6 +123,29 @@
(list section)))
(loop l keys (append prev (list section)) #t)))])))
(define (get-site-help last-col)
(let ([h (hash-ref site-help last-col #f)])
(if h
(let* ([id "help"]
[toggle (let ([elem (~a "document.getElementById" "('" id "')")])
(~a elem ".style.display = ((" elem ".style.display == 'inline') ? 'none' : 'inline');"
" return false;"))])
`(" "
(div ([class "helpbutton"])
(a ([href "#"]
[class "helpbuttonlabel"]
[onclick ,toggle]
[title "explain"])
nbsp "?" nbsp))
(div ([class "hiddenhelp"]
[id ,id]
[onclick ,toggle]
[style "display: none"])
(div ([class "helpcontent"])
(div ([class "helptext"])
,h)))))
null)))
(call-with-output-file*
dest
#:exists 'truncate/replace
@ -130,12 +154,36 @@
(write-xexpr
`(html
(head (title ,title)
(style ,(~a " .detail { font-size: small; }"
" .checksum, .path { font-family: monospace; }"
" .group { background-color : #ccccff; padding-left: 0.5ex; }"
" .major { font-weight : bold; font-size : large; left-border: 1ex; }"
" .minor { font-weight : bold; }"
" a { text-decoration: none; }")))
(style @,~a|{
.detail { font-size: small; }
.checksum, .path { font-family: monospace; }
.group { background-color : #ccccff; padding-left: 0.5ex; }
.major { font-weight : bold; font-size : large; left-border: 1ex; }
.minor { font-weight : bold; }
.helpbutton {
display: inline;
font-family: sans-serif;
font-size : x-small;
background-color: #ffffee;
border: 1px solid black;
vertical-align: top;
}
.helpbuttonlabel{ vertical-align: top; }
.hiddenhelp {
width: 0em;
position: absolute;
}
.helpcontent {
width: 20em;
font-family: serif;
font-size : small;
font-weight : normal;
background-color: #ffffee;
padding: 10px;
border: 1px solid black;
}
a { text-decoration: none; }
}|))
(body
(h2 ,title)
(table
@ -171,7 +219,8 @@
(combine-url/relative
(string->url installers-url)
inst))))
,last-col)))
,last-col))
,@(get-site-help last-col))
(td nbsp)
(td ,(if (past-success? inst)
`(span ([class "detail"]) "")
@ -225,7 +274,8 @@
(colspan ,num-cols))
,@(for/list ([col (in-list mid-cols)])
`(span nbsp nbsp nbsp))
,last-col))])))
,last-col
,@(get-site-help last-col)))])))
,@(if docs-url
`((p (a ((href ,docs-url)) "Documentation")
,@(if pdf-docs-url

View File

@ -109,6 +109,7 @@
"index.html")
#:current-rx current-rx
#:git-clone (current-directory)
#:help-table (hash-ref config '#:site-help (hash))
#:post-content `((p "Snapshot ID: "
(a ((href ,(string-append current-snapshot
"/index.html")))