Implement DEPLOY, package updates, minor tweaks.

This commit is contained in:
Brit Butler 2012-08-19 00:29:33 -04:00
parent c18562d202
commit a698389c42
5 changed files with 32 additions and 38 deletions

2
.gitignore vendored
View file

@ -2,3 +2,5 @@
*.fasl
ignore/
generated/
.curr
.prev

View file

@ -11,38 +11,38 @@
(title :initarg :title :initform "" :accessor title)
(theme :initarg :theme :initform "hyde" :accessor theme)))
(defparameter *config* nil
"A variable to store the blog configuration and plugin settings.")
(defun app-path (path)
"Take a relative PATH and return the corresponding pathname beneath coleslaw."
(merge-pathnames path coleslaw-conf:*basedir*))
(defun load-config ()
nil)
(defun exit-handler ()
nil)
(defun compile-blog ()
(let ((staging #p"/tmp/coleslaw/"))
; TODO: More incremental compilation? Don't regen whole blog unnecessarily.
(if (probe-file staging)
(iolib.os:delete-files staging :recursive t)
(delete-files staging :recursive t)
(ensure-directories-exist staging))
(with-current-directory staging
(let ((css-dir (app-path (format nil "themes/~a/css/" (theme *config*))))
(static-dir (merge-pathnames "static/" (repo *config*))))
(dolist (dir (list css-dir static-dir))
(iolib.os:run-program "cp" `("-R" ,dir "."))))
(run-program "cp" `("-R" ,dir "."))))
(render-posts)
(render-indices))
(deploy staging)))
(defun deploy (dir)
"Deploy DIR, updating the .prev and .curr symlinks."
(let ((new-build (app-path (format nil "generated/~a" (get-universal-time)))))
(run-program "mv" (list dir (app-path new-build)))
(when (probe-file (app-path ".prev"))
(delete-files (read-symlink (app-path ".prev")) :recursive t))
(when (probe-file (app-path ".curr"))
(run-program "ln" (list "-sfn" (read-symlink (app-path ".curr")) ".prev")))
(run-program "ln" (list "-sfn" new-build ".curr")))
(setf (last-published) (last-commit)))
(defun main ()
(load-config)
(unwind-protect
(loop do (if (blog-update-p)
(compile-blog)
(sleep (interval *config*))))
(exit-handler)))
(loop do (if (blog-update-p)
(compile-blog)
(sleep (interval *config*)))))

View file

@ -4,7 +4,7 @@
"Retrieve the SHA1 hash of the most recent blog commit."
(multiple-value-bind (pid stdout stderr)
(with-current-directory (repo *config*)
(iolib.os:run-program "git" '("log" "-n 1")))
(run-program "git" '("log" "-n 1")))
(cl-ppcre:scan-to-strings "[0-9a-f]{40}" stdout)))
(defun last-published ()

View file

@ -1,13 +1,16 @@
(defpackage :coleslaw
(:use :cl :closure-template)
(:import-from :iolib.os #:with-current-directory
#:*temporary-directory*)
#:delete-files
#:read-symlink
#:run-program)
(:export ;; themes
#:*current-theme*
#:*theme-dir*
#:add-injection
#:remove-injection
;; plugins
#:load-plugins
;; posts
#:make-post
#:add-post
@ -32,7 +35,4 @@
#:index-url
#:index-id
#:index-posts
;; plugins
#:load-plugins))
#:index-posts))

View file

@ -1,27 +1,19 @@
(in-package :coleslaw)
(defparameter *current-theme* "hyde"
"The name of a directory containing templates for HTML generation.")
(defparameter *theme-dir* (merge-pathnames
(concatenate 'string "themes/" *current-theme* "/")
(asdf:system-source-directory 'coleslaw))
"The directory containing the current theme and other site templates.")
(defgeneric add-injection (str location)
(:documentation "Add STR to the list of elements injected in LOCATION."))
(defgeneric remove-injection (str location)
(:documentation "Remove STR from the list of elements injected in LOCATION."))
(defun theme-package (&key (name *current-theme*))
(defun theme-package (&key (name (theme *config*)))
(find-package (string-upcase (concatenate 'string "coleslaw.theme." name))))
(defun compile-theme (&key (theme-dir *theme-dir*))
(loop for file in (cl-fad:list-directory theme-dir) do
(let ((extension (pathname-type file)))
(when (and extension (string= extension "tmpl"))
(compile-template :common-lisp-backend file)))))
(defun compile-theme (&key (theme-dir (app-path (theme *config*))))
(loop for file in (iolib.os:list-directory theme-dir)
do (let ((extension (pathname-type file)))
(when (and extension (string= extension "tmpl"))
(compile-template :common-lisp-backend file)))))
;; DOCUMENTATION
;; A theme directory should be named after the theme and contain *.tmpl files