Move the filepath stuff into an :around method.
This commit is contained in:
parent
6dc400c91c
commit
d7747ea0b2
1 changed files with 12 additions and 9 deletions
|
@ -15,6 +15,12 @@
|
||||||
(defgeneric page-path (object)
|
(defgeneric page-path (object)
|
||||||
(:documentation "The path to store OBJECT at once rendered."))
|
(:documentation "The path to store OBJECT at once rendered."))
|
||||||
|
|
||||||
|
(defmethod page-path :around ((object object))
|
||||||
|
(let ((result (namestring (call-next-method))))
|
||||||
|
(if (position #\. result)
|
||||||
|
result
|
||||||
|
(concatenate 'string result ".html"))))
|
||||||
|
|
||||||
(defun render-page (content &optional theme-fn &rest render-args)
|
(defun render-page (content &optional theme-fn &rest render-args)
|
||||||
"Render the given CONTENT to disk using THEME-FN if supplied.
|
"Render the given CONTENT to disk using THEME-FN if supplied.
|
||||||
Additional args to render CONTENT can be passed via RENDER-ARGS."
|
Additional args to render CONTENT can be passed via RENDER-ARGS."
|
||||||
|
@ -26,15 +32,12 @@ Additional args to render CONTENT can be passed via RENDER-ARGS."
|
||||||
:injections (find-injections content))))
|
:injections (find-injections content))))
|
||||||
|
|
||||||
(defun write-page (filepath page)
|
(defun write-page (filepath page)
|
||||||
"Write the given PAGE to FILEPATH.html unless an extension is present."
|
"Write the given PAGE to FILEPATH."
|
||||||
(let ((path (if (position #\. filepath)
|
(ensure-directories-exist filepath)
|
||||||
filepath
|
(with-open-file (out filepath
|
||||||
(concatenate 'string filepath ".html"))))
|
|
||||||
(ensure-directories-exist path)
|
|
||||||
(with-open-file (out path
|
|
||||||
:direction :output
|
:direction :output
|
||||||
:if-does-not-exist :create)
|
:if-does-not-exist :create)
|
||||||
(write-line page out))))
|
(write-line page out)))
|
||||||
|
|
||||||
(defun compile-blog (staging)
|
(defun compile-blog (staging)
|
||||||
"Compile the blog to a STAGING directory as specified in .coleslawrc."
|
"Compile the blog to a STAGING directory as specified in .coleslawrc."
|
||||||
|
|
Loading…
Add table
Reference in a new issue