guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: Add plain text representation for the page for a


From: Christopher Baines
Subject: branch master updated: Add plain text representation for the page for a single job
Date: Mon, 20 Apr 2020 17:28:10 -0400

This is an automated email from the git hooks/post-receive script.

cbaines pushed a commit to branch master
in repository data-service.

The following commit(s) were added to refs/heads/master by this push:
     new c61a8af  Add plain text representation for the page for a single job
c61a8af is described below

commit c61a8afd3646837c2752f9c95306a254d659b2d4
Author: Danjela Lura <address@hidden>
AuthorDate: Mon Apr 20 11:13:13 2020 +0200

    Add plain text representation for the page for a single job
    
    Signed-off-by: Christopher Baines <address@hidden>
---
 guix-data-service/web/jobs/controller.scm | 25 ++++++++++++++++---------
 guix-data-service/web/jobs/html.scm       |  9 ++++++++-
 guix-data-service/web/util.scm            |  3 ++-
 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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]