Add some options to the branch page

Add handling for some query parameters to the branch page. This takes
advantage of the improvements for building forms and query parameter
validation.
This commit is contained in:
Christopher Baines 2019-05-11 16:49:18 +01:00
parent a7053846f1
commit 3611f7b122
3 changed files with 64 additions and 7 deletions

View file

@ -348,12 +348,27 @@
(view-branches
(all-branches-with-most-recent-commit conn))))
((GET "branch" branch-name)
(apply render-html
(let ((parsed-query-parameters
(parse-query-parameters
request
`((after_date ,parse-datetime)
(before_date ,parse-datetime)
(limit_results ,parse-result-limit #:default 100)))))
(apply
render-html
(if (any-invalid-query-parameters? parsed-query-parameters)
(view-branch branch-name parsed-query-parameters '())
(view-branch
branch-name
(most-recent-100-commits-for-branch
parsed-query-parameters
(most-recent-commits-for-branch
conn
branch-name))))
branch-name
#:limit (assq-ref parsed-query-parameters 'limit_results)
#:after-date (assq-ref parsed-query-parameters
'after_date)
#:before-date (assq-ref parsed-query-parameters
'before_date)))))))
((GET "gnu" "store" filename)
(if (string-suffix? ".drv" filename)
(render-derivation conn (string-append "/gnu/store/" filename))