From f0eff7d9c69de2e6c7257b8d94e7deb7b89becdf Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Thu, 27 Oct 2022 06:57:19 -0500 Subject: Add+Move: user and model files, moved code into files --- vampire.lisp | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) (limited to 'vampire.lisp') diff --git a/vampire.lisp b/vampire.lisp index cf6accc..85eed95 100644 --- a/vampire.lisp +++ b/vampire.lisp @@ -19,29 +19,21 @@ ;;; RESOURCE MODEL -(defclass/bknr user (keyed) - ((name :with :std "") - (playlists :with :std (list)) - (pw pwhash :with))) + ;;; TRANSACTIONS -(defun new-user (&key name) - (with-transaction () - (make-instance 'user :name name))) + ;;; CLIENT -(defparameter +user-key+ "vampire.userkey") -(defun user-key (window) - (jonathan:parse (storage-element window :local +user-key+))) -(defun (setf user-key) (val window) - (setf (storage-element window :local +user-key+) (jonathan:to-json val))) -(defun session-user (clog-obj) - (object-with-key (user-key (window (connection-body clog-obj))))) + + + + (defun create-new-playlist-form (parent &rest args) (declare (ignorable args)) @@ -78,16 +70,6 @@ (setf (url (location (connection-body parent))) url))))))) - -(defun user-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)) "/"))) - (defun login-page (body) (with-clog-create body (div () @@ -104,7 +86,7 @@ (defun main (body) (if (session-user body) - (setf (url (location body)) "/user") + (setf (url (location body)) "/home") (setf (url (location body)) "/login"))) ;;; STARTUP @@ -123,7 +105,7 @@ (initialize 'main :extended-routing t :static-root (static-directory config)) - (set-on-new-window 'user-page :path "/user") + (set-on-new-window 'user-home-page :path "/home") (set-on-new-window 'login-page :path "/login") (set-on-new-window 'playlist-page :path "/playlist") (open-browser)) -- cgit v1.2.3