From 7f5005a7034952c958df1d84767097778593a1a1 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sat, 9 Aug 2014 10:06:28 -0400 Subject: Show package inputs when viewing package details. * guix-web/view.scm (view-package): Display inputs, native inputs, and propagated inputs when present. --- guix-web/view.scm | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/guix-web/view.scm b/guix-web/view.scm index 35cce29..6898c28 100644 --- a/guix-web/view.scm +++ b/guix-web/view.scm @@ -16,7 +16,9 @@ ;;; . (define-module (guix-web view) + #:use-module (ice-9 match) #:use-module (json) + #:use-module (web uri) #:use-module (guix licenses) #:use-module (guix packages) #:use-module (gnu packages) @@ -100,7 +102,26 @@ `((div (@ (id "guix")) "") ,@(map script-tag javascripts)))) +;; This should be moved client-side and the server should just serve +;; the relevant JSON. (define (view-package name) + (define (describe-inputs package package-inputs description) + (define (describe-input input) + (match input + ((_ input) + `(li + (a (@ (href ,(string-append + "/" + (encode-and-join-uri-path + `("package" ,(package-name input)))))) + ,(string-append (package-name input) " " + (package-version input))))))) + (let ((inputs (package-inputs package))) + (if (null? inputs) + '() + `((dt ,description) + (dd (ul ,@(map describe-input inputs))))))) + (define (describe-package package) `(dl (dt "Version") @@ -110,7 +131,11 @@ (dt "Description") (dd ,(package-description package)) (dt "License") - (dd ,(render-package-license package)))) + (dd ,(render-package-license package)) + ,@(describe-inputs package package-inputs "Inputs") + ,@(describe-inputs package package-native-inputs "Native Inputs") + ,@(describe-inputs package package-propagated-inputs + "Propagated Inputs"))) (let ((packages (find-packages-by-name name))) (define (format-package-count) -- cgit v1.2.3