Ver código fonte

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

Brit Butler 11 anos atrás
pai
commit
74ac87d4e5
3 arquivos alterados com 6 adições e 6 exclusões
  1. 2 2
      src/config.lisp
  2. 0 4
      src/content.lisp
  3. 4 0
      src/util.lisp

+ 2 - 2
src/config.lisp

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

+ 0 - 4
src/content.lisp

@@ -22,10 +22,6 @@
22 22
    (date :initform nil :initarg :date :accessor content-date)
23 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 25
 (defun tag-p (tag obj)
30 26
   "Test if OBJ is tagged with TAG."
31 27
   (member tag (content-tags obj) :test #'tag-slug=))

+ 4 - 0
src/util.lisp

@@ -1,5 +1,9 @@
1 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 7
 (defun fmt (fmt-str args)
4 8
   "A convenient FORMAT interface for string building."
5 9
   (apply 'format nil fmt-str args))