Add plain text representation for the page for a single job

Signed-off-by: Christopher Baines <mail@cbaines.net>
This commit is contained in:
Danjela Lura 2020-04-20 11:13:13 +02:00 committed by Christopher Baines
parent 60cb07f469
commit c61a8afd36
3 changed files with 26 additions and 11 deletions

View file

@ -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))))))

View file

@ -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"))

View file

@ -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)