APP-PATH tweaks, COMPILE-THEME fix.
This commit is contained in:
parent
558a04e696
commit
65d4f349da
4 changed files with 27 additions and 53 deletions
|
@ -1,19 +1,9 @@
|
|||
(in-package :coleslaw)
|
||||
|
||||
(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)))
|
||||
|
||||
(defun app-path (path)
|
||||
"Take a relative PATH and return the corresponding pathname beneath coleslaw."
|
||||
(merge-pathnames path coleslaw-conf:*basedir*))
|
||||
(defun app-path (path &rest args)
|
||||
"Take a relative PATH and return the corresponding pathname beneath coleslaw.
|
||||
If ARGS is provided, use (apply 'format nil PATH ARGS) as the value of PATH."
|
||||
(merge-pathnames (apply 'format nil path args) coleslaw-conf:*basedir*))
|
||||
|
||||
(defun compile-blog ()
|
||||
(let ((staging #p"/tmp/coleslaw/"))
|
||||
|
@ -22,7 +12,7 @@
|
|||
(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*))))
|
||||
(let ((css-dir (app-path "themes/~a/css/" (theme *config*)))
|
||||
(static-dir (merge-pathnames "static/" (repo *config*))))
|
||||
(dolist (dir (list css-dir static-dir))
|
||||
(run-program "cp" `("-R" ,dir "."))))
|
||||
|
@ -36,7 +26,7 @@
|
|||
|
||||
(defun deploy (dir)
|
||||
"Deploy DIR, updating the .prev and .curr symlinks."
|
||||
(let ((new-build (app-path (format nil "generated/~a" (get-universal-time)))))
|
||||
(let ((new-build (app-path "generated/~a" (get-universal-time))))
|
||||
(run-program "mv" (list dir (namestring new-build)))
|
||||
(when (probe-file (app-path ".prev"))
|
||||
(delete-files (read-symlink (app-path ".prev")) :recursive t))
|
||||
|
@ -47,6 +37,7 @@
|
|||
|
||||
(defun main ()
|
||||
(load-config)
|
||||
(compile-theme)
|
||||
(loop do (if (blog-update-p)
|
||||
(compile-blog)
|
||||
(sleep (interval *config*)))))
|
||||
|
|
|
@ -1,5 +1,16 @@
|
|||
(in-package :coleslaw)
|
||||
|
||||
(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)))
|
||||
|
||||
(defparameter *config* nil
|
||||
"A variable to store the blog configuration and plugin settings.")
|
||||
|
||||
|
|
|
@ -4,35 +4,5 @@
|
|||
#:delete-files
|
||||
#:read-symlink
|
||||
#:run-program)
|
||||
(:export ;; themes
|
||||
#:add-injection
|
||||
#:remove-injection
|
||||
|
||||
;; plugins
|
||||
#:load-plugins
|
||||
|
||||
;; posts
|
||||
#:make-post
|
||||
#:add-post
|
||||
#:remove-post
|
||||
#:render-post
|
||||
#:find-post
|
||||
#:post-url
|
||||
|
||||
#:post-id
|
||||
#:post-title
|
||||
#:post-tags
|
||||
#:post-date
|
||||
#:post-content
|
||||
#:post-aliases
|
||||
|
||||
;; indices
|
||||
#:make-index
|
||||
#:add-to-index
|
||||
#:remove-from-index
|
||||
#:render-index
|
||||
#:find-index
|
||||
#:index-url
|
||||
|
||||
#:index-id
|
||||
#:index-posts))
|
||||
(:import-from :iolib.pathnames #:file-path-namestring)
|
||||
(:export #:main))
|
||||
|
|
|
@ -9,11 +9,13 @@
|
|||
(defun theme-package (&key (name (theme *config*)))
|
||||
(find-package (string-upcase (concatenate 'string "coleslaw.theme." name))))
|
||||
|
||||
(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)))))
|
||||
(defun compile-theme (&key (theme-dir (app-path "themes/~a/" (theme *config*))))
|
||||
(flet ((maybe-compile (file)
|
||||
(let* ((path (merge-pathnames (file-path-namestring file) theme-dir))
|
||||
(extension (pathname-type path)))
|
||||
(when (and extension (string= extension "tmpl"))
|
||||
(compile-template :common-lisp-backend path)))))
|
||||
(iolib.os:mapdir #'maybe-compile theme-dir)))
|
||||
|
||||
;; DOCUMENTATION
|
||||
;; A theme directory should be named after the theme and contain *.tmpl files
|
||||
|
|
Loading…
Add table
Reference in a new issue