Browse Source

Move CONSTRUCT into util, it's more general than CONTENT.

Brit Butler 11 years ago
parent
commit
74ac87d4e5
3 changed files with 6 additions and 6 deletions
  1. 2 2
      src/config.lisp
  2. 0 4
      src/content.lisp
  3. 4 0
      src/util.lisp

+ 2 - 2
src/config.lisp

55
     (let ((config-form (read in)))
55
     (let ((config-form (read in)))
56
       (if (symbolp (car config-form))
56
       (if (symbolp (car config-form))
57
           ;; Single site config: ignore CONFIG-KEY.
57
           ;; Single site config: ignore CONFIG-KEY.
58
-          (setf *config* (apply #'make-instance 'blog config-form))
58
+          (setf *config* (construct 'blog config-form))
59
           ;; Multi-site config: load config section for CONFIG-KEY.
59
           ;; Multi-site config: load config section for CONFIG-KEY.
60
           (let* ((config-key-pathname (cl-fad:pathname-as-directory config-key))
60
           (let* ((config-key-pathname (cl-fad:pathname-as-directory config-key))
61
                  (section (assoc config-key-pathname config-form
61
                  (section (assoc config-key-pathname config-form
62
                                  :key #'cl-fad:pathname-as-directory
62
                                  :key #'cl-fad:pathname-as-directory
63
                                  :test #'equal)))
63
                                  :test #'equal)))
64
             (if section
64
             (if section
65
-                (setf *config* (apply #'make-instance 'blog (cdr section))
65
+                (setf *config* (construct 'blog (cdr section))
66
                       (repo *config*) config-key)
66
                       (repo *config*) config-key)
67
                 (error 'unknown-config-section-error
67
                 (error 'unknown-config-section-error
68
                        :text (format nil "In ~A: No such key: '~A'." in config-key)))))
68
                        :text (format nil "In ~A: No such key: '~A'." in config-key)))))

+ 0 - 4
src/content.lisp

22
    (date :initform nil :initarg :date :accessor content-date)
22
    (date :initform nil :initarg :date :accessor content-date)
23
    (text :initform nil :initarg :text :accessor content-text)))
23
    (text :initform nil :initarg :text :accessor content-text)))
24
 
24
 
25
-(defun construct (content-type args)
26
-  "Create an instance of CONTENT-TYPE with the given ARGS."
27
-  (apply 'make-instance content-type args))
28
-
29
 (defun tag-p (tag obj)
25
 (defun tag-p (tag obj)
30
   "Test if OBJ is tagged with TAG."
26
   "Test if OBJ is tagged with TAG."
31
   (member tag (content-tags obj) :test #'tag-slug=))
27
   (member tag (content-tags obj) :test #'tag-slug=))

+ 4 - 0
src/util.lisp

1
 (in-package :coleslaw)
1
 (in-package :coleslaw)
2
 
2
 
3
+(defun construct (class-name args)
4
+  "Create an instance of CLASS-NAME with the given ARGS."
5
+  (apply 'make-instance class-name args))
6
+
3
 (defun fmt (fmt-str args)
7
 (defun fmt (fmt-str args)
4
   "A convenient FORMAT interface for string building."
8
   "A convenient FORMAT interface for string building."
5
   (apply 'format nil fmt-str args))
9
   (apply 'format nil fmt-str args))