Improve exposed API for plugins.
This commit is contained in:
parent
ef38d2874f
commit
4e27bcf8cd
6 changed files with 26 additions and 21 deletions
|
@ -54,22 +54,23 @@ on files that match the given extension."
|
||||||
(run-program "cp" `("-R" ,dir "."))))
|
(run-program "cp" `("-R" ,dir "."))))
|
||||||
(render-posts)
|
(render-posts)
|
||||||
(render-indices))
|
(render-indices))
|
||||||
(deploy staging)))
|
(deploy staging)
|
||||||
|
(setf (last-published) (last-commit))))
|
||||||
|
|
||||||
(defun update-symlink (name target)
|
(defun update-symlink (name target)
|
||||||
"Update the symlink NAME to point to TARGET."
|
"Update the symlink NAME to point to TARGET."
|
||||||
(run-program "ln" (list "-sfn" (namestring target) name)))
|
(run-program "ln" (list "-sfn" (namestring target) name)))
|
||||||
|
|
||||||
(defun deploy (dir)
|
(defgeneric deploy (dir)
|
||||||
"Deploy DIR, updating the .prev and .curr symlinks."
|
(:documentation "Deploy DIR, updating the .prev and .curr symlinks.")
|
||||||
(let ((new-build (app-path "generated/~a" (get-universal-time))))
|
(:method (dir)
|
||||||
(run-program "mv" (list dir (namestring new-build)))
|
(let ((new-build (app-path "generated/~a" (get-universal-time))))
|
||||||
(when (probe-file (app-path ".prev"))
|
(run-program "mv" (list dir (namestring new-build)))
|
||||||
(delete-files (read-symlink (app-path ".prev")) :recursive t))
|
(when (probe-file (app-path ".prev"))
|
||||||
(when (probe-file (app-path ".curr"))
|
(delete-files (read-symlink (app-path ".prev")) :recursive t))
|
||||||
(update-symlink ".prev" (read-symlink (app-path ".curr"))))
|
(when (probe-file (app-path ".curr"))
|
||||||
(update-symlink ".curr" new-build))
|
(update-symlink ".prev" (read-symlink (app-path ".curr"))))
|
||||||
(setf (last-published) (last-commit)))
|
(update-symlink ".curr" new-build))))
|
||||||
|
|
||||||
(defun main ()
|
(defun main ()
|
||||||
(load-config)
|
(load-config)
|
||||||
|
|
|
@ -27,7 +27,8 @@
|
||||||
(domain *config*) (post-slug post))
|
(domain *config*) (post-slug post))
|
||||||
:title (post-title post)
|
:title (post-title post)
|
||||||
:date (post-date post)
|
:date (post-date post)
|
||||||
:contents (post-contents post)))))
|
:content (render-content (post-content post)
|
||||||
|
(post-format post))))))
|
||||||
(render-page filename
|
(render-page filename
|
||||||
(funcall (theme-fn "INDEX")
|
(funcall (theme-fn "INDEX")
|
||||||
(list :taglinks (taglinks)
|
(list :taglinks (taglinks)
|
||||||
|
|
|
@ -5,4 +5,7 @@
|
||||||
#:read-symlink
|
#:read-symlink
|
||||||
#:run-program)
|
#:run-program)
|
||||||
(:import-from :iolib.pathnames #:file-path-namestring)
|
(:import-from :iolib.pathnames #:file-path-namestring)
|
||||||
(:export #:main))
|
(:export #:main
|
||||||
|
#:add-injection
|
||||||
|
#:render-content
|
||||||
|
#:deploy))
|
||||||
|
|
|
@ -20,6 +20,11 @@
|
||||||
(setf (gethash (post-slug post) *posts*) post))))
|
(setf (gethash (post-slug post) *posts*) post))))
|
||||||
(maphash #'write-post *posts*))
|
(maphash #'write-post *posts*))
|
||||||
|
|
||||||
|
(defgeneric render-content (text format)
|
||||||
|
(:documentation "Compile TEXT from the given FORMAT to HTML for display.")
|
||||||
|
(:method (text (format (eql :html)))
|
||||||
|
text))
|
||||||
|
|
||||||
(defun read-post (stream)
|
(defun read-post (stream)
|
||||||
"Make a POST instance based on the data from STREAM."
|
"Make a POST instance based on the data from STREAM."
|
||||||
)
|
)
|
||||||
|
@ -31,7 +36,8 @@
|
||||||
(list :title (post-title post)
|
(list :title (post-title post)
|
||||||
:tags (post-tags post)
|
:tags (post-tags post)
|
||||||
:date (post-date post)
|
:date (post-date post)
|
||||||
:content (post-content post)
|
:content (render-content (post-content post)
|
||||||
|
(post-format post))
|
||||||
; TODO: Populate prev and next with links.
|
; TODO: Populate prev and next with links.
|
||||||
:prev nil
|
:prev nil
|
||||||
:next nil))))
|
:next nil))))
|
||||||
|
|
|
@ -8,12 +8,6 @@
|
||||||
(:method ((str string) location)
|
(:method ((str string) location)
|
||||||
(pushnew str (gethash location *injections*) :test #'string=)))
|
(pushnew str (gethash location *injections*) :test #'string=)))
|
||||||
|
|
||||||
(defgeneric remove-injection (str location)
|
|
||||||
(:documentation "Remove STR from the list of elements injected in LOCATION.")
|
|
||||||
(:method ((str string) location)
|
|
||||||
(setf (gethash location *injections*)
|
|
||||||
(remove str (gethash location *injections*) :test #'string=))))
|
|
||||||
|
|
||||||
(defun theme-package (&key (name (theme *config*)))
|
(defun theme-package (&key (name (theme *config*)))
|
||||||
"Find the package matching the theme NAME."
|
"Find the package matching the theme NAME."
|
||||||
(find-package (string-upcase (concatenate 'string "coleslaw.theme." name))))
|
(find-package (string-upcase (concatenate 'string "coleslaw.theme." name))))
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<div class="article-meta">
|
<div class="article-meta">
|
||||||
<a class="article-title" href="{$post.url}">{$post.title}</a>
|
<a class="article-title" href="{$post.url}">{$post.title}</a>
|
||||||
<div class="date"> posted on {$post.date}</div>
|
<div class="date"> posted on {$post.date}</div>
|
||||||
<div class="article">{$post.contents |noAutoescape}</div>
|
<div class="article">{$post.content |noAutoescape}</div>
|
||||||
</div>
|
</div>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
<div id="relative-nav">
|
<div id="relative-nav">
|
||||||
|
|
Loading…
Add table
Reference in a new issue