Factor purge-all calls in discover to a before method.

This commit is contained in:
Brit Butler 2014-04-15 20:43:56 -04:00
parent 862d7ad066
commit c17bcdd385
2 changed files with 3 additions and 4 deletions

View file

@ -34,11 +34,13 @@
(:method (doc-type)
(let* ((class-name (class-name doc-type))
(file-type (string-downcase (symbol-name class-name))))
(purge-all class-name)
(do-files (file (repo *config*) file-type)
(let ((obj (construct class-name (read-content file))))
(add-document obj))))))
(defmethod discover :before (doc-type)
(purge-all (class-name doc-type)))
;; Instance Methods
(defgeneric page-url (document)

View file

@ -21,7 +21,6 @@
(format nil "tag/~a" (index-slug object)))
(defmethod discover ((doc-type (eql (find-class 'tag-index))))
(purge-all (class-name doc-type))
(let ((content (by-date (find-all 'post))))
(dolist (tag (all-tags))
(add-document (index-by-tag tag content)))))
@ -44,7 +43,6 @@
(format nil "date/~a" (index-slug object)))
(defmethod discover ((doc-type (eql (find-class 'month-index))))
(purge-all (class-name doc-type))
(let ((content (by-date (find-all 'post))))
(dolist (month (all-months))
(add-document (index-by-month month content)))))
@ -67,7 +65,6 @@
(format nil "~d" (index-slug object)))
(defmethod discover ((doc-type (eql (find-class 'numeric-index))))
(purge-all (class-name doc-type))
(let ((content (by-date (find-all 'post))))
(dotimes (i (ceiling (length content) 10))
(add-document (index-by-n i content)))))