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) :depends-on (:closure-template :iolib.os :local-time :alexandria)
:serial t :serial t
:components ((:file "packages") :components ((:file "packages")
(:file "config")
(:file "git")
(:file "coleslaw") (:file "coleslaw")
(:file "themes") (:file "themes")
(:file "posts") (:file "posts")
@ -28,3 +30,7 @@
(defmethod operation-done-p ((op test-op) (defmethod operation-done-p ((op test-op)
(c (eql (find-system :coleslaw)))) (c (eql (find-system :coleslaw))))
(values nil)) (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) (in-package :coleslaw)
(defparameter *storage* nil (defclass blog ()
"A db-spec for postmodern or a hash-table cache. It is expected that ((author :initarg :author :initform "" :accessor author)
*storage* has methods for each Generic Function in coleslaw implemented.") (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) (defparameter *config* nil
(:documentation "Retrieve the credentials keyed by NAME from *storage*.")) "A variable to store the blog configuration and plugin settings.")
(defgeneric set-credentials (name credentials) (defun app-path (path)
(:documentation "Store the given CREDENTIALS in *storage* under NAME.")) "Take a relative PATH and return the corresponding pathname beneath coleslaw."
(merge-pathnames path coleslaw-conf:*basedir*))
(defun load-config () (defun load-config ()
nil) nil)
@ -17,14 +25,24 @@
nil) nil)
(defun compile-blog () (defun compile-blog ()
(with-current-directory *temporary-directory* (let ((staging #p"/tmp/coleslaw/"))
nil)) ; 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 () (defun main ()
(load-config) (load-config)
(unwind-protect (unwind-protect
(loop do (if (blog-update-p) (loop do (if (blog-update-p)
(compile-blog) (compile-blog)
(sleep 600))) (sleep (interval *config*))))
(exit-handler))) (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) (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 () (defun last-commit ()
"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 "/home/redline/projects/coleslaw/" (with-current-directory (repo *config*)
(iolib.os:run-program "git" '("log" "-n 1"))) (iolib.os: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)))

View file

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

View file

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