Ver código fonte

Use default-initargs, switch some accessors to readers.

Brit Butler 11 anos atrás
pai
commit
414b221e6b
3 arquivos alterados com 27 adições e 22 exclusões
  1. 18 14
      src/config.lisp
  2. 6 5
      src/content.lisp
  3. 3 3
      src/posts.lisp

+ 18 - 14
src/config.lisp

@@ -1,20 +1,24 @@
1 1
 (in-package :coleslaw)
2 2
 
3 3
 (defclass blog ()
4
-  ((author          :initarg :author         :accessor author)
5
-   (deploy-dir      :initarg :deploy-dir     :accessor deploy-dir)
6
-   (domain          :initarg :domain         :accessor domain)
7
-   (feeds           :initarg :feeds          :accessor feeds)
8
-   (license         :initarg :license        :accessor license)
9
-   (page-ext        :initarg :page-ext       :accessor page-ext       :initform "html")
10
-   (plugins         :initarg :plugins        :accessor plugins)
11
-   (repo            :initarg :repo           :accessor repo)
12
-   (routing         :initarg :routing        :accessor routing)
13
-   (separator       :initarg :separator      :accessor separator      :initform ";;;;;")
14
-   (sitenav         :initarg :sitenav        :accessor sitenav)
15
-   (staging-dir     :initarg :staging-dir    :accessor staging-dir    :initform "/tmp/coleslaw/")
16
-   (theme           :initarg :theme          :accessor theme)
17
-   (title           :initarg :title          :accessor title)))
4
+  ((author          :initarg :author         :reader author)
5
+   (deploy-dir      :initarg :deploy-dir     :reader deploy-dir)
6
+   (domain          :initarg :domain         :reader domain)
7
+   (feeds           :initarg :feeds          :reader feeds)
8
+   (license         :initarg :license        :reader license)
9
+   (page-ext        :initarg :page-ext       :reader page-ext)
10
+   (plugins         :initarg :plugins        :reader plugins)
11
+   (repo            :initarg :repo           :reader repo)
12
+   (routing         :initarg :routing        :reader routing)
13
+   (separator       :initarg :separator      :reader separator)
14
+   (sitenav         :initarg :sitenav        :reader sitenav)
15
+   (staging-dir     :initarg :staging-dir    :reader staging-dir)
16
+   (theme           :initarg :theme          :reader theme)
17
+   (title           :initarg :title          :reader title))
18
+  (:default-initargs
19
+   :page-ext "html"
20
+   :separator ";;;;;"
21
+   :staging-dir "/tmp/coleslaw"))
18 22
 
19 23
 (defparameter *config* nil
20 24
   "A variable to store the blog configuration and plugin settings.")

+ 6 - 5
src/content.lisp

@@ -31,11 +31,12 @@
31 31
 ;; Content Types
32 32
 
33 33
 (defclass content ()
34
-  ((file :initform nil :initarg :file :accessor content-file)
35
-   (tags :initform nil :initarg :tags :accessor content-tags)
36
-   (slug :initform nil :initarg :slug :accessor content-slug)
37
-   (date :initform nil :initarg :date :accessor content-date)
38
-   (text :initform nil :initarg :text :accessor content-text)))
34
+  ((file :initarg :file :reader content-file)
35
+   (date :initarg :date :reader content-date)
36
+   (tags :initarg :tags :accessor content-tags)
37
+   (slug :initarg :slug :accessor content-slug)
38
+   (text :initarg :text :accessor content-text))
39
+  (:default-initargs :tags nil :date nil :slug nil))
39 40
 
40 41
 (defmethod initialize-instance :after ((object content) &key)
41 42
   (with-accessors ((tags content-tags)) object

+ 3 - 3
src/posts.lisp

@@ -1,9 +1,9 @@
1 1
 (in-package :coleslaw)
2 2
 
3 3
 (defclass post (content)
4
-  ((title :initform nil :initarg :title :accessor title-of)
5
-   (author :initform nil :initarg :author :accessor author-of)
6
-   (format :initform nil :initarg :format :accessor post-format)))
4
+  ((title :initarg :title :reader title-of)
5
+   (author :initarg :author :accessor author-of)
6
+   (format :initarg :format :accessor post-format)))
7 7
 
8 8
 (defmethod initialize-instance :after ((object post) &key)
9 9
   (with-accessors ((title title-of)