Add staging config option. Tweak defaults.

This commit is contained in:
Brit Butler 2012-08-21 19:05:57 -04:00
parent 1c0a037bac
commit 43501458c1
2 changed files with 22 additions and 20 deletions

View file

@ -23,33 +23,34 @@ on files that match the given extension."
(defun render-page (path html) (defun render-page (path html)
"Populate the base template with the provided HTML and write it out to PATH." "Populate the base template with the provided HTML and write it out to PATH."
(ensure-directories-exist path) (let ((filepath (merge-pathnames path (staging *config*))))
(with-open-file (out path (ensure-directories-exist filepath)
:direction :output (with-open-file (out path
:if-does-not-exist :create) :direction :output
(let ((content (funcall (theme-fn "BASE") :if-does-not-exist :create)
(list :title (title *config*) (let ((content (funcall (theme-fn "BASE")
:siteroot (domain *config*) (list :title (title *config*)
:navigation (sitenav *config*) :siteroot (domain *config*)
:content html :navigation (sitenav *config*)
:head-inject (apply #'concatenate 'string :content html
(gethash :head *injections*)) :head-inject (apply #'concatenate 'string
:body-inject (apply #'concatenate 'string (gethash :head *injections*))
(gethash :body *injections*)) :body-inject (apply #'concatenate 'string
:license (license *config*) (gethash :body *injections*))
:credits (author *config*))))) :license (license *config*)
(write-line content out)))) :credits (author *config*)))))
(write-line content out)))))
(defun compile-blog () (defun compile-blog ()
"Compile the blog to a staging directory in /tmp." "Compile the blog to a staging directory in /tmp."
(let ((staging #p"/tmp/coleslaw/")) (let ((staging (staging *config*)))
; TODO: More incremental compilation? Don't regen whole blog unnecessarily. ; TODO: More incremental compilation? Don't regen whole blog unnecessarily.
(when (probe-file staging) (when (probe-file staging)
(delete-directory-and-files staging)) (delete-directory-and-files staging))
(ensure-directories-exist staging) (ensure-directories-exist staging)
(with-current-directory staging (with-current-directory staging
(let ((css-dir (app-path "themes/~a/css/" (theme *config*))) (let ((css-dir (app-path "themes/~a/css" (theme *config*)))
(static-dir (merge-pathnames "static/" (repo *config*)))) (static-dir (merge-pathnames "static" (repo *config*))))
(dolist (dir (list css-dir static-dir)) (dolist (dir (list css-dir static-dir))
(when (probe-file dir) (when (probe-file dir)
(run-program "cp" `("-R" ,(namestring dir) "."))))) (run-program "cp" `("-R" ,(namestring dir) ".")))))

View file

@ -4,10 +4,11 @@
((author :initarg :author :initform "" :accessor author) ((author :initarg :author :initform "" :accessor author)
(domain :initarg :domain :initform "" :accessor domain) (domain :initarg :domain :initform "" :accessor domain)
(interval :initarg :interval :initform 600 :accessor interval) (interval :initarg :interval :initform 600 :accessor interval)
(license :initarg :license :initform "" :accessor license) (license :initarg :license :initform "CC-BY-SA" :accessor license)
(plugins :initarg :plugins :initform '() :accessor plugins) (plugins :initarg :plugins :initform '() :accessor plugins)
(repo :initarg :repo :initform #p"/" :accessor repo) (repo :initarg :repo :initform #p"/" :accessor repo)
(sitenav :initarg :sitenav :initform "" :accessor sitenav) (sitenav :initarg :sitenav :initform "" :accessor sitenav)
(staging :initarg :staging :initform #p"/tmp/coleslaw/" :accessor staging)
(title :initarg :title :initform "" :accessor title) (title :initarg :title :initform "" :accessor title)
(theme :initarg :theme :initform "hyde" :accessor theme))) (theme :initarg :theme :initform "hyde" :accessor theme)))