Przeglądaj źródła

Extract setfs into UPDATE-CONTENT-METADATA.

Brit Butler 11 lat temu
rodzic
commit
2397b70abb
2 zmienionych plików z 7 dodań i 2 usunięć
  1. 1 0
      src/coleslaw.lisp
  2. 6 2
      src/indexes.lisp

+ 1 - 0
src/coleslaw.lisp

@@ -19,6 +19,7 @@ the last push."
19 19
   "Load all content stored in the blog's repo."
20 20
   (do-subclasses (ctype content)
21 21
     (discover ctype))
22
+  (update-content-metadata)
22 23
   (do-subclasses (itype index)
23 24
     (discover itype)))
24 25
 

+ 6 - 2
src/indexes.lisp

@@ -23,7 +23,6 @@
23 23
 (defclass tag-index (index) ())
24 24
 
25 25
 (defmethod discover ((doc-type (eql (find-class 'tag-index))))
26
-  (setf *all-tags* (all-tags))
27 26
   (let ((content (by-date (find-all 'post))))
28 27
     (dolist (tag (all-tags))
29 28
       (add-document (index-by-tag tag content)))))
@@ -43,7 +42,6 @@
43 42
 (defclass month-index (index) ())
44 43
 
45 44
 (defmethod discover ((doc-type (eql (find-class 'month-index))))
46
-  (setf *all-months* (all-months))
47 45
   (let ((content (by-date (find-all 'post))))
48 46
     (dolist (month *all-months*)
49 47
       (add-document (index-by-month month content)))))
@@ -85,6 +83,12 @@
85 83
 
86 84
 ;;; Helper Functions
87 85
 
86
+(defun update-content-metadata ()
87
+  "Set *ALL-TAGS* and *ALL-MONTHS* to the union of all tags and months
88
+of content loaded in the DB."
89
+  (setf *all-tags* (all-tags))
90
+  (setf *all-months* (all-months)))
91
+
88 92
 (defun all-months ()
89 93
   "Retrieve a list of all months with published content."
90 94
   (let ((months (mapcar (lambda (x) (subseq (content-date x) 0 7))