web: Render "unknown" instead of showing a blank page.
authorRicardo Wurmus <rekado@elephly.net>
Wed, 22 Apr 2020 16:02:23 +0000 (18:02 +0200)
committerRicardo Wurmus <rekado@elephly.net>
Wed, 22 Apr 2020 16:02:23 +0000 (18:02 +0200)
mumi/web/controller.scm
mumi/web/view/html.scm

index 6ca7627b3d02dd3c2b2700bcf86de4b70fc9efb3..e55f127dd31f7fac2b650994a2ccd0dbb7a0fbf8 100644 (file)
                      ;; 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?)
index b5552d2771bc84c4db60245dd6ede25f800e35e6..b474a328233355c51e531ea1930eb2534c90d9d5 100644 (file)
@@ -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."