feat(web/panettone): Make issues visible publicly
Make auth optional on the index, closed-issues, and view-issue pages, and only render the various buttons (close issue, new issue, make comment, etc.) if the user is authenticated. Fixes: #5 Change-Id: I0a2aaf4a7cc4c5ef0494cc183410f00d2a3b7e06 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1414 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in>
This commit is contained in:
parent
3e033637b4
commit
e191e0afad
1 changed files with 31 additions and 21 deletions
|
@ -288,9 +288,11 @@ updated issue"
|
||||||
(render ()
|
(render ()
|
||||||
(:header
|
(:header
|
||||||
(:h1 "Issues")
|
(:h1 "Issues")
|
||||||
|
(when *user*
|
||||||
|
(who:htm
|
||||||
(:a
|
(:a
|
||||||
:class "new-issue"
|
:class "new-issue"
|
||||||
:href "/issues/new" "New Issue"))
|
:href "/issues/new" "New Issue"))))
|
||||||
(:main
|
(:main
|
||||||
(:div
|
(:div
|
||||||
:class "issue-links"
|
:class "issue-links"
|
||||||
|
@ -357,6 +359,8 @@ updated issue"
|
||||||
:class "issue-info"
|
:class "issue-info"
|
||||||
(created-by-at issue)
|
(created-by-at issue)
|
||||||
|
|
||||||
|
(when *user*
|
||||||
|
(who:htm
|
||||||
(:form :class "set-issue-status"
|
(:form :class "set-issue-status"
|
||||||
:method "post"
|
:method "post"
|
||||||
:action (format nil "/issues/~A/~A"
|
:action (format nil "/issues/~A/~A"
|
||||||
|
@ -370,7 +374,7 @@ updated issue"
|
||||||
(:closed "open-issue"))
|
(:closed "open-issue"))
|
||||||
:value (case issue-status
|
:value (case issue-status
|
||||||
(:open "Close")
|
(:open "Close")
|
||||||
(:closed "Reopen")))))
|
(:closed "Reopen")))))))
|
||||||
(:p (who:esc (body issue)))
|
(:p (who:esc (body issue)))
|
||||||
(let ((comments (issue-comments issue)))
|
(let ((comments (issue-comments issue)))
|
||||||
(who:htm
|
(who:htm
|
||||||
|
@ -388,7 +392,8 @@ updated issue"
|
||||||
(who:esc (displayname author))
|
(who:esc (displayname author))
|
||||||
" at "
|
" at "
|
||||||
(who:esc (format-dottime (created-at comment)))))))))
|
(who:esc (format-dottime (created-at comment)))))))))
|
||||||
(render/new-comment (get-id issue)))))))))
|
(when *user*
|
||||||
|
(render/new-comment (get-id issue))))))))))
|
||||||
|
|
||||||
(defun render/not-found (entity-type)
|
(defun render/not-found (entity-type)
|
||||||
(render ()
|
(render ()
|
||||||
|
@ -398,6 +403,10 @@ updated issue"
|
||||||
;;; HTTP handlers
|
;;; HTTP handlers
|
||||||
;;;
|
;;;
|
||||||
|
|
||||||
|
(defun @auth-optional (next)
|
||||||
|
(let ((*user* (hunchentoot:session-value 'user)))
|
||||||
|
(funcall next)))
|
||||||
|
|
||||||
(defun @auth (next)
|
(defun @auth (next)
|
||||||
(if-let ((*user* (hunchentoot:session-value 'user)))
|
(if-let ((*user* (hunchentoot:session-value 'user)))
|
||||||
(funcall next)
|
(funcall next)
|
||||||
|
@ -425,11 +434,12 @@ updated issue"
|
||||||
(hunchentoot:delete-session-value 'user)
|
(hunchentoot:delete-session-value 'user)
|
||||||
(hunchentoot:redirect "/"))
|
(hunchentoot:redirect "/"))
|
||||||
|
|
||||||
(defroute index ("/" :decorators (@auth)) ()
|
(defroute index ("/" :decorators (@auth-optional)) ()
|
||||||
(let ((issues (open-issues *p-system*)))
|
(let ((issues (open-issues *p-system*)))
|
||||||
(render/index :issues issues)))
|
(render/index :issues issues)))
|
||||||
|
|
||||||
(defroute handle-closed-issues ("/issues/closed" :decorators (@auth)) ()
|
(defroute handle-closed-issues
|
||||||
|
("/issues/closed" :decorators (@auth-optional)) ()
|
||||||
(let ((issues (closed-issues *p-system*)))
|
(let ((issues (closed-issues *p-system*)))
|
||||||
(render/closed-issues :issues issues)))
|
(render/closed-issues :issues issues)))
|
||||||
|
|
||||||
|
@ -450,7 +460,7 @@ updated issue"
|
||||||
(cl-prevalence:snapshot *p-system*)
|
(cl-prevalence:snapshot *p-system*)
|
||||||
(hunchentoot:redirect "/"))))
|
(hunchentoot:redirect "/"))))
|
||||||
|
|
||||||
(defroute show-issue ("/issues/:id" :decorators (@auth))
|
(defroute show-issue ("/issues/:id" :decorators (@auth-optional))
|
||||||
(&path (id 'integer))
|
(&path (id 'integer))
|
||||||
(handler-case
|
(handler-case
|
||||||
(let* ((issue (get-issue *p-system* id))
|
(let* ((issue (get-issue *p-system* id))
|
||||||
|
|
Loading…
Add table
Reference in a new issue