Include locale in the JSON response for the packages page

Signed-off-by: Christopher Baines <mail@cbaines.net>
This commit is contained in:
Danjela Lura 2020-06-22 21:09:08 +02:00 committed by Christopher Baines
parent 0b4825427d
commit 5708b81002
4 changed files with 40 additions and 20 deletions

View file

@ -312,13 +312,14 @@
commit-hash)))
(_ #f)))
(define (texinfo->variants-alist s)
(define (texinfo->variants-alist s locale)
(let ((stexi (texi-fragment->stexi s)))
`((source . ,s)
(html . ,(with-output-to-string
(lambda ()
(sxml->html (stexi->shtml stexi)))))
(plain . ,(stexi->plain-text stexi)))))
(plain . ,(stexi->plain-text stexi))
(locale . ,locale))))
(define (render-unknown-revision mime-types conn commit-hash)
(case (most-appropriate-mime-type
@ -597,7 +598,7 @@
(packages
. ,(list->vector
(map (match-lambda
((name version synopsis description home-page
((name version synopsis synopsis-locale description description-locale home-page
location-file location-line
location-column-number licenses)
`((name . ,name)
@ -606,11 +607,11 @@
'())
,@(if (member "synopsis" fields)
`((synopsis
. ,(texinfo->variants-alist synopsis)))
. ,(texinfo->variants-alist synopsis synopsis-locale)))
'())
,@(if (member "description" fields)
`((description
. ,(texinfo->variants-alist description)))
. ,(texinfo->variants-alist description description-locale)))
'())
,@(if (member "home-page" fields)
`((home-page . ,home-page))
@ -737,9 +738,10 @@
`((name . ,name)
(version . ,version)
,@(match metadata
(((synopsis description home-page))
`((synopsis . ,synopsis)
(description . ,description)
(((synopsis synopsis-locale description description-locale home-page file line column-number
licenses))
`((synopsis . ,(texinfo->variants-alist synopsis synopsis-locale))
(description . ,(texinfo->variants-alist description description-locale))
(home-page . ,home-page))))
(derivations . ,(list->vector
(map (match-lambda

View file

@ -199,6 +199,18 @@
(button (@ (type "submit")
(class "btn btn-lg btn-primary"))
"Update results")))))))
(div
(@ (class "row"))
(div
(@ (class "col-sm-12"))
(a (@ (class "btn btn-default btn-lg pull-right")
(href ,(let ((query-params
(query-parameters->string query-parameters)))
(string-append header-link "/package/" name "/" version ".json"
(if (string-null? query-params)
""
(string-append "?" query-params))))))
"View JSON")))
(div
(@ (class "row"))
(div
@ -215,7 +227,7 @@
(div
(@ (class "col-sm-12"))
,(match package-metadata
(((synopsis description home-page file line column-number
(((synopsis synopsis-locale description description-locale home-page file line column-number
licenses))
`(dl
(@ (class "dl-horizontal"))
@ -620,7 +632,7 @@
,@(let ((fields (assq-ref query-parameters 'field)))
(map
(match-lambda
((name version synopsis description home-page
((name version synopsis _ description _ home-page
location-file location-line
location-column-number licenses)
`(tr