Browse Source

Handle trailing slashes more gracefully. Kick off 0.9.7-dev.

Brit Butler 10 years ago
parent
commit
762ad5e44d
10 changed files with 28 additions and 16 deletions
  1. 6 0
      NEWS.md
  2. 1 1
      coleslaw.asd
  3. 2 2
      plugins/import.lisp
  4. 1 1
      plugins/incremental.lisp
  5. 3 3
      src/coleslaw.lisp
  6. 10 2
      src/config.lisp
  7. 1 1
      src/content.lisp
  8. 1 1
      src/documents.lisp
  9. 1 3
      src/packages.lisp
  10. 2 2
      src/util.lisp

+ 6 - 0
NEWS.md

7
     A change to Coleslaw's exported interface. Plugins or Themes that have
7
     A change to Coleslaw's exported interface. Plugins or Themes that have
8
     not been upstreamed are effected and may require minor effort to fix.
8
     not been upstreamed are effected and may require minor effort to fix.
9
 
9
 
10
+## Changes for 0.9.7 (20xx):
11
+
12
+* Coleslaw now handles **deploy-dir**, **repo**, and **staging-dir**
13
+  config options more gracefully. Previously, various errors could be
14
+  encountered if directory options lacked a trailing slash.
15
+
10
 ## Changes for 0.9.6 (2014-09-27):
16
 ## Changes for 0.9.6 (2014-09-27):
11
 
17
 
12
 * **SITE-BREAKING CHANGE**: Coleslaw now defaults to a "basic" deploy
18
 * **SITE-BREAKING CHANGE**: Coleslaw now defaults to a "basic" deploy

+ 1 - 1
coleslaw.asd

1
 (defsystem #:coleslaw
1
 (defsystem #:coleslaw
2
   :name "coleslaw"
2
   :name "coleslaw"
3
   :description "Flexible Lisp Blogware"
3
   :description "Flexible Lisp Blogware"
4
-  :version "0.9.6"
4
+  :version "0.9.7-dev"
5
   :license "BSD"
5
   :license "BSD"
6
   :author "Brit Butler <redline6561@gmail.com>"
6
   :author "Brit Butler <redline6561@gmail.com>"
7
   :pathname "src/"
7
   :pathname "src/"

+ 2 - 2
plugins/import.lisp

40
                    (format nil "~a.post" slug) output))))
40
                    (format nil "~a.post" slug) output))))
41
 
41
 
42
 (defun export-post (title tags date content path output)
42
 (defun export-post (title tags date content path output)
43
-  (with-open-file (out (merge-pathnames path (or output (repo *config*)))
43
+  (with-open-file (out (merge-pathnames path (or output (repo-dir *config*)))
44
                    :direction :output
44
                    :direction :output
45
                    :if-exists :supersede
45
                    :if-exists :supersede
46
                    :if-does-not-exist :create
46
                    :if-does-not-exist :create
56
 
56
 
57
 (defun import-posts (filepath output &optional since)
57
 (defun import-posts (filepath output &optional since)
58
   (when (probe-file filepath)
58
   (when (probe-file filepath)
59
-    (ensure-directories-exist (or output (repo *config*)))
59
+    (ensure-directories-exist (or output (repo-dir *config*)))
60
     (let* ((xml (cxml:parse-file filepath (cxml-dom:make-dom-builder)))
60
     (let* ((xml (cxml:parse-file filepath (cxml-dom:make-dom-builder)))
61
            (posts (dom:get-elements-by-tag-name xml "item")))
61
            (posts (dom:get-elements-by-tag-name xml "item")))
62
       (loop for post across posts do (import-post post output since))
62
       (loop for post across posts do (import-post post output since))

+ 1 - 1
plugins/incremental.lisp

41
   (let ((db-file (rel-path (user-homedir-pathname) ".coleslaw.db")))
41
   (let ((db-file (rel-path (user-homedir-pathname) ".coleslaw.db")))
42
     (setf coleslaw::*site* (cl-store:restore db-file))
42
     (setf coleslaw::*site* (cl-store:restore db-file))
43
     (loop for (status path) in (get-updated-files)
43
     (loop for (status path) in (get-updated-files)
44
-       for file-path = (rel-path (repo *config*) path)
44
+       for file-path = (rel-path (repo-dir *config*) path)
45
        do (update-content status file-path))
45
        do (update-content status file-path))
46
     (update-content-metadata)
46
     (update-content-metadata)
47
     ;; Discover's :before method will delete any possibly outdated indexes.
47
     ;; Discover's :before method will delete any possibly outdated indexes.

+ 3 - 3
src/coleslaw.lisp

24
 
24
 
25
 (defun compile-blog (staging)
25
 (defun compile-blog (staging)
26
   "Compile the blog to a STAGING directory as specified in .coleslawrc."
26
   "Compile the blog to a STAGING directory as specified in .coleslawrc."
27
-  (ensure-directories-exist (ensure-directory-pathname staging))
27
+  (ensure-directories-exist staging)
28
   (with-current-directory staging
28
   (with-current-directory staging
29
     (dolist (dir (list (app-path "themes/~a/css" (theme *config*))
29
     (dolist (dir (list (app-path "themes/~a/css" (theme *config*))
30
                        (app-path "themes/~a/img" (theme *config*))
30
                        (app-path "themes/~a/img" (theme *config*))
31
                        (app-path "themes/~a/js" (theme *config*))
31
                        (app-path "themes/~a/js" (theme *config*))
32
-                       (merge-pathnames "static" (repo *config*))))
32
+                       (merge-pathnames "static" (repo-dir *config*))))
33
       (when (probe-file dir)
33
       (when (probe-file dir)
34
         (run-program "rsync --delete -raz ~a ." dir)))
34
         (run-program "rsync --delete -raz ~a ." dir)))
35
     (do-subclasses (ctype content)
35
     (do-subclasses (ctype content)
54
     (unless *config*
54
     (unless *config*
55
       (load-config (namestring current-working-directory))
55
       (load-config (namestring current-working-directory))
56
       (compile-theme (theme *config*)))
56
       (compile-theme (theme *config*)))
57
-    (let* ((file (rel-path (repo *config*) path))
57
+    (let* ((file (rel-path (repo-dir *config*) path))
58
            (content (construct content-type (read-content file))))
58
            (content (construct content-type (read-content file))))
59
       (write-file "tmp.html" (render-page content)))))
59
       (write-file "tmp.html" (render-page content)))))
60
 
60
 

+ 10 - 2
src/config.lisp

10
    (license         :initarg :license        :reader license)
10
    (license         :initarg :license        :reader license)
11
    (page-ext        :initarg :page-ext       :reader page-ext)
11
    (page-ext        :initarg :page-ext       :reader page-ext)
12
    (plugins         :initarg :plugins        :reader plugins)
12
    (plugins         :initarg :plugins        :reader plugins)
13
-   (repo            :initarg :repo           :accessor repo)
13
+   (repo            :initarg :repo           :accessor repo-dir)
14
    (routing         :initarg :routing        :reader routing)
14
    (routing         :initarg :routing        :reader routing)
15
    (separator       :initarg :separator      :reader separator)
15
    (separator       :initarg :separator      :reader separator)
16
    (sitenav         :initarg :sitenav        :reader sitenav)
16
    (sitenav         :initarg :sitenav        :reader sitenav)
28
    :separator    ";;;;;"
28
    :separator    ";;;;;"
29
    :staging-dir  "/tmp/coleslaw"))
29
    :staging-dir  "/tmp/coleslaw"))
30
 
30
 
31
+(defun dir-slot-reader (config name)
32
+  "Take CONFIG and NAME, and return a directory pathname for the matching SLOT."
33
+  (ensure-directory-pathname (slot-value config name)))
34
+
35
+(defmethod deploy-dir  ((config blog)) (dir-slot-reader config 'deploy-dir))
36
+(defmethod repo-dir    ((config blog)) (dir-slot-reader config 'repo))
37
+(defmethod staging-dir ((config blog)) (dir-slot-reader config 'staging-dir))
38
+
31
 (defparameter *config* nil
39
 (defparameter *config* nil
32
   "A variable to store the blog configuration and plugin settings.")
40
   "A variable to store the blog configuration and plugin settings.")
33
 
41
 
71
   (with-open-file (in (discover-config-path repo-dir) :external-format :utf-8)
79
   (with-open-file (in (discover-config-path repo-dir) :external-format :utf-8)
72
     (let ((config-form (read in)))
80
     (let ((config-form (read in)))
73
       (setf *config* (construct 'blog config-form)
81
       (setf *config* (construct 'blog config-form)
74
-            (repo *config*) repo-dir)))
82
+            (repo-dir *config*) repo-dir)))
75
   (load-plugins (plugins *config*)))
83
   (load-plugins (plugins *config*)))

+ 1 - 1
src/content.lisp

75
     (with-open-file (in file :external-format :utf-8)
75
     (with-open-file (in file :external-format :utf-8)
76
       (let ((metadata (parse-metadata in))
76
       (let ((metadata (parse-metadata in))
77
             (content (slurp-remainder in))
77
             (content (slurp-remainder in))
78
-            (filepath (enough-namestring file (repo *config*))))
78
+            (filepath (enough-namestring file (repo-dir *config*))))
79
         (append metadata (list :text content :file filepath))))))
79
         (append metadata (list :text content :file filepath))))))
80
 
80
 
81
 ;; Helper Functions
81
 ;; Helper Functions

+ 1 - 1
src/documents.lisp

16
   (:documentation "Load all documents of the given DOC-TYPE into memory.")
16
   (:documentation "Load all documents of the given DOC-TYPE into memory.")
17
   (:method (doc-type)
17
   (:method (doc-type)
18
     (let ((file-type (format nil "~(~A~)" (class-name doc-type))))
18
     (let ((file-type (format nil "~(~A~)" (class-name doc-type))))
19
-      (do-files (file (repo *config*) file-type)
19
+      (do-files (file (repo-dir *config*) file-type)
20
         (let ((obj (construct (class-name doc-type) (read-content file))))
20
         (let ((obj (construct (class-name doc-type) (read-content file))))
21
           (add-document obj))))))
21
           (add-document obj))))))
22
 
22
 

+ 1 - 3
src/packages.lisp

9
   (:import-from :closure-template #:compile-template)
9
   (:import-from :closure-template #:compile-template)
10
   (:import-from :local-time #:format-rfc1123-timestring)
10
   (:import-from :local-time #:format-rfc1123-timestring)
11
   (:import-from :uiop #:getcwd
11
   (:import-from :uiop #:getcwd
12
-                      #:chdir
13
-                      #:ensure-directory-pathname
14
-                      #:directory-exists-p)
12
+                      #:ensure-directory-pathname)
15
   (:export #:main
13
   (:export #:main
16
            #:preview
14
            #:preview
17
            #:*config*
15
            #:*config*

+ 2 - 2
src/util.lisp

38
 (defun (setf getcwd) (path)
38
 (defun (setf getcwd) (path)
39
   "Change the operating system's current directory to PATH."
39
   "Change the operating system's current directory to PATH."
40
   (setf path (ensure-directory-pathname path))
40
   (setf path (ensure-directory-pathname path))
41
-  (unless (and (directory-exists-p path)
42
-               (chdir path))
41
+  (unless (and (uiop:directory-exists-p path)
42
+               (uiop:chdir path))
43
     (error 'directory-does-not-exist :dir path))
43
     (error 'directory-does-not-exist :dir path))
44
   path)
44
   path)
45
 
45