From 6082cb46f5e4cb95d4f14eb5238225788b049fce Mon Sep 17 00:00:00 2001 From: Brit Butler Date: Tue, 9 Apr 2013 16:23:10 -0400 Subject: [PATCH] Add and export PREVIEW. --- NEWS.md | 1 + src/coleslaw.lisp | 9 +++++++++ src/packages.lisp | 1 + 3 files changed, 11 insertions(+) diff --git a/NEWS.md b/NEWS.md index 38fce4a..701eb4b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,6 @@ ## Changes for 0.9.1 (2013-04-xx): +* Added a PREVIEW function for REPL use. * Make ATOM and RSS templates a separate "generic" theme. (thanks @woudshoo!) ## Changes for 0.9 (2013-02-20): diff --git a/src/coleslaw.lisp b/src/coleslaw.lisp index df0c2ad..9d62c02 100644 --- a/src/coleslaw.lisp +++ b/src/coleslaw.lisp @@ -81,3 +81,12 @@ compile and deploy the blog." (compile-theme (theme *config*)) (compile-blog (staging *config*)) (deploy (staging *config*)))) + +(defun preview (path &optional (content-type 'post)) + "Render the content at PATH and save it to ~/tmp.html, loading the +user's config and theme if necessary." + (unless *config* + (load-config nil) + (compile-theme (theme *config*))) + (let ((object (construct content-type (read-content path)))) + (write-page "~/tmp.html" (render-page object)))) diff --git a/src/packages.lisp b/src/packages.lisp index 3b3b657..e95e3a2 100644 --- a/src/packages.lisp +++ b/src/packages.lisp @@ -7,6 +7,7 @@ #:compose) (:import-from :closure-template #:compile-template) (:export #:main + #:preview #:*config* #:blog #:content