Merge pull request #207 from coleslaw-org/fix-extensionless-routing

Fix routing issues
This commit is contained in:
Cthulhux 2023-07-01 16:25:00 +02:00 committed by GitHub
commit cc0271b319
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 27 deletions

View file

@ -25,14 +25,13 @@ There are also many *optional* config parameters such as:
* `:charset` => to set HTML attributes for international characters, default: "UTF-8"
* `:feeds` => to generate RSS and Atom feeds for certain tagged content
* `: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"
* `:license` => to override the displayed content license, the default is CC-BY-SA
* `: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]
* `:separator` => to set the separator for content metadata, default: ";;;;;"
* `:sitenav` => to provide relevant links and ease navigation
* `:staging-dir` => for Coleslaw to do intermediate work, default: "/tmp/coleslaw"
* `:title-fn` => to modify document slugs after they are generated, default: `'identity`
[plugin-use]: https://github.com/redline6561/coleslaw/blob/master/docs/plugin-use.md

View file

@ -37,14 +37,13 @@
(when (probe-file dir)
(if (uiop:os-windows-p)
(run-program "(robocopy ~a ~a /MIR /IS) ^& IF %ERRORLEVEL% LEQ 1 exit 0" dir (path:basename dir))
(run-program "rsync --delete -raz ~a ." dir))
)))
(run-program "rsync --delete -raz ~a ." dir)))))
(do-subclasses (ctype content)
(publish ctype))
(do-subclasses (itype index)
(publish itype))
(update-symlink (format nil "index.~A" (index-ext *config*))
(format nil "1~A" (page-ext *config*)))))
(let ((recent-posts (first (find-all 'numeric-index))))
(update-symlink "index.html" (page-url recent-posts)))))
(defgeneric deploy (staging)
(:documentation "Deploy the STAGING build to the directory specified in the config.")

View file

@ -10,7 +10,7 @@
(name-fn :initarg :name-fn :reader name-fn)
(lang :initarg :lang :reader lang)
(license :initarg :license :reader license)
(page-ext :initarg :page-ext :reader page-ext-intolerant)
(page-ext :initarg :page-ext :reader page-ext)
(plugins :initarg :plugins :reader plugins)
(repo :initarg :repo :accessor repo-dir)
(routing :initarg :routing :reader routing)
@ -18,8 +18,7 @@
(sitenav :initarg :sitenav :reader sitenav)
(staging-dir :initarg :staging-dir :reader staging-dir)
(theme :initarg :theme :reader theme)
(title :initarg :title :reader title)
(index-ext :initarg :index-ext :reader index-ext))
(title :initarg :title :reader title))
(:default-initargs
:feeds nil
:license nil
@ -29,17 +28,10 @@
:name-fn 'identity
:charset "UTF-8"
:lang "en"
:page-ext #1="html"
:page-ext "html"
:separator ";;;;;"
:staging-dir "/tmp/coleslaw"
:index-ext #1#))
:staging-dir "/tmp/coleslaw"))
(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)))

View file

@ -42,15 +42,8 @@ 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 :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))
(make-pathname :name (funcall (name-fn *config*) (pathname-name result))
:type type
:defaults result))))
(defun get-route (doc-type)