summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Okay <okay@toyful.space>2021-05-14 15:01:37 -0500
committerColin Okay <okay@toyful.space>2021-05-14 15:01:37 -0500
commitdca7e067e48f812e270c051f17f1b65cd6e32d2a (patch)
treee1ecd350622270685f7b6585a67006643ed2d976
parent41e88da82477201c9a25e1c3000066be399931c1 (diff)
dev server working
-rw-r--r--flexo.lisp32
-rw-r--r--package.lisp6
2 files changed, 30 insertions, 8 deletions
diff --git a/flexo.lisp b/flexo.lisp
index c05d68d..b9c820f 100644
--- a/flexo.lisp
+++ b/flexo.lisp
@@ -20,6 +20,12 @@
;;; HACKING ON A SITE
+(defgeneric content-equivlanet-p (a b)
+ (:documentation "T if artifacts A and B should be thought of as having equivalent content."))
+
+(defmethod content-equivlanet-p (a b) most-negative-long-float )
+
+
(defun make-auto-refresh-key ()
(symbol-name (gensym "auto-refresh-")))
@@ -78,10 +84,10 @@
(and (table-subset-p tab1 tab2 :test test)
(table-subset-p tab2 tab1 :test test)))
-(defun site-changed-p (backup)
+(defun site-changed-p (site backup)
"A site has changed since backed up if either the asset table or the
artifact tables have changed."
- (not (tables-equal-p backup *site*)))
+ (not (tables-equal-p site backup :test 'content-equivlanet-p)))
(defun run-recipe (recipe)
"Runs the RECIPE, a function of zero arguments, in a fresh context
@@ -96,13 +102,14 @@ artifact tables have changed."
added to the correct hash table. These hash tables are used under
the hood by the content and artifact retrieval utility functions -
e.g. FIND-CONTENT, ARTIFACTS-WITH-CLASS, and so on."
- (let ((*site* (make-hash-table))
- (*content* (make-hash-table)))
+ (let ((*site* (make-hash-table :test 'equal))
+ (*content* (make-hash-table :test 'equal)))
(funcall recipe)
*site*))
(defun hack-on
(recipe location &key (port 4242) (rebuild-freqeuncy 1) (auto-refresh t) log-to-repl)
+ (ensure-directories-exist location)
(setf *development-acceptor*
(hunchentoot:start (make-instance 'hunchentoot:easy-acceptor
:port port
@@ -160,12 +167,17 @@ artifact tables have changed."
((filepath
:reader filepath
:initarg :filepath
- :initform (error "FILE must have a FILEPATH slot value."))))
+ :initform (error "FILE must have a FILEPATH slot value."))
+ (mod-time
+ :accessor mod-time
+ :initarg :mod-time)))
(defmethod initialize-instance :after ((content file) &key)
(when *content*
(setf (gethash (filepath content) *content*)
- content)))
+ content
+ (mod-time content)
+ (file-write-date (filepath content)))))
;;; ARTIFACTS
@@ -196,6 +208,10 @@ artifact tables have changed."
generated by some kind of lisp template. e.g. spinenret, lass,
paranscript. "))
+(defmethod content-equivlanet-p ((a template-generated-text) (b template-generated-text))
+ (string-equal (generated-text a) (generated-text b)))
+
+
(defclass spinneret-page (template-generated-text) ()
(:documentation "An artifact generated from a spinneret template
representing an entire web page.."))
@@ -351,6 +367,9 @@ artifact tables have changed."
"Meant to be extended by all artifacts that are also files on
disk."))
+(defmethod content-equivlanet-p ((a file-artifact) (b file-artifact))
+ (equal (mod-time a) (mod-time b)))
+
;;; SITE BUILDING TOOLS
(defun add-file (path class &rest keywords)
@@ -373,7 +392,6 @@ artifact tables have changed."
(dolist (subdir (uiop:subdirectories directory-path))
(apply #'add-files-matching subdir regex class keywords)))
-
;;; PUBLISH PROTOCOL
(defgeneric publish (artifact location)
diff --git a/package.lisp b/package.lisp
index 0a2d1ef..8563cd7 100644
--- a/package.lisp
+++ b/package.lisp
@@ -16,7 +16,10 @@
#:content-keywords
#:content-with-filepath-like
#:content-with-tags
+ #:define-lass-sheet
#:define-lass-template
+ #:define-ps-script
+ #:define-spinneret-page
#:define-spinneret-template
#:file
#:file-artifact
@@ -33,4 +36,5 @@
#:spinneret-page
#:stop-hacking
#:template-generated-text
- #:url-path))
+ #:url-path
+))