From 8aeabd81cd7aa5d1227d24eb3f81c34ebab57184 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Wed, 2 Nov 2022 10:09:40 -0500 Subject: Add: user pages and links to user pages in playlists --- home.lisp | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) (limited to 'home.lisp') 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))))))))) + -- cgit v1.2.3