2
0
Fork 0
mirror of git://git.savannah.gnu.org/guix/data-service.git synced 2023-12-14 03:23:03 +01:00

Add indications for no translations available in the packages page

Signed-off-by: Christopher Baines <mail@cbaines.net>
This commit is contained in:
Danjela Lura 2020-06-23 13:44:18 +02:00 committed by Christopher Baines
parent 7d85372acc
commit f16fdb44f1
3 changed files with 34 additions and 6 deletions

View file

@ -32,7 +32,9 @@
select-package-versions-for-revision select-package-versions-for-revision
package-versions-for-branch package-versions-for-branch
package-derivations-for-branch package-derivations-for-branch
package-outputs-for-branch)) package-outputs-for-branch
any-package-synopsis-or-descriptions-translations?))
(define (select-existing-package-entries package-entries) (define (select-existing-package-entries package-entries)
(string-append "SELECT id, packages.name, packages.version, " (string-append "SELECT id, packages.name, packages.version, "
@ -530,3 +532,11 @@ ORDER BY first_datetime DESC, package_version DESC")
output-name output-name
system system
target)))) target))))
(define (any-package-synopsis-or-descriptions-translations? packages locale)
(any
(match-lambda
((name version synopsis synopsis-locale description description-locale _ _ _ _ _)
(or (string=? synopsis-locale locale)
(string=? description-locale locale))))
packages))

View file

@ -568,6 +568,7 @@
(limit-results (or (assq-ref query-parameters 'limit_results) (limit-results (or (assq-ref query-parameters 'limit_results)
99999)) ; TODO There shouldn't be a limit 99999)) ; TODO There shouldn't be a limit
(fields (assq-ref query-parameters 'field)) (fields (assq-ref query-parameters 'field))
(locale (assq-ref query-parameters 'locale))
(packages (packages
(if search-query (if search-query
(search-packages-in-revision (search-packages-in-revision
@ -587,7 +588,9 @@
(show-next-page? (show-next-page?
(and (not search-query) (and (not search-query)
(>= (length packages) (>= (length packages)
limit-results)))) limit-results)))
(any-translations? (any-package-synopsis-or-descriptions-translations?
packages locale)))
(case (most-appropriate-mime-type (case (most-appropriate-mime-type
'(application/json text/html) '(application/json text/html)
mime-types) mime-types)
@ -638,6 +641,7 @@
git-repositories git-repositories
show-next-page? show-next-page?
description-and-synopsis-locale-options description-and-synopsis-locale-options
any-translations?
#:path-base path-base #:path-base path-base
#:header-text header-text #:header-text header-text
#:header-link header-link) #:header-link header-link)

View file

@ -532,6 +532,7 @@
git-repositories git-repositories
show-next-page? show-next-page?
locale-options locale-options
any-translations-available?
#:key path-base #:key path-base
header-text header-link) header-text header-link)
(define field-options (define field-options
@ -571,7 +572,10 @@
#:options locale-options #:options locale-options
#:allow-selecting-multiple-options #f #:allow-selecting-multiple-options #f
#:help-text #:help-text
"Language.") (if any-translations-available?
"Language."
'((span (@ (class "text-danger"))
"No translations available in this page."))))
,(form-horizontal-control ,(form-horizontal-control
"Search query" query-parameters "Search query" query-parameters
#:help-text #:help-text
@ -632,7 +636,7 @@
,@(let ((fields (assq-ref query-parameters 'field))) ,@(let ((fields (assq-ref query-parameters 'field)))
(map (map
(match-lambda (match-lambda
((name version synopsis _ description _ home-page ((name version synopsis synopsis-locale description description-locale home-page
location-file location-line location-file location-line
location-column-number licenses) location-column-number licenses)
`(tr `(tr
@ -641,10 +645,20 @@
`((td ,version)) `((td ,version))
'()) '())
,(if (member "synopsis" fields) ,(if (member "synopsis" fields)
`((td ,(stexi->shtml (texi-fragment->stexi synopsis)))) `((td ,(stexi->shtml (texi-fragment->stexi synopsis))
,(if (string=? synopsis-locale
(assq-ref query-parameters 'locale))
""
'((span (@ (class "text-danger"))
"No translation available for synopsis.")))))
'()) '())
,(if (member "description" fields) ,(if (member "description" fields)
`((td ,(stexi->shtml (texi-fragment->stexi description)))) `((td ,(stexi->shtml (texi-fragment->stexi description))
,(if (string=? description-locale
(assq-ref query-parameters 'locale))
""
'((span (@ (class "text-danger"))
"No translation available for description.")))))
'()) '())
,(if (member "home-page" fields) ,(if (member "home-page" fields)
`((td ,home-page)) `((td ,home-page))