|
@@ -1,12 +1,18 @@
|
1
|
1
|
(in-package :coleslaw)
|
2
|
2
|
|
3
|
|
-(defparameter *injections* (make-hash-table :test #'equal)
|
4
|
|
- "A hash table for storing JS to inject in the theme templates.")
|
|
3
|
+(defparameter *injections* ()
|
|
4
|
+ "A list that stores pairs of (string . predicate) to inject in the page.")
|
5
|
5
|
|
6
|
|
-(defgeneric add-injection (str location)
|
7
|
|
- (:documentation "Add STR to the list of elements injected in LOCATION.")
|
8
|
|
- (:method ((str string) location)
|
9
|
|
- (pushnew str (gethash location *injections*) :test #'string=)))
|
|
6
|
+(defun add-injection (injection location)
|
|
7
|
+ (push injection (getf *injections* location)))
|
|
8
|
+
|
|
9
|
+(defun find-injections (content)
|
|
10
|
+ (flet ((injections-for (location)
|
|
11
|
+ (loop for (injection . predicate) in (getf *injections* location)
|
|
12
|
+ when (funcall predicate content)
|
|
13
|
+ collect injection)))
|
|
14
|
+ (list :head (injections-for :head)
|
|
15
|
+ :body (injections-for :body))))
|
10
|
16
|
|
11
|
17
|
(defun theme-package (&key (name (theme *config*)))
|
12
|
18
|
"Find the package matching the theme NAME."
|
|
@@ -30,4 +36,3 @@
|
30
|
36
|
;; {template base}
|
31
|
37
|
;; {template post}
|
32
|
38
|
;; {template index}
|
33
|
|
-
|