feat(panettone): Add nav to the top of the page as well

The absence of the navbar containing the "all issues" and "log out"
links from the top of the page has been a common complaint - initially I
disagreed, but after some time thinking about it I've come around. This
adds the same nav - with the "All Issues" link and the "Log Out" link -
to the top of every page, and also fixes a bug where query params would
prevent the "All Issues" link from being hidden on the "All Issues"
page, which looked especially weird when they were right next to each other.

Change-Id: I1d07175fa07aee057ddd140a6864d01342fbb7ef
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1868
Reviewed-by: kanepyork <rikingcoding@gmail.com>
Tested-by: BuildkiteCI
This commit is contained in:
Griffin Smith 2020-08-28 18:10:27 -04:00 committed by glittershark
parent 74a8c3d359
commit de851ec08b
3 changed files with 33 additions and 24 deletions

View file

@ -5,6 +5,7 @@ depot.nix.buildLisp.program {
deps = with depot.third_party.lisp; [
cl-json
cl-ppcre
cl-who
drakma
defclass-std

View file

@ -41,6 +41,7 @@
:panettone.authentication)
(:import-from :defclass-std :defclass/std)
(:import-from :alexandria :if-let :when-let :switch :alist-hash-table)
(:import-from :cl-ppcre :split)
(:import-from
:panettone.model
:id :subject :body :author-dn :issue-id :status :created-at

View file

@ -65,33 +65,35 @@
(setf (who:html-mode) :html5)
(defun render/footer-nav ()
(defun render/nav ()
(who:with-html-output (*standard-output*)
(:footer
(:nav
(if (find (hunchentoot:request-uri*)
(list "/" "/issues/closed")
:test #'string=)
(who:htm (:span :class "placeholder"))
(who:htm (:a :href "/" "All Issues")))
(if *user*
(who:htm
(:form :class "form-link log-out"
:method "post"
:action "/logout"
(:input :type "submit" :value "Log Out")))
(who:htm
(:a :href
(format nil
"/login?original-uri=~A"
(drakma:url-encode (hunchentoot:request-uri*)
:utf-8))
"Log In")))))))
(:nav
(if (find (car (split "\\?" (hunchentoot:request-uri*) :limit 2))
(list "/" "/issues/closed")
:test #'string=)
(who:htm (:span :class "placeholder"))
(who:htm (:a :href "/" "All Issues")))
(if *user*
(who:htm
(:form :class "form-link log-out"
:method "post"
:action "/logout"
(:input :type "submit" :value "Log Out")))
(who:htm
(:a :href
(format nil
"/login?original-uri=~A"
(drakma:url-encode (hunchentoot:request-uri*)
:utf-8))
"Log In"))))))
(defun author (object)
(find-user-by-dn (author-dn object)))
(defmacro render ((&key (footer t)) &body body)
(defmacro render ((&key
(footer t)
(header t))
&body body)
`(who:with-html-output-to-string (*standard-output* nil :prologue t)
(:html
:lang "en"
@ -103,9 +105,14 @@
(:body
(:div
:class "content"
(when ,header
(who:htm
(render/nav)))
,@body
(when ,footer
(render/footer-nav)))))))
(who:htm
(:footer
(render/nav)))))))))
(defun form-button (&key
class
@ -129,7 +136,7 @@
(who:htm (:div :class "alert" (who:esc message))))))
(defun render/login (&key message (original-uri "/"))
(render (:footer nil)
(render (:footer nil :header nil)
(:div
:class "login-form"
(:header