Merge pull request #187 from equwal/url-gen-control
Control of URL generation -- extensions and name-fn
This commit is contained in:
commit
e7e68ce602
4 changed files with 29 additions and 8 deletions
|
@ -25,9 +25,11 @@ There are also many *optional* config parameters such as:
|
||||||
* `:charset` => to set HTML attributes for international characters, default: "UTF-8"
|
* `:charset` => to set HTML attributes for international characters, default: "UTF-8"
|
||||||
* `:feeds` => to generate RSS and Atom feeds for certain tagged content
|
* `:feeds` => to generate RSS and Atom feeds for certain tagged content
|
||||||
* `:excerpt-sep` => to set the separator for excerpt in content, default: `<!--more-->`
|
* `:excerpt-sep` => to set the separator for excerpt in content, default: `<!--more-->`
|
||||||
|
* `:index-ext` => The extension for the index, default "html" for index.html
|
||||||
* `:lang` => to set HTML attributes indicating the site language, default: "en"
|
* `:lang` => to set HTML attributes indicating the site language, default: "en"
|
||||||
* `:license` => to override the displayed content license, the default is CC-BY-SA
|
* `:license` => to override the displayed content license, the default is CC-BY-SA
|
||||||
* `:page-ext` => to set the suffix of generated files, default: "html"
|
* `:name-fn` => to modify URL strings after they are generated, default: `'identity`
|
||||||
|
* `:page-ext` => to set the suffix of generated files, default: "html". "" for no extension
|
||||||
* `:plugins` => to configure and enable coleslaw's [various plugins][plugin-use]
|
* `:plugins` => to configure and enable coleslaw's [various plugins][plugin-use]
|
||||||
* `:separator` => to set the separator for content metadata, default: ";;;;;"
|
* `:separator` => to set the separator for content metadata, default: ";;;;;"
|
||||||
* `:sitenav` => to provide relevant links and ease navigation
|
* `:sitenav` => to provide relevant links and ease navigation
|
||||||
|
|
|
@ -43,8 +43,8 @@
|
||||||
(publish ctype))
|
(publish ctype))
|
||||||
(do-subclasses (itype index)
|
(do-subclasses (itype index)
|
||||||
(publish itype))
|
(publish itype))
|
||||||
(update-symlink (format nil "index.~A" (page-ext *config*))
|
(update-symlink (format nil "index.~A" (index-ext *config*))
|
||||||
(format nil "1.~A" (page-ext *config*)))))
|
(format nil "1~A" (page-ext *config*)))))
|
||||||
|
|
||||||
(defgeneric deploy (staging)
|
(defgeneric deploy (staging)
|
||||||
(:documentation "Deploy the STAGING build to the directory specified in the config.")
|
(:documentation "Deploy the STAGING build to the directory specified in the config.")
|
||||||
|
|
|
@ -7,9 +7,10 @@
|
||||||
(domain :initarg :domain :reader domain)
|
(domain :initarg :domain :reader domain)
|
||||||
(excerpt-sep :initarg :excerpt-sep :reader excerpt-sep)
|
(excerpt-sep :initarg :excerpt-sep :reader excerpt-sep)
|
||||||
(feeds :initarg :feeds :reader feeds)
|
(feeds :initarg :feeds :reader feeds)
|
||||||
|
(name-fn :initarg :name-fn :reader name-fn)
|
||||||
(lang :initarg :lang :reader lang)
|
(lang :initarg :lang :reader lang)
|
||||||
(license :initarg :license :reader license)
|
(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)
|
(plugins :initarg :plugins :reader plugins)
|
||||||
(repo :initarg :repo :accessor repo-dir)
|
(repo :initarg :repo :accessor repo-dir)
|
||||||
(routing :initarg :routing :reader routing)
|
(routing :initarg :routing :reader routing)
|
||||||
|
@ -17,19 +18,28 @@
|
||||||
(sitenav :initarg :sitenav :reader sitenav)
|
(sitenav :initarg :sitenav :reader sitenav)
|
||||||
(staging-dir :initarg :staging-dir :reader staging-dir)
|
(staging-dir :initarg :staging-dir :reader staging-dir)
|
||||||
(theme :initarg :theme :reader theme)
|
(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
|
(:default-initargs
|
||||||
:feeds nil
|
:feeds nil
|
||||||
:license nil
|
:license nil
|
||||||
:plugins '((rsync "-avz" "--delete" "--exclude" ".git/" "--exclude" ".gitignore" "--copy-links"))
|
:plugins '((rsync "-avz" "--delete" "--exclude" ".git/" "--exclude" ".gitignore" "--copy-links"))
|
||||||
:sitenav nil
|
:sitenav nil
|
||||||
:excerpt-sep "<!--more-->"
|
:excerpt-sep "<!--more-->"
|
||||||
|
:name-fn 'identity
|
||||||
:charset "UTF-8"
|
:charset "UTF-8"
|
||||||
:lang "en"
|
:lang "en"
|
||||||
:page-ext "html"
|
:page-ext #1="html"
|
||||||
:separator ";;;;;"
|
: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)
|
(defun dir-slot-reader (config name)
|
||||||
"Take CONFIG and NAME, and return a directory pathname for the matching SLOT."
|
"Take CONFIG and NAME, and return a directory pathname for the matching SLOT."
|
||||||
(ensure-directory-pathname (slot-value config name)))
|
(ensure-directory-pathname (slot-value config name)))
|
||||||
|
|
|
@ -42,7 +42,16 @@ is provided, it overrides the route used."
|
||||||
(error "No routing method found for: ~A" class-name))
|
(error "No routing method found for: ~A" class-name))
|
||||||
(let* ((result (format nil route unique-id))
|
(let* ((result (format nil route unique-id))
|
||||||
(type (or (pathname-type result) (page-ext *config*))))
|
(type (or (pathname-type result) (page-ext *config*))))
|
||||||
(make-pathname :type type :defaults result))))
|
(make-pathname :name (funcall (name-fn *config*)
|
||||||
|
(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)
|
(defun get-route (doc-type)
|
||||||
"Return the route format string for DOC-TYPE."
|
"Return the route format string for DOC-TYPE."
|
||||||
|
|
Loading…
Add table
Reference in a new issue