aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanjela Lura <danielaluraa@gmail.com>2020-04-20 11:13:13 +0200
committerChristopher Baines <mail@cbaines.net>2020-04-20 22:27:55 +0100
commitc61a8afd3646837c2752f9c95306a254d659b2d4 (patch)
treef279fce5ad019dbc662fed7424a75d0fdc5d985e
parent60cb07f469c6ad0a1dd483c5ad217b20073d9e77 (diff)
downloaddata-service-c61a8afd3646837c2752f9c95306a254d659b2d4.tar
data-service-c61a8afd3646837c2752f9c95306a254d659b2d4.tar.gz
Add plain text representation for the page for a single job
Signed-off-by: Christopher Baines <mail@cbaines.net>
-rw-r--r--guix-data-service/web/jobs/controller.scm25
-rw-r--r--guix-data-service/web/jobs/html.scm9
-rw-r--r--guix-data-service/web/util.scm3
3 files changed, 26 insertions, 11 deletions
diff --git a/guix-data-service/web/jobs/controller.scm b/guix-data-service/web/jobs/controller.scm
index 24a1274..3de9827 100644
--- a/guix-data-service/web/jobs/controller.scm
+++ b/guix-data-service/web/jobs/controller.scm
@@ -131,13 +131,20 @@
(select-unprocessed-jobs-and-events conn))))
(define (render-job mime-types conn job-id query-parameters)
- (render-html
- #:sxml (view-job
- job-id
- query-parameters
- (log-for-job conn job-id
- #:character-limit
- (assq-ref query-parameters 'characters)
- #:start-character
- (assq-ref query-parameters 'start_character)))))
+ (let ((log-text (log-for-job conn job-id
+ #:character-limit
+ (assq-ref query-parameters 'characters)
+ #:start-character
+ (assq-ref query-parameters 'start_character))))
+ (case (most-appropriate-mime-type
+ '(text/plain text/html)
+ mime-types)
+ ((text/plain)
+ (render-text log-text))
+ (else
+ (render-html
+ #:sxml (view-job
+ job-id
+ query-parameters
+ log-text))))))
diff --git a/guix-data-service/web/jobs/html.scm b/guix-data-service/web/jobs/html.scm
index 742d7bd..4495391 100644
--- a/guix-data-service/web/jobs/html.scm
+++ b/guix-data-service/web/jobs/html.scm
@@ -358,7 +358,14 @@
(div
(@ (class "row"))
(div
- (@ (class "col-sm-12"))
+ (@ (class "col-md-6"))
+ (a (@ (class "btn btn-default btn-lg pull-left")
+ (style "margin-bottom: 20px;")
+ (href ,(string-append
+ "/job/" job-id ".txt")))
+ "View plain text"))
+ (div
+ (@ (class "col-md-6"))
(a (@ (class "btn btn-default btn-lg pull-right")
(style "margin-bottom: 20px;")
(href "#bottom"))
diff --git a/guix-data-service/web/util.scm b/guix-data-service/web/util.scm
index 108c9ec..d5c18c4 100644
--- a/guix-data-service/web/util.scm
+++ b/guix-data-service/web/util.scm
@@ -44,7 +44,8 @@
(define (request->path-components-and-mime-type request)
(define extensions-to-mime-types
'(("json" . application/json)
- ("html" . text/html)))
+ ("html" . text/html)
+ ("txt" . text/plain)))
(define (ends-with-recognised-extension? path)
(any (lambda (extension)