From 6d2f5539a5d401856e13c87f34daf4f951cc7c6e Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Fri, 28 Oct 2022 14:49:12 -0500 Subject: Add: sample config; destroy playlist; cli startup --- config.lisp | 5 +++++ model.lisp | 6 ++++++ package.lisp | 2 +- run.lisp | 15 +++++++++++++++ vampire.asd | 6 ++++-- vampire.lisp | 27 ++++++++++++++++++--------- 6 files changed, 49 insertions(+), 12 deletions(-) create mode 100644 config.lisp create mode 100644 run.lisp diff --git a/config.lisp b/config.lisp new file mode 100644 index 0000000..966e90f --- /dev/null +++ b/config.lisp @@ -0,0 +1,5 @@ +(:datastore-directory "~/vampire-store/" + :static-directory "~/vampire-static/" + :swank-port 5011 + :port 8081 + :downloader-threads 5) diff --git a/model.lisp b/model.lisp index b8f564c..399d018 100644 --- a/model.lisp +++ b/model.lisp @@ -156,6 +156,12 @@ (with-transaction () (make-instance 'playlist :title title :user user))) +(defun destroy-playlist (pl) + (with-transaction () + (setf (user-playlists (playlist-user pl)) + (delete pl (user-playlists (playlist-user pl)))) + (bknr.datastore:delete-object pl))) + (defun update-playlist-title (playlist title) (with-transaction () (setf (playlist-title playlist) title))) diff --git a/package.lisp b/package.lisp index 2903fe6..623e166 100644 --- a/package.lisp +++ b/package.lisp @@ -8,7 +8,7 @@ #:persistent-class #:store-objects-with-class #:store-object-id - #:make-blob-from-file) + #:store-object-with-id) (:import-from #:bknr.indices #:string-unique-index #:hash-index diff --git a/run.lisp b/run.lisp new file mode 100644 index 0000000..8961b91 --- /dev/null +++ b/run.lisp @@ -0,0 +1,15 @@ +;;;; run.lisp -- starting from the command line + +(in-package :vampire) + +(defun get-option (name &optional default) + (or + (let ((args (uiop:command-line-arguments))) + (when-let ((pos (position name args :test #'string-equal))) + (nth (1+ pos) args))) + default)) + +(defun run-vampire () + (let ((conf-file (get-option "--config"))) + (start-vampire (config-from-file conf-file))) + (loop while *runningp* do (sleep 1))) diff --git a/vampire.asd b/vampire.asd index ccb1df3..7ffa473 100644 --- a/vampire.asd +++ b/vampire.asd @@ -12,7 +12,8 @@ #:defclass-std #:derrida #:ironclad - #:jonathan) + #:jonathan + #:swank) :components ((:file "package") (:file "definition-macros") (:file "utilities") @@ -25,4 +26,5 @@ (:file "login") (:file "home") (:file "playlist") - (:file "vampire"))) + (:file "vampire") + (:file "run"))) diff --git a/vampire.lisp b/vampire.lisp index f149255..16665fc 100644 --- a/vampire.lisp +++ b/vampire.lisp @@ -7,8 +7,9 @@ (defvar *config* nil) (defclass/std config () - ((datastore-directory :ir :std #P"/srv/parasite/store/") - (static-directory :ir :std #P"/srv/parasite/static/") + ((datastore-directory :ir :std #P"/srv/vampire/store/") + (static-directory :ir :std #P"/srv/vampire/static/") + (swank-port :std nil :doc "If set, swank is started on this port.") (port :ir :std 4919) (downloader-threads :ir :std 5))) @@ -39,11 +40,13 @@ (defun when-logged-in? (fn) ( 'session-user fn 'redirect-to-root)) -(defun start (config) +(defun start-vampire (config) (setf *config* config) (initialize-database config ) (start-downloader-service config) - (initialize 'main + (clog:initialize 'main + :port (port config) + :host "localhost" :extended-routing t :static-root (static-directory config)) (set-on-new-window (when-logged-in? 'user-home-page) :path "/home") @@ -51,10 +54,16 @@ (set-on-new-window (when-logged-in? 'playlist-page) :path "/playlist") (set-on-new-window 'new-accout-page :path "/new-account") (set-on-new-window (when-logged-in? 'explore-page) :path "/explore") - (open-browser)) + + (when (swank-port config) + (swank:create-server :port (swank-port config)))) (defun hacking-start () - (start (make-instance - 'config - :static-directory (merge-pathnames "vampire-static/" (user-homedir-pathname)) - :datastore-directory (merge-pathnames "vampire-store/" (user-homedir-pathname))))) + (start-vampire (make-instance + 'config + :static-directory (merge-pathnames "vampire-static/" (user-homedir-pathname)) + :datastore-directory (merge-pathnames "vampire-store/" (user-homedir-pathname)))) + (clog:open-browser)) + + + -- cgit v1.2.3