Optional extension file extensions for posts and index
I wanted posts to have no extension (via :page-ext), so I had to allow for :page-ext "" to work, and without inserting a dot at the end of my files. To allow for index.html when :page-ext is not "html", :index-ext "html" in the .coleslawrc is supported.
This commit is contained in:
parent
d1e30f150d
commit
656401df71
3 changed files with 23 additions and 7 deletions
|
@ -40,8 +40,8 @@
|
|||
(publish ctype))
|
||||
(do-subclasses (itype index)
|
||||
(publish itype))
|
||||
(update-symlink (format nil "index.~A" (page-ext *config*))
|
||||
(format nil "1.~A" (page-ext *config*)))))
|
||||
(update-symlink (format nil "index.~A" (index-ext *config*))
|
||||
(format nil "1~A" (page-ext *config*)))))
|
||||
|
||||
(defgeneric deploy (staging)
|
||||
(:documentation "Deploy the STAGING build to the directory specified in the config.")
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
(feeds :initarg :feeds :reader feeds)
|
||||
(lang :initarg :lang :reader lang)
|
||||
(license :initarg :license :reader license)
|
||||
(page-ext :initarg :page-ext :reader page-ext)
|
||||
(page-ext :initarg :page-ext :reader page-ext-intolerant)
|
||||
(plugins :initarg :plugins :reader plugins)
|
||||
(repo :initarg :repo :accessor repo-dir)
|
||||
(routing :initarg :routing :reader routing)
|
||||
|
@ -17,7 +17,8 @@
|
|||
(sitenav :initarg :sitenav :reader sitenav)
|
||||
(staging-dir :initarg :staging-dir :reader staging-dir)
|
||||
(theme :initarg :theme :reader theme)
|
||||
(title :initarg :title :reader title))
|
||||
(title :initarg :title :reader title)
|
||||
(index-ext :initarg :index-ext :reader index-ext))
|
||||
(:default-initargs
|
||||
:feeds nil
|
||||
:license nil
|
||||
|
@ -26,10 +27,17 @@
|
|||
:excerpt-sep "<!--more-->"
|
||||
:charset "UTF-8"
|
||||
:lang "en"
|
||||
:page-ext "html"
|
||||
:page-ext #1="html"
|
||||
:separator ";;;;;"
|
||||
:staging-dir "/tmp/coleslaw"))
|
||||
:staging-dir "/tmp/coleslaw"
|
||||
:index-ext #1#))
|
||||
|
||||
(defun page-ext (config)
|
||||
"Get page extension, and allow for an extensionless system."
|
||||
(let ((ext (page-ext-intolerant config)))
|
||||
(if (string= ext "")
|
||||
""
|
||||
(concatenate 'string "." ext))))
|
||||
(defun dir-slot-reader (config name)
|
||||
"Take CONFIG and NAME, and return a directory pathname for the matching SLOT."
|
||||
(ensure-directory-pathname (slot-value config name)))
|
||||
|
|
|
@ -42,7 +42,15 @@ is provided, it overrides the route used."
|
|||
(error "No routing method found for: ~A" class-name))
|
||||
(let* ((result (format nil route unique-id))
|
||||
(type (or (pathname-type result) (page-ext *config*))))
|
||||
(make-pathname :type type :defaults result))))
|
||||
(make-pathname :name (pathname-name result)
|
||||
:type (when (string/= type "")
|
||||
(if (or (string-equal "index"
|
||||
(pathname-name result))
|
||||
(string-equal "1"
|
||||
(pathname-name result)))
|
||||
(index-ext *config*)
|
||||
type))
|
||||
:defaults result))))
|
||||
|
||||
(defun get-route (doc-type)
|
||||
"Return the route format string for DOC-TYPE."
|
||||
|
|
Loading…
Add table
Reference in a new issue