From 03029efd07ad5273818e585a9b94472dbfcc06e6 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Sat, 22 Oct 2022 08:27:26 -0500 Subject: Add: Resource model and some utilities --- vampire.lisp | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'vampire.lisp') diff --git a/vampire.lisp b/vampire.lisp index f6d5d20..7ad9b63 100644 --- a/vampire.lisp +++ b/vampire.lisp @@ -1,3 +1,58 @@ ;;;; vampire.lisp (in-package #:vampire) + +;;; SYSTEM CONFIG COMPONENT + +(defvar *config* nil) + +(defclass/std config () + ((datastore-directory :ir + :std #P"/srv/parasite/store/") + (port :ir + :std 4919) + (media-directory :ir + :std #P"/srv/parasite/media/"))) + +;;; RESOURCE MODEL + +(defclass/bknr keyed () + ((key + :r :std (nuid) + :index-type string-unique-index + :index-reader object-with-key))) + +(defclass/bknr content (keyed) + ((title :with :std "") + (user :with + :ri + :std (error "A USER is required to have created the content.") + :index-type hash-index + :index-reader content-by-user))) + +(defmethod initialize-instance :after ((content content) &key) + (when (zerop (length (content-title content))) + (setf (content-title content) (format nil "~a-~a" + (class-of content) + (store-object-id content))))) + +(defclass/bknr playlist (content) + ((tracks editors :with :std (list)))) + +(defclass/bknr track (content) + ((source media artist album :with) + (playlists :with :std (list) :doc "Playlists in which this track appears.") + (status :a :with + :std :uninitialized + :doc ":uninitialized, :acquiring, :available, :error-aquiring"))) + +(defclass/bknr user (keyed) + ((name :with :std "") + (pw pwhash :with ) + (playlists :with :std (list) :doc "Playlists made by this user"))) + +(defclass/std media (bknr.datastore:blob) + ((track :with)) + (:metaclass persistent-class)) + +;;; RESOURCE ACCESS PROTOCOL -- cgit v1.2.3