feat(web/panettone): Add direct anchor links to comments

Fixes: #31
Change-Id: I5a8228229eb2b68bdfc5addd305ab055443aa5a6
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1581
Reviewed-by: lukegb <lukegb@tvl.fyi>
Tested-by: BuildkiteCI
This commit is contained in:
Griffin Smith 2020-08-01 22:54:58 -04:00 committed by glittershark
parent 688d4c6be3
commit 7aebba7531
2 changed files with 23 additions and 12 deletions

View file

@ -77,7 +77,11 @@
(.comment-info (.comment-info
:color ,color/gray :color ,color/gray
:margin 0 :margin 0
:padding-top "1rem") :padding-top "1rem"
(a :text-decoration "none")
((:and a :hover)
:text-decoration "underline"))
((:or .comment .event) ((:or .comment .event)
:padding-top "1rem" :padding-top "1rem"
@ -86,6 +90,10 @@
(p :margin 0)) (p :margin 0))
((:and (:or .comment .event) :target)
:border-color ,color/primary
:border-bottom-width "3px")
(.event (.event
:color ,color/gray)))) :color ,color/gray))))

View file

@ -272,23 +272,26 @@
(defgeneric render/issue-history-item (item)) (defgeneric render/issue-history-item (item))
(defmethod render/issue-history-item ((comment model:issue-comment)) (defmethod render/issue-history-item ((comment model:issue-comment))
(let ((fragment (format nil "comment-~A" (id comment))))
(who:with-html-output (*standard-output*) (who:with-html-output (*standard-output*)
(who:htm
(:li (:li
:class "comment" :class "comment"
:id fragment
(:p (who:str (body comment))) (:p (who:str (body comment)))
(:p (:p
:class "comment-info" :class "comment-info"
(:span :class "username" (:span :class "username"
(who:esc (displayname (author comment))) (who:esc (displayname (author comment)))
" at " " at "
(who:esc (format-dottime (created-at comment))))))))) (:a :href (concatenate 'string "#" fragment)
(who:esc (format-dottime (created-at comment))))))))))
(defmethod render/issue-history-item ((event model:issue-event)) (defmethod render/issue-history-item ((event model:issue-event))
(let ((user (find-user-by-dn (acting-user-dn event)))) (let ((user (find-user-by-dn (acting-user-dn event))))
(who:with-html-output (*standard-output*) (who:with-html-output (*standard-output*)
(:li (:li
:class "event" :class "event"
:id
(who:esc (displayname user)) (who:esc (displayname user))
(if (string= (field event) "STATUS") (if (string= (field event) "STATUS")
(who:htm (who:htm