Просмотр исходного кода

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

Brit Butler лет назад: 10
Родитель
Сommit
762ad5e44d
10 измененных файлов с 28 добавлено и 16 удалено
  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,6 +7,12 @@ Legend:
7 7
     A change to Coleslaw's exported interface. Plugins or Themes that have
8 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 16
 ## Changes for 0.9.6 (2014-09-27):
11 17
 
12 18
 * **SITE-BREAKING CHANGE**: Coleslaw now defaults to a "basic" deploy

+ 1 - 1
coleslaw.asd

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

+ 2 - 2
plugins/import.lisp

@@ -40,7 +40,7 @@
40 40
                    (format nil "~a.post" slug) output))))
41 41
 
42 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 44
                    :direction :output
45 45
                    :if-exists :supersede
46 46
                    :if-does-not-exist :create
@@ -56,7 +56,7 @@
56 56
 
57 57
 (defun import-posts (filepath output &optional since)
58 58
   (when (probe-file filepath)
59
-    (ensure-directories-exist (or output (repo *config*)))
59
+    (ensure-directories-exist (or output (repo-dir *config*)))
60 60
     (let* ((xml (cxml:parse-file filepath (cxml-dom:make-dom-builder)))
61 61
            (posts (dom:get-elements-by-tag-name xml "item")))
62 62
       (loop for post across posts do (import-post post output since))

+ 1 - 1
plugins/incremental.lisp

@@ -41,7 +41,7 @@
41 41
   (let ((db-file (rel-path (user-homedir-pathname) ".coleslaw.db")))
42 42
     (setf coleslaw::*site* (cl-store:restore db-file))
43 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 45
        do (update-content status file-path))
46 46
     (update-content-metadata)
47 47
     ;; Discover's :before method will delete any possibly outdated indexes.

+ 3 - 3
src/coleslaw.lisp

@@ -24,12 +24,12 @@ in REPO-DIR. Optionally, OLDREV is the revision prior to the last push."
24 24
 
25 25
 (defun compile-blog (staging)
26 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 28
   (with-current-directory staging
29 29
     (dolist (dir (list (app-path "themes/~a/css" (theme *config*))
30 30
                        (app-path "themes/~a/img" (theme *config*))
31 31
                        (app-path "themes/~a/js" (theme *config*))
32
-                       (merge-pathnames "static" (repo *config*))))
32
+                       (merge-pathnames "static" (repo-dir *config*))))
33 33
       (when (probe-file dir)
34 34
         (run-program "rsync --delete -raz ~a ." dir)))
35 35
     (do-subclasses (ctype content)
@@ -54,7 +54,7 @@ in REPO-DIR. Optionally, OLDREV is the revision prior to the last push."
54 54
     (unless *config*
55 55
       (load-config (namestring current-working-directory))
56 56
       (compile-theme (theme *config*)))
57
-    (let* ((file (rel-path (repo *config*) path))
57
+    (let* ((file (rel-path (repo-dir *config*) path))
58 58
            (content (construct content-type (read-content file))))
59 59
       (write-file "tmp.html" (render-page content)))))
60 60
 

+ 10 - 2
src/config.lisp

@@ -10,7 +10,7 @@
10 10
    (license         :initarg :license        :reader license)
11 11
    (page-ext        :initarg :page-ext       :reader page-ext)
12 12
    (plugins         :initarg :plugins        :reader plugins)
13
-   (repo            :initarg :repo           :accessor repo)
13
+   (repo            :initarg :repo           :accessor repo-dir)
14 14
    (routing         :initarg :routing        :reader routing)
15 15
    (separator       :initarg :separator      :reader separator)
16 16
    (sitenav         :initarg :sitenav        :reader sitenav)
@@ -28,6 +28,14 @@
28 28
    :separator    ";;;;;"
29 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 39
 (defparameter *config* nil
32 40
   "A variable to store the blog configuration and plugin settings.")
33 41
 
@@ -71,5 +79,5 @@ preferred over the home directory if provided."
71 79
   (with-open-file (in (discover-config-path repo-dir) :external-format :utf-8)
72 80
     (let ((config-form (read in)))
73 81
       (setf *config* (construct 'blog config-form)
74
-            (repo *config*) repo-dir)))
82
+            (repo-dir *config*) repo-dir)))
75 83
   (load-plugins (plugins *config*)))

+ 1 - 1
src/content.lisp

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

+ 1 - 1
src/documents.lisp

@@ -16,7 +16,7 @@
16 16
   (:documentation "Load all documents of the given DOC-TYPE into memory.")
17 17
   (:method (doc-type)
18 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 20
         (let ((obj (construct (class-name doc-type) (read-content file))))
21 21
           (add-document obj))))))
22 22
 

+ 1 - 3
src/packages.lisp

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

+ 2 - 2
src/util.lisp

@@ -38,8 +38,8 @@ BODY on files that match the given extension."
38 38
 (defun (setf getcwd) (path)
39 39
   "Change the operating system's current directory to PATH."
40 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 43
     (error 'directory-does-not-exist :dir path))
44 44
   path)
45 45