diff options
author | David Thompson <dthompson2@worcester.edu> | 2014-08-07 17:29:34 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2014-08-07 17:29:34 -0400 |
commit | b210fd00100d04aac022f3ab973f87dd7505b60e (patch) | |
tree | 978d958e4461d4127ac8b3beef44dab35af9b7d5 | |
parent | d8d6c0877391afc8d089632317399bbfdd409229 (diff) |
Extract common page layout to procedure.
* guix-web (main-layout): New procedure.
(all-packages, view-package, weblabels): Use main-layout.
-rwxr-xr-x | guix-web | 72 |
1 files changed, 38 insertions, 34 deletions
@@ -162,6 +162,22 @@ ("license" ,(serialize-license p))))) (fold-packages cons '())))) +(define (main-layout subtitle body) + `(html + (head + (title ,(string-append "GNU Guix - " subtitle)) + (link (@ (rel "stylesheet") + (href "/css/bootstrap.css")))) + (body + (div (@ (class "container")) + (image (@ (src "/images/logo.png"))) + ,@body + (footer + (small + (a (@ (href "/librejs") + (rel "jslicense")) + "JavaScript license information"))))))) + (define (render-package-license package) (define (license-link license) `(a (@ (href ,(license-uri license))) @@ -178,19 +194,9 @@ (else "")))) (define (all-packages) - `(html - (head - (title "GNU Guix") - (link (@ (rel "stylesheet") - (href "/css/bootstrap.css")))) - (body - (div (@ (id "guix") - (class "container"))) - (footer - (small - (a (@ (href "/weblabels") - (rel "jslicense")) - "JavaScript license information"))) + (main-layout + "Packages" + `((div (@ (id "guix")) "") ,@(map script-tag javascripts)))) (define (view-package name) @@ -213,22 +219,16 @@ (if (> count 1) "versions" "version")))) - `(html - (head - (title ,(string-append "GNU Guix - " name)) - (link (@ (rel "stylesheet") - (href "/css/bootstrap.css")))) - (body - (div (@ (class "container")) - (image (@ (src "/images/logo.png"))) - (h1 ,name (span (@ (class "badge")) - ,(format-package-count))) - (ul (@ (class "list-unstyled")) - ,@(map (lambda (p) - `(li ,(describe-package p))) - packages))))))) (define (weblabels) + (main-layout + name + `((h1 ,name (span (@ (class "badge")) + ,(format-package-count))) + (ul (@ (class "list-unstyled")) + ,@(map (lambda (p) + `(li ,(describe-package p))) + packages)))))) (define (weblabel js) `(tr (td @@ -241,13 +241,17 @@ (a (@ (href ,js)) ,(basename js))))) - `(html - (head - (title "GNU Guix")) - (body - (div (@ (class "container")) - (table (@ (id "jslicense-labels1")) - ,@(map weblabel javascripts)))))) + (main-layout + "LibreJS" + `((h1 "JavaScript License Information") + (table (@ (id "jslicense-labels1") + (class "table")) + (thead + (tr + (th "URI") + (th "License") + (th "Source Code"))) + (tbody ,@(map weblabel javascripts)))))) (spawn-server (make-tcp-server-socket #:port 37146)) (run-server (lambda args (apply handler args))) |