summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--playlist.lisp20
-rw-r--r--user.lisp12
-rw-r--r--utilities.lisp6
-rw-r--r--vampire.lisp6
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)))))
diff --git a/user.lisp b/user.lisp
index 6fbbf66..6f95b2c 100644
--- a/user.lisp
+++ b/user.lisp
@@ -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 )