Ver código fonte

Add and export PREVIEW.

Brit Butler 12 anos atrás
pai
commit
6082cb46f5
3 arquivos alterados com 11 adições e 0 exclusões
  1. 1 0
      NEWS.md
  2. 9 0
      src/coleslaw.lisp
  3. 1 0
      src/packages.lisp

+ 1 - 0
NEWS.md

@@ -1,5 +1,6 @@
1 1
 ## Changes for 0.9.1 (2013-04-xx):
2 2
 
3
+* Added a PREVIEW function for REPL use.
3 4
 * Make ATOM and RSS templates a separate "generic" theme. (thanks @woudshoo!)
4 5
 
5 6
 ## Changes for 0.9 (2013-02-20):

+ 9 - 0
src/coleslaw.lisp

@@ -81,3 +81,12 @@ compile and deploy the blog."
81 81
     (compile-theme (theme *config*))
82 82
     (compile-blog (staging *config*))
83 83
     (deploy (staging *config*))))
84
+
85
+(defun preview (path &optional (content-type 'post))
86
+  "Render the content at PATH and save it to ~/tmp.html, loading the
87
+user's config and theme if necessary."
88
+  (unless *config*
89
+    (load-config nil)
90
+    (compile-theme (theme *config*)))
91
+  (let ((object (construct content-type (read-content path))))
92
+    (write-page "~/tmp.html" (render-page object))))

+ 1 - 0
src/packages.lisp

@@ -7,6 +7,7 @@
7 7
                             #:compose)
8 8
   (:import-from :closure-template #:compile-template)
9 9
   (:export #:main
10
+           #:preview
10 11
            #:*config*
11 12
            #:blog
12 13
            #:content