2011-04-16 15:45:37 -04:00
|
|
|
(in-package :coleslaw)
|
|
|
|
|
2012-09-14 18:37:56 -04:00
|
|
|
(defparameter *injections* ()
|
|
|
|
"A list that stores pairs of (string . predicate) to inject in the page.")
|
2012-08-20 10:44:46 -04:00
|
|
|
|
2012-09-14 18:37:56 -04:00
|
|
|
(defun add-injection (injection location)
|
|
|
|
(push injection (getf *injections* location)))
|
|
|
|
|
|
|
|
(defun find-injections (content)
|
|
|
|
(flet ((injections-for (location)
|
|
|
|
(loop for (injection . predicate) in (getf *injections* location)
|
|
|
|
when (funcall predicate content)
|
|
|
|
collect injection)))
|
|
|
|
(list :head (injections-for :head)
|
|
|
|
:body (injections-for :body))))
|
2011-04-23 00:13:27 -04:00
|
|
|
|
2012-08-19 00:29:33 -04:00
|
|
|
(defun theme-package (&key (name (theme *config*)))
|
2012-08-20 17:26:12 -04:00
|
|
|
"Find the package matching the theme NAME."
|
2011-04-16 15:45:37 -04:00
|
|
|
(find-package (string-upcase (concatenate 'string "coleslaw.theme." name))))
|
|
|
|
|
2012-08-20 11:06:35 -04:00
|
|
|
(defun theme-fn (name)
|
2012-08-20 17:26:12 -04:00
|
|
|
"Find the symbol NAME inside the current theme's package."
|
2012-08-29 23:08:48 -04:00
|
|
|
(find-symbol (princ-to-string name) (theme-package)))
|
2012-08-20 11:06:35 -04:00
|
|
|
|
2012-09-12 12:52:36 -04:00
|
|
|
(defun compile-theme (theme)
|
|
|
|
"Locate and compile the templates for the given THEME."
|
|
|
|
(do-files (file (app-path "themes/~a/" theme) "tmpl")
|
|
|
|
(compile-template :common-lisp-backend file))
|
|
|
|
(do-files (file (app-path "themes/") "tmpl")
|
2012-08-20 10:44:46 -04:00
|
|
|
(compile-template :common-lisp-backend file)))
|
2011-04-16 15:45:37 -04:00
|
|
|
|
|
|
|
;; DOCUMENTATION
|
|
|
|
;; A theme directory should be named after the theme and contain *.tmpl files
|
|
|
|
;; that define the following functions in a coleslaw.theme.$NAME namespace.
|
2012-09-12 12:52:36 -04:00
|
|
|
;; Required templates:
|
|
|
|
;; {template base}
|
|
|
|
;; {template post}
|
|
|
|
;; {template index}
|