Implement DEPLOY, package updates, minor tweaks.
This commit is contained in:
parent
c18562d202
commit
a698389c42
5 changed files with 32 additions and 38 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -2,3 +2,5 @@
|
||||||
*.fasl
|
*.fasl
|
||||||
ignore/
|
ignore/
|
||||||
generated/
|
generated/
|
||||||
|
.curr
|
||||||
|
.prev
|
||||||
|
|
|
@ -11,38 +11,38 @@
|
||||||
(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)))
|
||||||
|
|
||||||
(defparameter *config* nil
|
|
||||||
"A variable to store the blog configuration and plugin settings.")
|
|
||||||
|
|
||||||
(defun app-path (path)
|
(defun app-path (path)
|
||||||
"Take a relative PATH and return the corresponding pathname beneath coleslaw."
|
"Take a relative PATH and return the corresponding pathname beneath coleslaw."
|
||||||
(merge-pathnames path coleslaw-conf:*basedir*))
|
(merge-pathnames path coleslaw-conf:*basedir*))
|
||||||
|
|
||||||
(defun load-config ()
|
|
||||||
nil)
|
|
||||||
|
|
||||||
(defun exit-handler ()
|
|
||||||
nil)
|
|
||||||
|
|
||||||
(defun compile-blog ()
|
(defun compile-blog ()
|
||||||
(let ((staging #p"/tmp/coleslaw/"))
|
(let ((staging #p"/tmp/coleslaw/"))
|
||||||
; TODO: More incremental compilation? Don't regen whole blog unnecessarily.
|
; TODO: More incremental compilation? Don't regen whole blog unnecessarily.
|
||||||
(if (probe-file staging)
|
(if (probe-file staging)
|
||||||
(iolib.os:delete-files staging :recursive t)
|
(delete-files staging :recursive t)
|
||||||
(ensure-directories-exist staging))
|
(ensure-directories-exist staging))
|
||||||
(with-current-directory staging
|
(with-current-directory staging
|
||||||
(let ((css-dir (app-path (format nil "themes/~a/css/" (theme *config*))))
|
(let ((css-dir (app-path (format nil "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))
|
||||||
(iolib.os:run-program "cp" `("-R" ,dir "."))))
|
(run-program "cp" `("-R" ,dir "."))))
|
||||||
(render-posts)
|
(render-posts)
|
||||||
(render-indices))
|
(render-indices))
|
||||||
(deploy staging)))
|
(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 ()
|
(defun main ()
|
||||||
(load-config)
|
(load-config)
|
||||||
(unwind-protect
|
(loop do (if (blog-update-p)
|
||||||
(loop do (if (blog-update-p)
|
(compile-blog)
|
||||||
(compile-blog)
|
(sleep (interval *config*)))))
|
||||||
(sleep (interval *config*))))
|
|
||||||
(exit-handler)))
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"Retrieve the SHA1 hash of the most recent blog commit."
|
"Retrieve the SHA1 hash of the most recent blog commit."
|
||||||
(multiple-value-bind (pid stdout stderr)
|
(multiple-value-bind (pid stdout stderr)
|
||||||
(with-current-directory (repo *config*)
|
(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)))
|
(cl-ppcre:scan-to-strings "[0-9a-f]{40}" stdout)))
|
||||||
|
|
||||||
(defun last-published ()
|
(defun last-published ()
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
(defpackage :coleslaw
|
(defpackage :coleslaw
|
||||||
(:use :cl :closure-template)
|
(:use :cl :closure-template)
|
||||||
(:import-from :iolib.os #:with-current-directory
|
(:import-from :iolib.os #:with-current-directory
|
||||||
#:*temporary-directory*)
|
#:delete-files
|
||||||
|
#:read-symlink
|
||||||
|
#:run-program)
|
||||||
(:export ;; themes
|
(:export ;; themes
|
||||||
#:*current-theme*
|
|
||||||
#:*theme-dir*
|
|
||||||
#:add-injection
|
#:add-injection
|
||||||
#:remove-injection
|
#:remove-injection
|
||||||
|
|
||||||
|
;; plugins
|
||||||
|
#:load-plugins
|
||||||
|
|
||||||
;; posts
|
;; posts
|
||||||
#:make-post
|
#:make-post
|
||||||
#:add-post
|
#:add-post
|
||||||
|
@ -32,7 +35,4 @@
|
||||||
#:index-url
|
#:index-url
|
||||||
|
|
||||||
#:index-id
|
#:index-id
|
||||||
#:index-posts
|
#:index-posts))
|
||||||
|
|
||||||
;; plugins
|
|
||||||
#:load-plugins))
|
|
||||||
|
|
|
@ -1,27 +1,19 @@
|
||||||
(in-package :coleslaw)
|
(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)
|
(defgeneric add-injection (str location)
|
||||||
(:documentation "Add STR to the list of elements injected in LOCATION."))
|
(:documentation "Add STR to the list of elements injected in LOCATION."))
|
||||||
|
|
||||||
(defgeneric remove-injection (str location)
|
(defgeneric remove-injection (str location)
|
||||||
(:documentation "Remove STR from the list of elements injected in 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))))
|
(find-package (string-upcase (concatenate 'string "coleslaw.theme." name))))
|
||||||
|
|
||||||
(defun compile-theme (&key (theme-dir *theme-dir*))
|
(defun compile-theme (&key (theme-dir (app-path (theme *config*))))
|
||||||
(loop for file in (cl-fad:list-directory theme-dir) do
|
(loop for file in (iolib.os:list-directory theme-dir)
|
||||||
(let ((extension (pathname-type file)))
|
do (let ((extension (pathname-type file)))
|
||||||
(when (and extension (string= extension "tmpl"))
|
(when (and extension (string= extension "tmpl"))
|
||||||
(compile-template :common-lisp-backend file)))))
|
(compile-template :common-lisp-backend file)))))
|
||||||
|
|
||||||
;; DOCUMENTATION
|
;; DOCUMENTATION
|
||||||
;; A theme directory should be named after the theme and contain *.tmpl files
|
;; A theme directory should be named after the theme and contain *.tmpl files
|
||||||
|
|
Loading…
Add table
Reference in a new issue