Add a page to render the channel news entries for a revision
This commit is contained in:
parent
5fc23d788d
commit
53652db9ca
2 changed files with 103 additions and 1 deletions
|
|
@ -28,6 +28,7 @@
|
||||||
#:use-module (guix-data-service web query-parameters)
|
#:use-module (guix-data-service web query-parameters)
|
||||||
#:use-module (guix-data-service web util)
|
#:use-module (guix-data-service web util)
|
||||||
#:use-module (guix-data-service jobs load-new-guix-revision)
|
#:use-module (guix-data-service jobs load-new-guix-revision)
|
||||||
|
#:use-module (guix-data-service model channel-news)
|
||||||
#:use-module (guix-data-service model package)
|
#:use-module (guix-data-service model package)
|
||||||
#:use-module (guix-data-service model git-branch)
|
#:use-module (guix-data-service model git-branch)
|
||||||
#:use-module (guix-data-service model git-repository)
|
#:use-module (guix-data-service model git-repository)
|
||||||
|
|
@ -71,6 +72,19 @@
|
||||||
(render-unknown-revision mime-types
|
(render-unknown-revision mime-types
|
||||||
conn
|
conn
|
||||||
commit-hash)))
|
commit-hash)))
|
||||||
|
(('GET "revision" commit-hash "news")
|
||||||
|
(if (guix-commit-exists? conn commit-hash)
|
||||||
|
(let ((parsed-query-parameters
|
||||||
|
(parse-query-parameters
|
||||||
|
request
|
||||||
|
`((lang ,identity #:multi-value)))))
|
||||||
|
(render-revision-news mime-types
|
||||||
|
conn
|
||||||
|
commit-hash
|
||||||
|
parsed-query-parameters))
|
||||||
|
(render-unknown-revision mime-types
|
||||||
|
conn
|
||||||
|
commit-hash)))
|
||||||
(('GET "revision" commit-hash "packages")
|
(('GET "revision" commit-hash "packages")
|
||||||
(if (guix-commit-exists? conn commit-hash)
|
(if (guix-commit-exists? conn commit-hash)
|
||||||
(let ((parsed-query-parameters
|
(let ((parsed-query-parameters
|
||||||
|
|
@ -215,6 +229,38 @@
|
||||||
#:header-text header-text)
|
#:header-text header-text)
|
||||||
#:extra-headers http-headers-for-unchanging-content)))))
|
#:extra-headers http-headers-for-unchanging-content)))))
|
||||||
|
|
||||||
|
(define (render-revision-news mime-types
|
||||||
|
conn
|
||||||
|
commit-hash
|
||||||
|
query-parameters)
|
||||||
|
(if (any-invalid-query-parameters? query-parameters)
|
||||||
|
(case (most-appropriate-mime-type
|
||||||
|
'(application/json text/html)
|
||||||
|
mime-types)
|
||||||
|
((application/json)
|
||||||
|
(render-json
|
||||||
|
`((error . "invalid query"))))
|
||||||
|
(else
|
||||||
|
(render-html
|
||||||
|
#:sxml (view-revision-news commit-hash
|
||||||
|
query-parameters
|
||||||
|
'()))))
|
||||||
|
(let ((news-entries
|
||||||
|
(select-channel-news-entries-contained-in-guix-revision conn
|
||||||
|
commit-hash)))
|
||||||
|
(case (most-appropriate-mime-type
|
||||||
|
'(application/json text/html)
|
||||||
|
mime-types)
|
||||||
|
((application/json)
|
||||||
|
(render-json
|
||||||
|
'()))
|
||||||
|
(else
|
||||||
|
(render-html
|
||||||
|
#:sxml (view-revision-news commit-hash
|
||||||
|
query-parameters
|
||||||
|
news-entries)
|
||||||
|
#:extra-headers http-headers-for-unchanging-content))))))
|
||||||
|
|
||||||
(define* (render-revision-packages mime-types
|
(define* (render-revision-packages mime-types
|
||||||
conn
|
conn
|
||||||
commit-hash
|
commit-hash
|
||||||
|
|
|
||||||
|
|
@ -24,13 +24,69 @@
|
||||||
#:use-module (guix-data-service web util)
|
#:use-module (guix-data-service web util)
|
||||||
#:use-module (guix-data-service web query-parameters)
|
#:use-module (guix-data-service web query-parameters)
|
||||||
#:use-module (guix-data-service web view html)
|
#:use-module (guix-data-service web view html)
|
||||||
#:export (view-revision-package
|
#:export (view-revision-news
|
||||||
|
view-revision-package
|
||||||
view-revision-package-and-version
|
view-revision-package-and-version
|
||||||
view-revision
|
view-revision
|
||||||
view-revision-packages
|
view-revision-packages
|
||||||
view-revision-lint-warnings
|
view-revision-lint-warnings
|
||||||
unknown-revision))
|
unknown-revision))
|
||||||
|
|
||||||
|
(define* (view-revision-news commit-hash
|
||||||
|
query-parameters
|
||||||
|
news-entries)
|
||||||
|
(layout
|
||||||
|
#:body
|
||||||
|
`(,(header)
|
||||||
|
(div
|
||||||
|
(@ (class "container"))
|
||||||
|
(div
|
||||||
|
(@ (class "row"))
|
||||||
|
(div
|
||||||
|
(@ (class "col-sm-12"))
|
||||||
|
(h3 (a (@ (style "white-space: nowrap;")
|
||||||
|
(href ,(string-append "/revision/" commit-hash)))
|
||||||
|
"Revision " (samp ,commit-hash)))))
|
||||||
|
(div
|
||||||
|
(@ (class "row"))
|
||||||
|
(div
|
||||||
|
(@ (class "col-sm-12"))
|
||||||
|
(h1 "Channel News Entries")
|
||||||
|
,@(map
|
||||||
|
(match-lambda
|
||||||
|
((commit tag title-text body-text)
|
||||||
|
`(div
|
||||||
|
(h4 ,@(if (null? commit)
|
||||||
|
'()
|
||||||
|
`(("Commit: " (samp ,commit))))
|
||||||
|
,@(if (null? tag)
|
||||||
|
'()
|
||||||
|
`(("Tag: " ,tag))))
|
||||||
|
(table
|
||||||
|
(@ (class "table"))
|
||||||
|
(thead
|
||||||
|
(tr
|
||||||
|
(th (@ (class "col-sm-1")) "Language")
|
||||||
|
(th (@ (class "col-sm-3")) "Title")
|
||||||
|
(th (@ (class "col-sm-8")) "Body"))
|
||||||
|
(tbody
|
||||||
|
,@(map (lambda (lang)
|
||||||
|
`(tr
|
||||||
|
(td ,lang)
|
||||||
|
(td ,(stexi->shtml
|
||||||
|
(texi-fragment->stexi
|
||||||
|
(assoc-ref title-text lang))))
|
||||||
|
(td ,
|
||||||
|
(stexi->shtml
|
||||||
|
(texi-fragment->stexi
|
||||||
|
(assoc-ref body-text lang))))))
|
||||||
|
(sort
|
||||||
|
(delete-duplicates
|
||||||
|
(append (map car title-text)
|
||||||
|
(map car body-text)))
|
||||||
|
string<?))))))))
|
||||||
|
news-entries)))))))
|
||||||
|
|
||||||
(define* (view-revision-package revision-commit-hash
|
(define* (view-revision-package revision-commit-hash
|
||||||
name
|
name
|
||||||
versions
|
versions
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue