From fc017256177c009ce0a70378d7ec05a72934e5bc Mon Sep 17 00:00:00 2001 From: shoshin Date: Mon, 17 Apr 2023 08:52:35 -0500 Subject: Add: time as universal, css, and initial page/endpoint --- arclade.lisp | 21 +++++++++++++++++---- model.lisp | 18 +++++++++++++++--- steam.lisp | 2 +- style.css | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ utilities.lisp | 21 +++++++++++++++++++-- 5 files changed, 100 insertions(+), 10 deletions(-) create mode 100644 style.css diff --git a/arclade.lisp b/arclade.lisp index eb34688..67f4183 100644 --- a/arclade.lisp +++ b/arclade.lisp @@ -46,7 +46,20 @@ (defun start () (setf *config* (config-from-file #P"config.lisp")) (init-db *config*) - ;; (setf *server* (lzb:create-server)) - ;; (lzb:install-app *server* (lzb:app 'arclade)) - ;; (lzb:start-server *server*) - ) + (setf *server* (lzb:create-server)) + (lzb:install-app *server* (lzb:app 'arclade)) + (lzb:start-server *server*)) + +(defendpoint* :get "/" () () + (with-page (:title "Records of Raditude") + (:div + :class "container" + (dolist (game (all-games)) + (let ((feats (feats-fulfilled game))) + (unless (null feats) + (:div + :class "game" + (:h2 (name game)) + (:div :class "feats" + (dolist (feat feats) + (:div :class "feat" (render feat))))))))))) diff --git a/model.lisp b/model.lisp index 7c863aa..4bf59c2 100644 --- a/model.lisp +++ b/model.lisp @@ -51,7 +51,7 @@ :initarg :fulfillment :initform nil :accessor fulfillment - :documentation "Ideally a date and time when the feat was fulfilled. + :documentation "Ideally a universal time when the feat was fulfilled. If nil, implies the feat is yet to be fulfilled.") (description :initarg :description @@ -77,7 +77,19 @@ Example: (:metaclass db:persistent-class) (:documentation "Feat with Steam specific slots.")) +(defmethod print-object ((object steam-achievement) stream) + (print-unreadable-object (object stream :type t :identity t) + (princ (name object) stream))) + +(defgeneric render (obj) (:documentation "make html for thing")) + +(defmethod render ((obj steam-achievement)) + (with-slots (name description fulfillment icon icongray) obj + (with-html + (:img :src icon) + (:b name) description (:i (format-time fulfillment))))) + ;;; "queries" -(defun feats-fulfilled () - (remove-if-not #'fulfillment (db:store-objects-with-class 'feat))) +(defun feats-fulfilled (game) + (remove-if-not #'fulfillment (feats-for-game game))) diff --git a/steam.lisp b/steam.lisp index f8fa64c..6d47153 100644 --- a/steam.lisp +++ b/steam.lisp @@ -112,7 +112,7 @@ game (icongray rec) icongray (apiname rec) apiname) (unless (zerop achieved) - (setf (fulfillment rec) (epoch-time time))) + (setf (fulfillment rec) (+ time *epoch*))) rec))))) (defun load-steam-games () diff --git a/style.css b/style.css new file mode 100644 index 0000000..5a3b781 --- /dev/null +++ b/style.css @@ -0,0 +1,48 @@ +body { + background-color: black; + + animation-name: textColorPalette; + animation-duration: .4s; + animation-iteration-count: infinite; +} + +.container { + width: 100%; + display: flex; + flex-direction: column; + align-items: center; + padding: .5rem; +} + +.game { + width: 80%; + height: 100%; +} + +.feats { +} + +.feat { + text-align: left; + display: flex; + justify-content: left; + align-items: center; +} + +@keyframes textColorPalette { + 0% { + color: #bd00ff; + } + 25% { + color: #fcee0c; + } + 50% { + color: #00ff9f; + } + 75% { + color: #d600ff; + } + 100% { + color: #00b8ff; + } +} diff --git a/utilities.lisp b/utilities.lisp index d58eb47..c3f49c1 100644 --- a/utilities.lisp +++ b/utilities.lisp @@ -9,5 +9,22 @@ (defvar *epoch* (encode-universal-time 0 0 0 1 1 1970) "Jan 1 1970 Unix Epoch time in CL universal time.") -(defun epoch-time (time) - (multiple-value-list (decode-universal-time (+ *epoch* time)))) +(defun format-time (time) + (multiple-value-bind (_ min hour day month year) + (decode-universal-time time) + (declare (ignore _)) + (format nil "~2,'0d-~2,'0d-~a ~2,'0d:~2,'0d" + month day year hour min))) + +(defmacro with-page ((&key title) &body body) + "A helper macro for defining some standard page boilerplate." + (let ((title-var (gensym))) + `(let ((,title-var ,title)) + (with-html-string + (:doctype) + (:html + (:head + (:script :src "http://localhost:8080/skewer") + (:title ,title-var)) + (:body + ,@body)))))) -- cgit v1.2.3