2011-04-16 15:45:37 -04:00
|
|
|
(in-package :coleslaw)
|
|
|
|
|
2012-08-20 10:44:46 -04:00
|
|
|
(defparameter *injections* (make-hash-table :test #'equal))
|
|
|
|
|
2011-04-23 00:13:27 -04:00
|
|
|
(defgeneric add-injection (str location)
|
2012-08-20 10:44:46 -04:00
|
|
|
(:documentation "Add STR to the list of elements injected in LOCATION.")
|
|
|
|
(:method ((str string) location)
|
|
|
|
(pushnew str (gethash location *injections*) :test #'string=)))
|
2011-04-23 00:13:27 -04:00
|
|
|
|
|
|
|
(defgeneric remove-injection (str location)
|
2012-08-20 10:44:46 -04:00
|
|
|
(:documentation "Remove STR from the list of elements injected in LOCATION.")
|
|
|
|
(:method ((str string) location)
|
|
|
|
(setf (gethash location *injections*)
|
|
|
|
(remove str (gethash location *injections*) :test #'string=))))
|
2011-04-23 00:13:27 -04:00
|
|
|
|
2012-08-19 00:29:33 -04:00
|
|
|
(defun theme-package (&key (name (theme *config*)))
|
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)
|
|
|
|
(find-symbol name (theme-package)))
|
|
|
|
|
2012-08-19 14:06:30 -04:00
|
|
|
(defun compile-theme (&key (theme-dir (app-path "themes/~a/" (theme *config*))))
|
2012-08-20 10:44:46 -04:00
|
|
|
(do-files (file theme-dir "tmpl")
|
|
|
|
(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.
|
|
|
|
;; Required templates follow with suggested args (args will be in plists):
|
|
|
|
;; {template base} // title navigation siteroot content credits &key license headInject bodyInject
|
|
|
|
;; {template post} // title tags date content prev next &key comments
|
|
|
|
;; {template index} // title posts prev next &key taglinks monthlinks count
|