Bladeren bron

Allow arbitrary layout of blog repos.

Brit Butler 11 jaren geleden
bovenliggende
commit
40c00b9708
3 gewijzigde bestanden met toevoegingen van 13 en 16 verwijderingen
  1. 5 0
      NEWS.md
  2. 0 8
      docs/hacking.md
  3. 8 8
      src/util.lisp

+ 5 - 0
NEWS.md

@@ -1,3 +1,8 @@
1
+## Changes for 0.9.4 (2013-05-05):
2
+
3
+* Coleslaw no longer expects a particular repo layout. Use whatever
4
+  directory hierarchy you like.
5
+
1 6
 ## Changes for 0.9.3 (2013-04-16):
2 7
 
3 8
 * **INCOMPATIBLE CHANGE**: `page-path` and the `blog` config class are no longer exported.

+ 0 - 8
docs/hacking.md

@@ -168,14 +168,6 @@ freshly built site.
168 168
 
169 169
 ## Areas for Improvement
170 170
 
171
-### Allow Arbitrary Repo Structure
172
-
173
-Currently, *coleslaw* expects all posts to be in the top-level of the
174
-blog repo. There is no technical reason that coleslaw should care.
175
-The only change that needs to be made is to the `do-files` macro
176
-used during content discovery. In particular, it should probably
177
-use `cl-fad:walk-directory` instead of `cl-fad:list-directory`.
178
-
179 171
 ### Allow Tagless or Dateless Content
180 172
 
181 173
 Several users have expected to be able to not supply tags or a date

+ 8 - 8
src/util.lisp

@@ -16,16 +16,16 @@ lexically bound to the current subclass."
16 16
          (loop for ,var in ,klasses do ,@body)))))
17 17
 
18 18
 (defmacro do-files ((var path &optional extension) &body body)
19
-  "For each file on PATH, run BODY. If EXTENSION is provided, only run BODY
20
-on files that match the given extension."
21
-  (alexandria:with-gensyms (extension-p files)
19
+  "For each file under PATH, run BODY. If EXTENSION is provided, only run
20
+BODY on files that match the given extension."
21
+  (alexandria:with-gensyms (extension-p)
22 22
     `(flet ((,extension-p (file)
23 23
               (string= (pathname-type file) ,extension)))
24
-       (let ((,files (cl-fad:list-directory ,path)))
25
-         (dolist (,var ,(if extension
26
-                            `(remove-if-not #',extension-p ,files)
27
-                            files))
28
-           ,@body)))))
24
+       (cl-fad:walk-directory ,path (lambda (,var) ,@body)
25
+                              :follow-symlinks nil
26
+                              :test (if ,extension
27
+                                        #',extension-p
28
+                                        (constantly t))))))
29 29
 
30 30
 (defmacro with-current-directory (path &body body)
31 31
   "Change the current directory to PATH and execute BODY in