aboutsummaryrefslogtreecommitdiff
path: root/guix-data-service
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2019-09-23 16:44:16 +0100
committerChristopher Baines <mail@cbaines.net>2019-09-23 16:44:16 +0100
commitb96bc58422222ff883c517615052add6869fc6c9 (patch)
tree3cca8bdaa6d70a07eed20251deb917b7c0fa221c /guix-data-service
parent970bcb31cf994b0e3b67e7f912734e5b53355d8d (diff)
downloaddata-service-b96bc58422222ff883c517615052add6869fc6c9.tar
data-service-b96bc58422222ff883c517615052add6869fc6c9.tar.gz
Handle the README.html file being missing
Diffstat (limited to 'guix-data-service')
-rw-r--r--guix-data-service/web/controller.scm14
-rw-r--r--guix-data-service/web/view/html.scm7
2 files changed, 14 insertions, 7 deletions
diff --git a/guix-data-service/web/controller.scm b/guix-data-service/web/controller.scm
index 55a136e..f497d32 100644
--- a/guix-data-service/web/controller.scm
+++ b/guix-data-service/web/controller.scm
@@ -20,6 +20,7 @@
#:use-module (ice-9 match)
#:use-module (ice-9 vlist)
#:use-module (ice-9 pretty-print)
+ #:use-module (ice-9 textual-ports)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-11)
#:use-module (srfi srfi-26)
@@ -30,6 +31,7 @@
#:use-module (texinfo plain-text)
#:use-module (squee)
#:use-module (json)
+ #:use-module (guix-data-service config)
#:use-module (guix-data-service comparison)
#:use-module (guix-data-service database)
#:use-module (guix-data-service model git-branch)
@@ -721,8 +723,16 @@
200
500))))
(('GET "README")
- (render-html
- #:sxml (readme)))
+ (let ((filename (string-append (%config 'doc-dir) "/README.html")))
+ (if (file-exists? filename)
+ (render-html
+ #:sxml (readme (call-with-input-file filename
+ get-string-all)))
+ (render-html
+ #:sxml (general-not-found
+ "README not found"
+ "The README.html file does not exist")
+ #:code 404))))
(_
(with-postgresql-connection
"web"
diff --git a/guix-data-service/web/view/html.scm b/guix-data-service/web/view/html.scm
index d0b480b..11833de 100644
--- a/guix-data-service/web/view/html.scm
+++ b/guix-data-service/web/view/html.scm
@@ -23,7 +23,6 @@
#:use-module (guix-data-service web util)
#:use-module (ice-9 vlist)
#:use-module (ice-9 match)
- #:use-module (ice-9 textual-ports)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-19)
#:use-module (texinfo)
@@ -223,7 +222,7 @@
'())))
'())))))
-(define (readme)
+(define (readme contents)
(layout
#:body
`(,(header)
@@ -238,9 +237,7 @@
(@ (class "row"))
(div
(@ (class "col-sm-12"))
- (raw ,(call-with-input-file
- (string-append (%config 'doc-dir) "/README.html")
- get-string-all))))))))
+ (raw ,contents)))))))
(define (index git-repositories-and-revisions)
(layout