diff options
author | Colin Okay <colin@cicadas.surf> | 2022-10-27 13:46:56 -0500 |
---|---|---|
committer | Colin Okay <colin@cicadas.surf> | 2022-10-27 13:46:56 -0500 |
commit | 7ec9075c8a20b4a8f2b1c0de9e5b86e18ad4ae8e (patch) | |
tree | 19930b67e358630a698275ff1dc506020c83d1b6 | |
parent | 75926d0ed50473efc106fa83231c862063d0f0c3 (diff) |
Add: auth-pages via a middleware page serving function
-rw-r--r-- | playlist.lisp | 20 | ||||
-rw-r--r-- | user.lisp | 12 | ||||
-rw-r--r-- | utilities.lisp | 6 | ||||
-rw-r--r-- | vampire.lisp | 6 |
4 files changed, 27 insertions, 17 deletions
diff --git a/playlist.lisp b/playlist.lisp index c2350d1..d7b08f1 100644 --- a/playlist.lisp +++ b/playlist.lisp @@ -319,24 +319,24 @@ (pl-dur ctl) dur-elem (display input) "none" (display title-elem) "inline") - + (set-on-blur input (thunk* - (when (plusp (length (value input))) - (update-playlist-title pl (value input)) - (setf (text title-elem) (value input))) - (setf (display input) "none" - (display title-elem) "inline"))) + (when (plusp (length (value input))) + (update-playlist-title pl (value input)) + (setf (text title-elem) (value input))) + (setf (display input) "none" + (display title-elem) "inline"))) (set-on-click title-elem (thunk* - (setf (value input) (text title-elem) - (display title-elem) "none" - (display input) "inline") + (setf (value input) (text title-elem) + (display title-elem) "none" + (display input) "inline") (focus input))) - + (initialize-now-playing body))))) @@ -48,12 +48,10 @@ url))))))) (defun user-home-page (body) - (if-let (user (session-user body)) - (with-clog-create body - (div () - (p (:content (format nil "Welcome ~a" (user-name user)))) - (new-playlist-form ()) - (playlist-listing ()))) - (setf (url (location body)) "/"))) + (with-clog-create body + (div () + (p (:content (format nil "Welcome ~a" (user-name (session-user body))))) + (new-playlist-form ()) + (playlist-listing ())))) diff --git a/utilities.lisp b/utilities.lisp index ce14b7e..1ed13a3 100644 --- a/utilities.lisp +++ b/utilities.lisp @@ -121,3 +121,9 @@ hours mins secs) (format nil "~a:~2,'0d" mins secs)))) + +(defun <?> (pred then else) + (lambda (&rest args) + (if (apply pred args) + (apply then args) + (apply else args)))) diff --git a/vampire.lisp b/vampire.lisp index 97266d3..2e8f506 100644 --- a/vampire.lisp +++ b/vampire.lisp @@ -84,6 +84,12 @@ :directory (datastore-directory config) :subsystems (list (make-instance 'bknr.datastore:store-object-subsystem)))) +(defun redirect-to-root (body) + (setf (url (location body)) "/")) + +(defun when-logged-in? (fn) + (<?> 'session-user fn 'redirect-to-root)) + (defun start (config) (setf *config* config) (initialize-database config ) |