瀏覽代碼

Extract setfs into UPDATE-CONTENT-METADATA.

Brit Butler 11 年之前
父節點
當前提交
2397b70abb
共有 2 個文件被更改,包括 7 次插入2 次删除
  1. 1 0
      src/coleslaw.lisp
  2. 6 2
      src/indexes.lisp

+ 1 - 0
src/coleslaw.lisp

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

+ 6 - 2
src/indexes.lisp

23
 (defclass tag-index (index) ())
23
 (defclass tag-index (index) ())
24
 
24
 
25
 (defmethod discover ((doc-type (eql (find-class 'tag-index))))
25
 (defmethod discover ((doc-type (eql (find-class 'tag-index))))
26
-  (setf *all-tags* (all-tags))
27
   (let ((content (by-date (find-all 'post))))
26
   (let ((content (by-date (find-all 'post))))
28
     (dolist (tag (all-tags))
27
     (dolist (tag (all-tags))
29
       (add-document (index-by-tag tag content)))))
28
       (add-document (index-by-tag tag content)))))
43
 (defclass month-index (index) ())
42
 (defclass month-index (index) ())
44
 
43
 
45
 (defmethod discover ((doc-type (eql (find-class 'month-index))))
44
 (defmethod discover ((doc-type (eql (find-class 'month-index))))
46
-  (setf *all-months* (all-months))
47
   (let ((content (by-date (find-all 'post))))
45
   (let ((content (by-date (find-all 'post))))
48
     (dolist (month *all-months*)
46
     (dolist (month *all-months*)
49
       (add-document (index-by-month month content)))))
47
       (add-document (index-by-month month content)))))
85
 
83
 
86
 ;;; Helper Functions
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
 (defun all-months ()
92
 (defun all-months ()
89
   "Retrieve a list of all months with published content."
93
   "Retrieve a list of all months with published content."
90
   (let ((months (mapcar (lambda (x) (subseq (content-date x) 0 7))
94
   (let ((months (mapcar (lambda (x) (subseq (content-date x) 0 7))