Explorar o código

revisions to configuration option patch in response to code review

tycho garen %!s(int64=11) %!d(string=hai) anos
pai
achega
795ddf5f1b
Modificáronse 3 ficheiros con 12 adicións e 13 borrados
  1. 2 4
      src/coleslaw.lisp
  2. 9 8
      src/config.lisp
  3. 1 1
      src/posts.lisp

+ 2 - 4
src/coleslaw.lisp

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

+ 9 - 8
src/config.lisp

@@ -10,9 +10,9 @@
10 10
    (repo            :initarg :repo           :accessor repo)
11 11
    (sitenav         :initarg :sitenav        :accessor sitenav)
12 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 16
    (title           :initarg :title          :accessor title)
17 17
    (theme           :initarg :theme          :accessor theme)))
18 18
 
@@ -41,11 +41,12 @@ are in the plugins folder in coleslaw's source directory."
41 41
         (apply 'enable-plugin (plugin-path name) args)))))
42 42
 
43 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 51
 (defun load-config (config-key)
51 52
   "Load the coleslaw configuration from DIR/.coleslawrc, using CONFIG-KEY

+ 1 - 1
src/posts.lisp

@@ -24,7 +24,7 @@
24 24
                                   :next next)))
25 25
 
26 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 29
 (defmethod publish ((content-type (eql :post)))
30 30
   (loop for (next post prev) on (append '(nil) (by-date (find-all 'post)))