diff --git a/plugins/incremental.lisp b/plugins/incremental.lisp index d60f121..8430be7 100644 --- a/plugins/incremental.lisp +++ b/plugins/incremental.lisp @@ -59,14 +59,11 @@ (:method :around (status path &key) (let ((extension (pathname-type path)) (ctypes (all-subclasses (find-class 'content)))) - ;; This feels way too clever. I wish I could think of a better option. - (flet ((class-name-p (x class) - (string-equal x (symbol-name (class-name class))))) - ;; If the updated file's extension doesn't match one of our content types, - ;; we don't need to mess with it at all. Otherwise, since the class is - ;; annoyingly tricky to determine, pass it along. - (when-let (ctype (find extension ctypes :test #'class-name-p)) - (call-next-method status path :ctype ctype)))))) + ;; If the updated file's extension doesn't match one of our content types, + ;; we don't need to mess with it at all. Otherwise, since the class is + ;; annoyingly tricky to determine, pass it along. + (when-let (ctype (find extension ctypes :test #'class-name-p)) + (call-next-method status path :ctype ctype))))) (defmethod process-change ((status (eql :deleted)) path &key) (let ((old (find-content-by-path path))) diff --git a/src/documents.lisp b/src/documents.lisp index b90d299..3995593 100644 --- a/src/documents.lisp +++ b/src/documents.lisp @@ -68,12 +68,15 @@ use it as the template passing any RENDER-ARGS." (url (namestring (page-url document)))) (write-file (rel-path (staging-dir *config*) url) html))) -(defun find-all (doc-type) +(defun find-all (doc-type &optional (matches-p (lambda (x) (typep x doc-type)))) "Return a list of all instances of a given DOC-TYPE." (loop for val being the hash-values in *site* - when (typep val doc-type) collect val)) + when (funcall matches-p val) collect val)) (defun purge-all (doc-type) "Remove all instances of DOC-TYPE from memory." - (dolist (obj (find-all doc-type)) - (remhash (page-url obj) *site*))) + (flet ((matches-class-name-p (x) + (class-name-p (symbol-name doc-type) + (class-of x)))) + (dolist (obj (find-all doc-type #'matches-class-name-p)) + (remhash (page-url obj) *site*)))) diff --git a/src/util.lisp b/src/util.lisp index e24e7a6..33509d6 100644 --- a/src/util.lisp +++ b/src/util.lisp @@ -122,3 +122,8 @@ in the git repo since REVISION." (cl-ppcre:split "\\s+" str))) (let ((cmd (format nil "git diff --name-status ~A HEAD" revision))) (mapcar #'split-on-whitespace (inferior-shell:run/lines cmd))))) + +(defun class-name-p (name class) + "True if the specified string is the name of the class provided" + ;; This feels way too clever. I wish I could think of a better option. + (string-equal name (symbol-name (class-name class))))