Browse Source

Update all page-url calls to only use the slug.

Brit Butler 11 years ago
parent
commit
e5a40b67a7
2 changed files with 10 additions and 8 deletions
  1. 1 1
      docs/hacking.md
  2. 9 7
      src/indexes.lisp

+ 1 - 1
docs/hacking.md

@@ -74,7 +74,7 @@ implement them by eql-specializing on the class, e.g.
74 74
 
75 75
 - `page-url`: Generate a unique, relative path for the object on the site
76 76
   sans file extension. An :around method adds that later. The `slug` slot
77
-  on the object is generally used to hold a portion of the unique
77
+  on the object is conventionally used to hold a portion of the unique
78 78
   identifier. i.e. `(format nil "posts/~a" (content-slug object))`.
79 79
 - `render`: A method that calls the appropriate template with `theme-fn`,
80 80
   passing it any needed arguments and returning rendered HTML.

+ 9 - 7
src/indexes.lisp

@@ -91,12 +91,14 @@
91 91
   ((format :initform nil :initarg :format :accessor feed-format)))
92 92
 
93 93
 (defmethod page-url ((object feed))
94
-  (format nil "~(~a~).xml" (feed-format object)))
94
+  (format nil "~a.xml" (index-slug object)))
95 95
 
96 96
 (defmethod discover ((doc-type (eql (find-class 'feed))))
97
-  (let ((content (take-up-to 10 (by-date (find-all 'post)))))
97
+  (let ((content (by-date (find-all 'post))))
98 98
     (dolist (format '(rss atom))
99
-      (let ((feed (make-instance 'feed :content content :format format)))
99
+      (let ((feed (make-instance 'feed :format format
100
+                                 :content (take-up-to 10 content)
101
+                                 :slug (format nil "~(~a~)" format))))
100 102
         (add-document feed)))))
101 103
 
102 104
 (defmethod publish ((doc-type (eql (find-class 'feed))))
@@ -108,16 +110,16 @@
108 110
 (defclass tag-feed (feed) ())
109 111
 
110 112
 (defmethod page-url ((object tag-feed))
111
-  (format nil "tag/~a~(~a~).xml" (index-slug object) (feed-format object)))
113
+  (format nil "tag/~a.xml" (index-slug object)))
112 114
 
113 115
 (defmethod discover ((doc-type (eql (find-class 'tag-feed))))
114 116
   (let ((content (by-date (find-all 'post))))
115 117
     (dolist (tag (feeds *config*))
116 118
       (let ((tagged (remove-if-not (lambda (x) (tag-p tag x)) content)))
117 119
         (dolist (format '(rss atom))
118
-          (let ((feed (make-instance 'tag-feed :content (take-up-to 10 tagged)
119
-                                     :format format
120
-                                     :slug tag)))
120
+          (let ((feed (make-instance 'tag-feed :format format
121
+                                     :content (take-up-to 10 tagged)
122
+                                     :slug (format nil "~a-~(~a~)" tag format))))
121 123
             (add-document feed)))))))
122 124
 
123 125
 (defmethod publish ((doc-type (eql (find-class 'tag-feed))))