diff --git a/coleslaw.asd b/coleslaw.asd index 69bed82..7e0ac0c 100644 --- a/coleslaw.asd +++ b/coleslaw.asd @@ -5,7 +5,7 @@ :license "BSD" :author "Brit Butler " :pathname "src/" - :depends-on (:closure-template :cl-fad :local-time :alexandria) + :depends-on (:closure-template :iolib.os :local-time :alexandria) :serial t :components ((:file "packages") (:file "coleslaw") diff --git a/src/coleslaw.lisp b/src/coleslaw.lisp index f4539d1..19d5555 100644 --- a/src/coleslaw.lisp +++ b/src/coleslaw.lisp @@ -1,11 +1,5 @@ (in-package :coleslaw) -(defgeneric start-coleslaw (&rest options) - (:documentation "Start the coleslaw server with any specified OPTIONS.")) - -(defgeneric stop-coleslaw (&rest options) - (:documentation "Stop the coleslaw server with any specified OPTIONS.")) - (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.") @@ -15,3 +9,20 @@ (defgeneric set-credentials (name credentials) (:documentation "Store the given CREDENTIALS in *storage* under NAME.")) + +(defun load-config () + nil) + +(defun exit-handler () + nil) + +(defun compile-blog () + nil) + +(defun main () + (load-config) + (unwind-protect + (loop do (if (blog-update-p) + (compile-blog) + (sleep 600))) + (exit-handler))) diff --git a/src/git.lisp b/src/git.lisp new file mode 100644 index 0000000..def977c --- /dev/null +++ b/src/git.lisp @@ -0,0 +1,29 @@ +(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) + (iolib.os:with-current-directory "/home/redline/projects/coleslaw/" + (iolib.os:run-program "git" '("log" "-n 1"))) + (cl-ppcre:scan-to-strings "[0-9a-f]{40}" stdout))) + +(defun last-published () + "Retrieve the SHA1 hash of the most recent published blog." + (with-open-file (in "/home/redline/.coleslaw" + :if-does-not-exist :create) + (read-line in nil))) + +(defun (setf last-published) (new-val) + (with-open-file (out "/home/redline/.coleslaw" + :direction :output + :if-exists :supersede + :if-does-not-exist :create) + (write-line new-val out))) + +(defun blog-update-p () + "Returns a non-nil value if the blog needs to be regenerated." + (mismatch (last-commit) (last-published))) diff --git a/src/packages.lisp b/src/packages.lisp index 04fe71f..78efffb 100644 --- a/src/packages.lisp +++ b/src/packages.lisp @@ -2,8 +2,6 @@ (:use :cl :closure-template) (:export ;; coleslaw-core #:*storage* - #:start-coleslaw - #:stop-coleslaw #:get-credentials #:set-credentials @@ -28,24 +26,6 @@ #:post-content #:post-aliases - ;; comments - #:make-comment - #:add-comment - #:remove-comment - #:render-comments - #:find-comments - - #:author-name - #:author-url - #:author-ip - - #:comment-id - #:comment-post - #:comment-author - #:comment-timestamp - #:comment-content - #:comment-parent - ;; indices #:make-index #:add-to-index