|
@@ -1,17 +1,20 @@
|
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
|
|
- (plugins :initarg :plugins :accessor plugins)
|
10
|
|
- (repo :initarg :repo :accessor repo)
|
11
|
|
- (sitenav :initarg :sitenav :accessor sitenav)
|
12
|
|
- (staging-dir :initarg :staging-dir :accessor staging-dir)
|
13
|
|
- (title :initarg :title :accessor title)
|
14
|
|
- (theme :initarg :theme :accessor theme)))
|
|
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
|
+ (plugins :initarg :plugins :accessor plugins)
|
|
10
|
+ (repo :initarg :repo :accessor repo)
|
|
11
|
+ (sitenav :initarg :sitenav :accessor sitenav)
|
|
12
|
+ (staging-dir :initarg :staging-dir :accessor staging-dir)
|
|
13
|
+ (postsdir :initarg :postsdir :accessor postsdir :initform "posts")
|
|
14
|
+ (separator :initarg :separator :accessor separator :initform ";;;;;")
|
|
15
|
+ (pageext :initarg :pageext :accessor pageext :initform ".html")
|
|
16
|
+ (title :initarg :title :accessor title)
|
|
17
|
+ (theme :initarg :theme :accessor theme)))
|
15
|
18
|
|
16
|
19
|
(define-condition unknown-config-section-error (error)
|
17
|
20
|
((text :initarg :text :reader text)))
|
|
@@ -37,10 +40,18 @@ are in the plugins folder in coleslaw's source directory."
|
37
|
40
|
(destructuring-bind (name &rest args) plugin
|
38
|
41
|
(apply 'enable-plugin (plugin-path name) args)))))
|
39
|
42
|
|
40
|
|
-(defun load-config (&optional config-key (dir (user-homedir-pathname)))
|
|
43
|
+(defun discover-config-path (&optional (path ""))
|
|
44
|
+ (let ((default-path (make-pathname :directory (namestring (user-homedir-pathname)) :name ".coleslawrc"))
|
|
45
|
+ (custom-path (make-pathname :directory path :name ".coleslawrc")))
|
|
46
|
+ (cond
|
|
47
|
+ ((file-exists-p custom-path) custom-path)
|
|
48
|
+ ((file-exists-p default-path) default-path))))
|
|
49
|
+
|
|
50
|
+(defun load-config (config-key)
|
41
|
51
|
"Load the coleslaw configuration from DIR/.coleslawrc, using CONFIG-KEY
|
42
|
52
|
if necessary. DIR is ~ by default."
|
43
|
|
- (with-open-file (in (merge-pathnames ".coleslawrc" dir))
|
|
53
|
+
|
|
54
|
+ (with-open-file (in (discover-config-path config-key))
|
44
|
55
|
(let ((config-form (read in)))
|
45
|
56
|
(if (symbolp (car config-form))
|
46
|
57
|
;; Single site config: ignore CONFIG-KEY.
|