Browse Source

revisions to configuration option patch in response to code review

tycho garen 11 years ago
parent
commit
795ddf5f1b
3 changed files with 12 additions and 13 deletions
  1. 2 4
      src/coleslaw.lisp
  2. 9 8
      src/config.lisp
  3. 1 1
      src/posts.lisp

+ 2 - 4
src/coleslaw.lisp

17
 
17
 
18
 (defmethod page-url :around ((object t))
18
 (defmethod page-url :around ((object t))
19
   (let ((result (call-next-method))
19
   (let ((result (call-next-method))
20
-        (extension (if (string-equal (pageext *config*) "/")
20
+        (extension (if (string= (page-ext *config*) "/")
21
                        "html"
21
                        "html"
22
-                       (pageext *config*))))
23
-    (when (string= (char extension 0) ".")
24
-      (setf extension (string-trim "." extension)))
22
+                       (page-ext *config*))))
25
     (if (pathname-type result)
23
     (if (pathname-type result)
26
         result
24
         result
27
         (make-pathname :type extension :defaults result)
25
         (make-pathname :type extension :defaults result)

+ 9 - 8
src/config.lisp

10
    (repo            :initarg :repo           :accessor repo)
10
    (repo            :initarg :repo           :accessor repo)
11
    (sitenav         :initarg :sitenav        :accessor sitenav)
11
    (sitenav         :initarg :sitenav        :accessor sitenav)
12
    (staging-dir     :initarg :staging-dir    :accessor staging-dir)
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")
13
+   (posts-dir       :initarg :posts-dir      :accessor posts-dir      :initform "posts")
14
+   (separator       :initarg :separator      :accessor separator      :initform ";;;;;")
15
+   (page-ext        :initarg :page-ext       :accessor page-ext       :initform "html")
16
    (title           :initarg :title          :accessor title)
16
    (title           :initarg :title          :accessor title)
17
    (theme           :initarg :theme          :accessor theme)))
17
    (theme           :initarg :theme          :accessor theme)))
18
 
18
 
41
         (apply 'enable-plugin (plugin-path name) args)))))
41
         (apply 'enable-plugin (plugin-path name) args)))))
42
 
42
 
43
 (defun discover-config-path (&optional (path ""))
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))))
44
+  "Checks the project directory for a coleslawrc and if one
45
+doesn't exist, uses the coleslawrc in the home directory."
46
+  (let ((rel-path (make-pathname :directory path :name ".coleslawrc")))
47
+    (if (file-exists-p rel-path)
48
+        rel-path
49
+        (make-pathname :directory (namestring (user-homedir-pathname)) :name ".coleslawrc"))))
49
 
50
 
50
 (defun load-config (config-key)
51
 (defun load-config (config-key)
51
   "Load the coleslaw configuration from DIR/.coleslawrc, using CONFIG-KEY
52
   "Load the coleslaw configuration from DIR/.coleslawrc, using CONFIG-KEY

+ 1 - 1
src/posts.lisp

24
                                   :next next)))
24
                                   :next next)))
25
 
25
 
26
 (defmethod page-url ((object post))
26
 (defmethod page-url ((object post))
27
-  (format nil "~a/~a" (postsdir *config*) (content-slug object)))
27
+  (format nil "~a/~a" (posts-dir *config*) (content-slug object)))
28
 
28
 
29
 (defmethod publish ((content-type (eql :post)))
29
 (defmethod publish ((content-type (eql :post)))
30
   (loop for (next post prev) on (append '(nil) (by-date (find-all 'post)))
30
   (loop for (next post prev) on (append '(nil) (by-date (find-all 'post)))