aboutsummaryrefslogtreecommitdiffhomepage
path: root/home.lisp
diff options
context:
space:
mode:
authorColin Okay <colin@cicadas.surf>2022-11-02 10:09:40 -0500
committerColin Okay <colin@cicadas.surf>2022-11-02 10:09:40 -0500
commit8aeabd81cd7aa5d1227d24eb3f81c34ebab57184 (patch)
tree8dbe7e22fcc34b9121650f3f73e8f4c6ca253884 /home.lisp
parent3a0b65f86ce67ccff391ea6c1dcf978f7807fb33 (diff)
Add: user pages and links to user pages in playlists
Diffstat (limited to 'home.lisp')
-rw-r--r--home.lisp37
1 files changed, 30 insertions, 7 deletions
diff --git a/home.lisp b/home.lisp
index 71fe31c..5df6aed 100644
--- a/home.lisp
+++ b/home.lisp
@@ -21,18 +21,22 @@
(format nil "/playlist/~a"
(key pl)))
-(defun create-playlist-listing (parent)
- (dolist (pl (user-playlists (session-user parent)))
+(defun create-playlist-listing (parent &optional user)
+ (dolist (pl (user-playlists (or user (session-user parent))))
(with-clog-create parent
(div (:bind pl-item)
(div ()
(playlist-explore-card (pl))
(button (:content "delete" :bind btn))))
- (set-on-click
- btn
- (thunk*
- (destroy-playlist pl)
- (destroy pl-item))))))
+ (cond
+ ((eq user (session-user parent))
+ (set-on-click
+ btn
+ (thunk*
+ (destroy-playlist pl)
+ (destroy pl-item))))
+ (t
+ (destroy btn))))))
(defun create-invite-list-item (invite-list invite)
(with-clog-create invite-list
@@ -88,4 +92,23 @@
(new-playlist-form ())
(invite-control ()))))))
+(defun user-key-from-url (url)
+ (first (last (ppcre:split "/" (nth 4 (multiple-value-list (quri:parse-uri url)))))))
+
+(defun user-listing-page (body)
+ (when-let* ((user-id
+ (user-key-from-url (url (location body))))
+ (user
+ (object-with-key user-id)))
+ (include-style body)
+ (with-clog-create body
+ (div ()
+ (navigation-header ())
+ (div (:class "row")
+ (div ()
+ (section (:h3 :content (format nil "Playlists by ~a"
+ (user-name user))))
+ (div (:class "row")
+ (playlist-listing (user)))))))))
+