aboutsummaryrefslogtreecommitdiff
path: root/guix-data-service/web/controller.scm
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2019-11-09 20:50:53 +0000
committerChristopher Baines <mail@cbaines.net>2019-11-09 20:50:53 +0000
commita658d64b46352830e82de28f8555691b63c9974c (patch)
tree38752ac33faa1607a688d7e595f64dbaa3916457 /guix-data-service/web/controller.scm
parent41afcef9a6d34687d80099659b284bbebd5ec2ef (diff)
downloaddata-service-a658d64b46352830e82de28f8555691b63c9974c.tar
data-service-a658d64b46352830e82de28f8555691b63c9974c.tar.gz
Add a page to show a formatted derivation representation
The HTML is very rough, and the way it's displayed is also rough, but it does provide a way to understand the derivation. I'm also unsure it's a perfect representation, but it's a start at least.
Diffstat (limited to 'guix-data-service/web/controller.scm')
-rw-r--r--guix-data-service/web/controller.scm31
1 files changed, 31 insertions, 0 deletions
diff --git a/guix-data-service/web/controller.scm b/guix-data-service/web/controller.scm
index 27b195c..feac0f1 100644
--- a/guix-data-service/web/controller.scm
+++ b/guix-data-service/web/controller.scm
@@ -118,6 +118,32 @@
"No derivation found with this file name.")
#:code 404))))
+(define (render-formatted-derivation conn derivation-file-name)
+ (let ((derivation (select-derivation-by-file-name conn
+ derivation-file-name)))
+ (if derivation
+ (let ((derivation-inputs (select-derivation-inputs-by-derivation-id
+ conn
+ (first derivation)))
+ (derivation-outputs (select-derivation-outputs-by-derivation-id
+ conn
+ (first derivation)))
+ (derivation-sources (select-derivation-sources-by-derivation-id
+ conn
+ (first derivation))))
+ (render-html
+ #:sxml (view-formatted-derivation derivation
+ derivation-inputs
+ derivation-outputs
+ derivation-sources)
+ #:extra-headers http-headers-for-unchanging-content))
+
+ (render-html
+ #:sxml (general-not-found
+ "Derivation not found"
+ "No derivation found with this file name.")
+ #:code 404))))
+
(define (render-store-item conn filename)
(let ((derivation (select-derivation-by-output-filename conn filename)))
(match derivation
@@ -239,6 +265,11 @@
(if (string-suffix? ".drv" path)
(render-derivation conn path)
(render-store-item conn path))))
+ (('GET "gnu" "store" filename "formatted")
+ (if (string-suffix? ".drv" filename)
+ (render-formatted-derivation conn
+ (string-append "/gnu/store/" filename))
+ (not-found (request-uri request))))
(('GET "compare" _ ...) (delegate-to compare-controller))
(('GET "compare-by-datetime" _ ...) (delegate-to compare-controller))
(('GET "jobs") (delegate-to jobs-controller))