Browse Source

Allow arbitrary layout of blog repos.

Brit Butler 11 years ago
parent
commit
40c00b9708
3 changed files with 13 additions and 16 deletions
  1. 5 0
      NEWS.md
  2. 0 8
      docs/hacking.md
  3. 8 8
      src/util.lisp

+ 5 - 0
NEWS.md

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
 ## Changes for 0.9.3 (2013-04-16):
6
 ## Changes for 0.9.3 (2013-04-16):
2
 
7
 
3
 * **INCOMPATIBLE CHANGE**: `page-path` and the `blog` config class are no longer exported.
8
 * **INCOMPATIBLE CHANGE**: `page-path` and the `blog` config class are no longer exported.

+ 0 - 8
docs/hacking.md

168
 
168
 
169
 ## Areas for Improvement
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
 ### Allow Tagless or Dateless Content
171
 ### Allow Tagless or Dateless Content
180
 
172
 
181
 Several users have expected to be able to not supply tags or a date
173
 Several users have expected to be able to not supply tags or a date

+ 8 - 8
src/util.lisp

16
          (loop for ,var in ,klasses do ,@body)))))
16
          (loop for ,var in ,klasses do ,@body)))))
17
 
17
 
18
 (defmacro do-files ((var path &optional extension) &body body)
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
     `(flet ((,extension-p (file)
22
     `(flet ((,extension-p (file)
23
               (string= (pathname-type file) ,extension)))
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
 (defmacro with-current-directory (path &body body)
30
 (defmacro with-current-directory (path &body body)
31
   "Change the current directory to PATH and execute BODY in
31
   "Change the current directory to PATH and execute BODY in