diff options
author | Ricardo Wurmus <rekado@elephly.net> | 2020-04-22 18:02:23 +0200 |
---|---|---|
committer | Ricardo Wurmus <rekado@elephly.net> | 2020-04-22 18:02:23 +0200 |
commit | f2b63f63aba2b210d2e556672c46fbca18556b76 (patch) | |
tree | 880873159b4ac8fd1b0017698977e2f2e721f76c | |
parent | 67566dd084312e9eab0d03df46aaec8785623720 (diff) |
web: Render "unknown" instead of showing a blank page.
-rw-r--r-- | mumi/web/controller.scm | 8 | ||||
-rw-r--r-- | mumi/web/view/html.scm | 339 |
2 files changed, 175 insertions, 172 deletions
diff --git a/mumi/web/controller.scm b/mumi/web/controller.scm index 6ca7627..e55f127 100644 --- a/mumi/web/controller.scm +++ b/mumi/web/controller.scm @@ -116,9 +116,11 @@ ;; Tell browser to cache this for 1 hour. (cons cookie-header '((cache-control . ((max-age . 3600)))))) - (else (list cookie-header))))) - (render-html (issue-page bug message) - #:extra-headers headers)) + (else (list cookie-header)))) + (page (issue-page bug message))) + (if page + (render-html page #:extra-headers headers) + (render-html (unknown id)))) (render-html (unknown id))))) (('POST "issue" (? string->number id) "comment") (if (mailer-enabled?) diff --git a/mumi/web/view/html.scm b/mumi/web/view/html.scm index b5552d2..b474a32 100644 --- a/mumi/web/view/html.scm +++ b/mumi/web/view/html.scm @@ -350,179 +350,180 @@ some examples.") (@ (class "col-11 offset-1 text-center")) (div (@ (class "badge badge-primary closed")) "Closed")))) '()))) - (layout - #:title (bug-subject* bug) - #:body - `(,(header) - (div - (@ (class "container")) - ,@(match flash-message - (('error . text) - `((div (@ (class "alert alert-danger") - (role "alert")) - ,text))) - (('info . text) - `((div (@ (class "alert alert-info") - (role "alert")) - ,text))) - (_ '())) - (div - (@ (class "title col-12")) - (h1 ,(bug-subject* bug)) - (span (@ (class "details")) - ,(status-tag bug) - ,(string-append "Submitted by " - ;; We don't use bug-originator here - ;; because it includes the email address. - ;; We cannot use extract-name on the - ;; return value, because it swallows - ;; non-ASCII characters. - (sender-name (first messages)) - ".") - ,@(if (bug-mergedwith bug) - `((ul (@ (class "merged")) - "Merged with: " - ,(map (lambda (id) - `(li (a (@ (href ,(string-append "/issue/" id))) - ,id))) - ;; XXX: This field can either hold a - ;; string of multiple ids, or a single - ;; number. Deal with this mess. - (match (bug-mergedwith bug) - ((? string? str) - (string-split str #\space)) - ((? number? n) - (list (number->string n))))))) - '()) - ,@(if (bug-blocks bug) - `((ul (@ (class "blocks")) - "Blocks: " - ,(map (lambda (id) - `(li (a (@ (href ,(string-append "/issue/" id))) - ,id))) - ;; XXX: This field can either hold a - ;; string of multiple ids, or a single - ;; number. Deal with this mess. - (match (bug-blocks bug) - ((? string? str) - (string-split str #\space)) - ((? number? n) - (list (number->string n))))))) - '()) - ,@(if (bug-blockedby bug) - `((ul (@ (class "blockedby")) - "Blocked by: " - ,(map (lambda (id) - `(li (a (@ (href ,(string-append "/issue/" id))) - ,id))) - ;; XXX: This field can either hold a - ;; string of multiple ids, or a single - ;; number. Deal with this mess. - (match (bug-blockedby bug) - ((? string? str) - (string-split str #\space)) - ((? number? n) - (list (number->string n))))))) - '()))) - (div (@ (class "row")) - (div - (@ (class "conversation col-lg-9")) - ,(let ((msgs (filter (lambda (msg) - ;; Ignore messages - ;; without body, and - ;; internal messages. - (and msg - (email-body msg) - (not (internal-message? msg)))) - messages))) - (map (lambda (message-number msg previous-subject) - (show-message message-number msg previous-subject)) - (iota (length msgs)) - msgs - (cons (bug-subject* bug) - (map subject msgs)))) - (div - (@ (class "comment-box")) - (a (@ (id "comment"))) + (if (null? messages) #f + (layout + #:title (bug-subject* bug) + #:body + `(,(header) (div - (@ (class "avatar") - (style "background-color:#bc80bd")) "?") - (div - (@ (class "message")) + (@ (class "container")) + ,@(match flash-message + (('error . text) + `((div (@ (class "alert alert-danger") + (role "alert")) + ,text))) + (('info . text) + `((div (@ (class "alert alert-info") + (role "alert")) + ,text))) + (_ '())) (div - (@ (class "card")) - ,@(if (mailer-enabled?) - `((form - (@ (action ,(format #f "/issue/~a/comment" - (number->string id))) - (enctype "multipart/form-data") - (method "POST")) - (input (@ (style "display:none") - (name "validation") - (placeholder "Please leave this empty.")) "") - (input (@ (type "hidden") - (name "timestamp") - (value ,(timestamp!))) "") - (div - (@ (class "card-header")) - (div (@ (class "from")) - (input (@ (class "address form-control") - (name "from") - (required "required") - (placeholder "Your name")) ""))) - (div - (@ (class "body card-body")) - (textarea (@ (name "text") - (required "required") - (class "form-control") - (placeholder "Please input your comment...")) - "")) - (div - (@ (class "card-footer")) - (button (@ (class "btn btn-primary") - (type "submit")) - "Send")))) - `((div - (@ (class "card-header")) - (div (@ (class "from")) - (span (@ (class "address")) "Your comment"))) - (div - (@ (class "body card-body")) - (p "Comments via the web interface are not currently + (@ (class "title col-12")) + (h1 ,(bug-subject* bug)) + (span (@ (class "details")) + ,(status-tag bug) + ,(string-append "Submitted by " + ;; We don't use bug-originator here + ;; because it includes the email address. + ;; We cannot use extract-name on the + ;; return value, because it swallows + ;; non-ASCII characters. + (sender-name (first messages)) + ".") + ,@(if (bug-mergedwith bug) + `((ul (@ (class "merged")) + "Merged with: " + ,(map (lambda (id) + `(li (a (@ (href ,(string-append "/issue/" id))) + ,id))) + ;; XXX: This field can either hold a + ;; string of multiple ids, or a single + ;; number. Deal with this mess. + (match (bug-mergedwith bug) + ((? string? str) + (string-split str #\space)) + ((? number? n) + (list (number->string n))))))) + '()) + ,@(if (bug-blocks bug) + `((ul (@ (class "blocks")) + "Blocks: " + ,(map (lambda (id) + `(li (a (@ (href ,(string-append "/issue/" id))) + ,id))) + ;; XXX: This field can either hold a + ;; string of multiple ids, or a single + ;; number. Deal with this mess. + (match (bug-blocks bug) + ((? string? str) + (string-split str #\space)) + ((? number? n) + (list (number->string n))))))) + '()) + ,@(if (bug-blockedby bug) + `((ul (@ (class "blockedby")) + "Blocked by: " + ,(map (lambda (id) + `(li (a (@ (href ,(string-append "/issue/" id))) + ,id))) + ;; XXX: This field can either hold a + ;; string of multiple ids, or a single + ;; number. Deal with this mess. + (match (bug-blockedby bug) + ((? string? str) + (string-split str #\space)) + ((? number? n) + (list (number->string n))))))) + '()))) + (div (@ (class "row")) + (div + (@ (class "conversation col-lg-9")) + ,(let ((msgs (filter (lambda (msg) + ;; Ignore messages + ;; without body, and + ;; internal messages. + (and msg + (email-body msg) + (not (internal-message? msg)))) + messages))) + (map (lambda (message-number msg previous-subject) + (show-message message-number msg previous-subject)) + (iota (length msgs)) + msgs + (cons (bug-subject* bug) + (map subject msgs)))) + (div + (@ (class "comment-box")) + (a (@ (id "comment"))) + (div + (@ (class "avatar") + (style "background-color:#bc80bd")) "?") + (div + (@ (class "message")) + (div + (@ (class "card")) + ,@(if (mailer-enabled?) + `((form + (@ (action ,(format #f "/issue/~a/comment" + (number->string id))) + (enctype "multipart/form-data") + (method "POST")) + (input (@ (style "display:none") + (name "validation") + (placeholder "Please leave this empty.")) "") + (input (@ (type "hidden") + (name "timestamp") + (value ,(timestamp!))) "") + (div + (@ (class "card-header")) + (div (@ (class "from")) + (input (@ (class "address form-control") + (name "from") + (required "required") + (placeholder "Your name")) ""))) + (div + (@ (class "body card-body")) + (textarea (@ (name "text") + (required "required") + (class "form-control") + (placeholder "Please input your comment...")) + "")) + (div + (@ (class "card-footer")) + (button (@ (class "btn btn-primary") + (type "submit")) + "Send")))) + `((div + (@ (class "card-header")) + (div (@ (class "from")) + (span (@ (class "address")) "Your comment"))) + (div + (@ (class "body card-body")) + (p "Comments via the web interface are not currently supported. To comment on this conversation " - (a (@ (href ,(string-append "mailto:" - (number->string id) "@" (%config 'debbugs-domain) - "?subject=" (bug-subject* bug)))) - ,(string-append "send email to " - (number->string id) "@" (%config 'debbugs-domain))))))))))) + (a (@ (href ,(string-append "mailto:" + (number->string id) "@" (%config 'debbugs-domain) + "?subject=" (bug-subject* bug)))) + ,(string-append "send email to " + (number->string id) "@" (%config 'debbugs-domain))))))))))) - (div - (@ (class "info col-lg-3")) - (dl - (@ (class "stat")) - ,@(let ((num (length parties))) - `((dt ,(if (= num 1) - "One participant" - (string-append (number->string num) - " participants"))) - (dd - (ul ,(map (lambda (name) - `(li (span (@ (class "name"))) - ,name)) - (map extract-name parties))))))) - (dl - (@ (class "stat")) - (dt "Owner") - (dd - ,(or (and=> (bug-owner bug) extract-name) "unassigned"))) - (dl - (@ (class "stat")) - (dt "Severity") - (dd ,(bug-severity bug))) - (dl - (@ (class "stat")) - (dt "Status") - (dd ,(status-tag bug))))))))) + (div + (@ (class "info col-lg-3")) + (dl + (@ (class "stat")) + ,@(let ((num (length parties))) + `((dt ,(if (= num 1) + "One participant" + (string-append (number->string num) + " participants"))) + (dd + (ul ,(map (lambda (name) + `(li (span (@ (class "name"))) + ,name)) + (map extract-name parties))))))) + (dl + (@ (class "stat")) + (dt "Owner") + (dd + ,(or (and=> (bug-owner bug) extract-name) "unassigned"))) + (dl + (@ (class "stat")) + (dt "Severity") + (dd ,(bug-severity bug))) + (dl + (@ (class "stat")) + (dt "Status") + (dd ,(status-tag bug)))))))))) (define (list-of-bugs bugs) "Return table rows for all BUGS." |