Sketch config and compilation, minor tweaks.

This commit is contained in:
Brit Butler 2012-08-18 23:00:33 -04:00
parent 6a71773c0c
commit d66ed584a6
7 changed files with 56 additions and 23 deletions

View file

@ -8,6 +8,8 @@
:depends-on (:closure-template :iolib.os :local-time :alexandria)
:serial t
:components ((:file "packages")
(:file "config")
(:file "git")
(:file "coleslaw")
(:file "themes")
(:file "posts")
@ -28,3 +30,7 @@
(defmethod operation-done-p ((op test-op)
(c (eql (find-system :coleslaw))))
(values nil))
(defpackage #:coleslaw-conf (:export #:*basedir*))
(defparameter coleslaw-conf:*basedir*
(make-pathname :name nil :type nil :defaults *load-truename*))

9
example.coleslawrc Normal file
View file

@ -0,0 +1,9 @@
(:author "Brit Butler"
:domain "http://redlinernotes.com"
:interval 600
:license "CC-BY-SA"
:plugins nil
:repo "/home/redline/projects/coleslaw/ignore/input/"
:sitenav ""
:title "Improved Means for Achieving Deteriorated Ends"
:theme "hyde")

View file

@ -1,14 +1,22 @@
(in-package :coleslaw)
(defparameter *storage* nil
"A db-spec for postmodern or a hash-table cache. It is expected that
*storage* has methods for each Generic Function in coleslaw implemented.")
(defclass blog ()
((author :initarg :author :initform "" :accessor author)
(domain :initarg :domain :initform "" :accessor domain)
(interval :initarg :interval :initform 600 :accessor interval)
(license :initarg :license :initform "" :accessor license)
(plugins :initarg :plugins :initform '() :accessor plugins)
(repo :initarg :repo :initform #p"/" :accessor repo)
(sitenav :initarg :sitenav :initform "" :accessor sitenav)
(title :initarg :title :initform "" :accessor title)
(theme :initarg :theme :initform "hyde" :accessor theme)))
(defgeneric get-credentials (name)
(:documentation "Retrieve the credentials keyed by NAME from *storage*."))
(defparameter *config* nil
"A variable to store the blog configuration and plugin settings.")
(defgeneric set-credentials (name credentials)
(:documentation "Store the given CREDENTIALS in *storage* under NAME."))
(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)
@ -17,14 +25,24 @@
nil)
(defun compile-blog ()
(with-current-directory *temporary-directory*
nil))
(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)
(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 "."))))
(render-posts)
(render-indices))
(deploy staging)))
;; TODO: Make update interval a config option.
(defun main ()
(load-config)
(unwind-protect
(loop do (if (blog-update-p)
(compile-blog)
(sleep 600)))
(sleep (interval *config*))))
(exit-handler)))

9
src/config.lisp Normal file
View file

@ -0,0 +1,9 @@
(in-package :coleslaw)
(defparameter *config* nil
"A variable to store the blog configuration and plugin settings.")
(defun load-config (&optional (dir (user-homedir-pathname)))
"Load the coleslaw configuration from DIR/.coleslawrc. DIR is ~ by default."
(with-open-file (in (merge-pathnames ".coleslawrc" dir))
(setf *config* (apply #'make-instance 'blog (read in)))))

View file

@ -1,13 +1,9 @@
(in-package :coleslaw)
;; TODO:
; Replace hardcoded paths (repo, .deploy) with *config*?
; blog-update-p would be thing to make a generic in a plugin.
(defun last-commit ()
"Retrieve the SHA1 hash of the most recent blog commit."
(multiple-value-bind (pid stdout stderr)
(with-current-directory "/home/redline/projects/coleslaw/"
(with-current-directory (repo *config*)
(iolib.os:run-program "git" '("log" "-n 1")))
(cl-ppcre:scan-to-strings "[0-9a-f]{40}" stdout)))

View file

@ -2,12 +2,7 @@
(:use :cl :closure-template)
(:import-from :iolib.os #:with-current-directory
#:*temporary-directory*)
(:export ;; coleslaw-core
#:*storage*
#:get-credentials
#:set-credentials
;; themes
(:export ;; themes
#:*current-theme*
#:*theme-dir*
#:add-injection

View file

@ -8,7 +8,7 @@ are in the plugins folder in coleslaw's source directory."
(merge-pathnames
(concatenate 'string "plugins/"
(string-downcase (symbol-name sym)))
(asdf:system-source-directory 'coleslaw)))
coleslaw-conf:*basedir*))
plugins)))
(map nil (lambda (file)
(compile-file file)