view: Define comment-box.
authorRicardo Wurmus <rekado@elephly.net>
Wed, 6 May 2020 09:05:53 +0000 (11:05 +0200)
committerRicardo Wurmus <rekado@elephly.net>
Wed, 6 May 2020 09:05:53 +0000 (11:05 +0200)
mumi/web/view/html.scm

index da3b519c25551e150aded809556d45e9eead4d77..f6ab5182f36438af3fc81672c2edb5f28e2ab499 100644 (file)
@@ -399,6 +399,61 @@ failed to process associated messages.")
                                      ((? number? n)
                                       (list (number->string n)))))))))
                   '()))))
+  (define comment-box
+    `(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)))))))))))
   (define (show-message message-number message previous-subject)
     `((div (@ (class "mb-5"))
            (a (@ (id ,(number->string message-number))))
@@ -453,6 +508,7 @@ failed to process associated messages.")
                 (@ (class "col-11 offset-1 text-center"))
                 (div (@ (class "badge badge-primary closed")) "Closed"))))
             '())))
+
   (if (null? messages) #f
       (layout
        #:title (bug-subject* bug)
@@ -491,60 +547,7 @@ failed to process associated messages.")
                         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)))))))))))))))))
+                ,comment-box)))))))
 
 (define (list-of-bugs bugs)
   "Return table rows for all BUGS."