Browse Source

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

Brit Butler 11 years ago
parent
commit
c17bcdd385
2 changed files with 3 additions and 4 deletions
  1. 3 1
      src/documents.lisp
  2. 0 3
      src/indexes.lisp

+ 3 - 1
src/documents.lisp

34
   (:method (doc-type)
34
   (:method (doc-type)
35
     (let* ((class-name (class-name doc-type))
35
     (let* ((class-name (class-name doc-type))
36
            (file-type (string-downcase (symbol-name class-name))))
36
            (file-type (string-downcase (symbol-name class-name))))
37
-      (purge-all class-name)
38
       (do-files (file (repo *config*) file-type)
37
       (do-files (file (repo *config*) file-type)
39
         (let ((obj (construct class-name (read-content file))))
38
         (let ((obj (construct class-name (read-content file))))
40
           (add-document obj))))))
39
           (add-document obj))))))
41
 
40
 
41
+(defmethod discover :before (doc-type)
42
+  (purge-all (class-name doc-type)))
43
+
42
 ;; Instance Methods
44
 ;; Instance Methods
43
 
45
 
44
 (defgeneric page-url (document)
46
 (defgeneric page-url (document)

+ 0 - 3
src/indexes.lisp

21
   (format nil "tag/~a" (index-slug object)))
21
   (format nil "tag/~a" (index-slug object)))
22
 
22
 
23
 (defmethod discover ((doc-type (eql (find-class 'tag-index))))
23
 (defmethod discover ((doc-type (eql (find-class 'tag-index))))
24
-  (purge-all (class-name doc-type))
25
   (let ((content (by-date (find-all 'post))))
24
   (let ((content (by-date (find-all 'post))))
26
     (dolist (tag (all-tags))
25
     (dolist (tag (all-tags))
27
       (add-document (index-by-tag tag content)))))
26
       (add-document (index-by-tag tag content)))))
44
   (format nil "date/~a" (index-slug object)))
43
   (format nil "date/~a" (index-slug object)))
45
 
44
 
46
 (defmethod discover ((doc-type (eql (find-class 'month-index))))
45
 (defmethod discover ((doc-type (eql (find-class 'month-index))))
47
-  (purge-all (class-name doc-type))
48
   (let ((content (by-date (find-all 'post))))
46
   (let ((content (by-date (find-all 'post))))
49
     (dolist (month (all-months))
47
     (dolist (month (all-months))
50
       (add-document (index-by-month month content)))))
48
       (add-document (index-by-month month content)))))
67
   (format nil "~d" (index-slug object)))
65
   (format nil "~d" (index-slug object)))
68
 
66
 
69
 (defmethod discover ((doc-type (eql (find-class 'numeric-index))))
67
 (defmethod discover ((doc-type (eql (find-class 'numeric-index))))
70
-  (purge-all (class-name doc-type))
71
   (let ((content (by-date (find-all 'post))))
68
   (let ((content (by-date (find-all 'post))))
72
     (dotimes (i (ceiling (length content) 10))
69
     (dotimes (i (ceiling (length content) 10))
73
       (add-document (index-by-n i content)))))
70
       (add-document (index-by-n i content)))))