diff options
author | David Thompson <dthompson2@worcester.edu> | 2014-08-07 09:21:34 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2014-08-07 09:23:57 -0400 |
commit | 0084cc96cb575d268e80f5771e5c6179a089ea07 (patch) | |
tree | 08cd8329a3c442bdcc8d7b53a4881380dc5de4e5 | |
parent | 4d714280d2f8d0b13de4c532a940cb85b48b5db5 (diff) |
Add /package endpoint.
* guix-web (file-mime-types): Add image/png.
(run-route): Add /package endpoint.
(license-link): Delete it.
(render-package-license): New procedure.
(view-package): New procedure.
* images/logo.png: New file.
-rwxr-xr-x | guix-web | 53 | ||||
-rw-r--r-- | images/logo.png | bin | 0 -> 5208 bytes |
2 files changed, 44 insertions, 9 deletions
@@ -50,7 +50,8 @@ (define file-mime-types '(("css" . (text/css)) - ("js" . (text/javascript)))) + ("js" . (text/javascript)) + ("png" . (image/png)))) (define (serve-static-asset request) (let ((filename (string-join @@ -128,6 +129,8 @@ (render-html (all-packages))) ((GET "packages.json") (render-json (all-packages-json))) + ((GET "package" name) + (render-html (view-package name))) ((GET "weblabels") (render-html (weblabels))) (_ #f))) @@ -159,15 +162,20 @@ ("license" ,(serialize-license p))))) (fold-packages cons '())))) -(define (license-link package) +(define (render-package-license package) + (define (license-link license) + `(a (@ (href ,(license-uri license))) + ,(license-name license))) + (let ((license (package-license package))) - (if license - (let ((license (if (list? license) - (first license) - license))) - `(a (@ (href ,(license-uri license))) - ,(license-name license))) - ""))) + (cond ((list? license) + `(ul (@ (class "list-inline")) + ,@(map (lambda (l) + `(li ,(license-link l))) + license))) + ((license? license) + (license-link license)) + (else "")))) (define (all-packages) `(html @@ -185,6 +193,33 @@ "JavaScript license information"))) ,@(map script-tag javascripts)))) +(define (view-package name) + (define (describe-package package) + `(dl + (dt "Version") + (dd ,(package-version package)) + (dt "Synopsis") + (dd ,(package-synopsis package)) + (dt "Description") + (dd ,(package-description package)) + (dt "License") + (dd ,(render-package-license package)))) + + (let ((packages (find-packages-by-name name))) + `(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")) ,(length packages))) + (ul (@ (class "list-unstyled")) + ,@(map (lambda (p) + `(li ,(describe-package p))) + packages))))))) + (define (weblabels) (define (weblabel js) `(tr diff --git a/images/logo.png b/images/logo.png Binary files differnew file mode 100644 index 0000000..9ca28a9 --- /dev/null +++ b/images/logo.png |