diff options
author | Christopher Baines <mail@cbaines.net> | 2019-05-12 10:11:14 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2019-05-12 10:11:14 +0100 |
commit | de76f89cb3ac2396a2ed9ccb0804b9286f05cc66 (patch) | |
tree | 839bed017a79c33f33d3b7e4600bd1d539ea59fe | |
parent | e64fc090cd6d0bdf2534d8688eec8f3262f4615a (diff) | |
download | data-service-de76f89cb3ac2396a2ed9ccb0804b9286f05cc66.tar data-service-de76f89cb3ac2396a2ed9ccb0804b9286f05cc66.tar.gz |
Add initial JSON output for the package page
-rw-r--r-- | guix-data-service/web/controller.scm | 66 |
1 files changed, 50 insertions, 16 deletions
diff --git a/guix-data-service/web/controller.scm b/guix-data-service/web/controller.scm index e8381a1..7f60b84 100644 --- a/guix-data-service/web/controller.scm +++ b/guix-data-service/web/controller.scm @@ -125,6 +125,50 @@ (apply render-html (view-revision-packages commit-hash packages)))))) +(define (render-revision-package mime-types + conn + commit-hash + name + version) + (let ((metadata + (select-package-metadata-by-revision-name-and-version + conn + commit-hash + name + version)) + (derivations + (select-derivations-by-revision-name-and-version + conn + commit-hash + name + version))) + (case (most-appropriate-mime-type + '(application/json text/html) + mime-types) + ((application/json) + (render-json + `((name . ,name) + (version . ,version) + ,@(match metadata + (((synopsis description home-page)) + `((synopsis . ,synopsis) + (description . ,description) + (home-page . ,home-page)))) + (derivations . ,(list->vector + (map (match-lambda + ((system target file-name status) + `((system . ,system) + (target . ,target) + (derivation . ,file-name)))) + derivations)))))) + (else + (apply render-html + (view-revision-package-and-version commit-hash + name + version + metadata + derivations)))))) + (define (render-compare-unknown-commit mime-types conn base-commit @@ -401,22 +445,12 @@ mime-types conn commit-hash)) - ((GET "revision" commit-hash "package" name version) - (apply render-html - (view-revision-package-and-version - commit-hash - name - version - (select-package-metadata-by-revision-name-and-version - conn - commit-hash - name - version) - (select-derivations-by-revision-name-and-version - conn - commit-hash - name - version)))) + ((GET "revision" commit-hash "package" name version) (render-revision-package + mime-types + conn + commit-hash + name + version)) ((GET "branches") (apply render-html (view-branches |