POST rendering cleanup.
This commit is contained in:
parent
467f81098b
commit
8443a0bc3a
2 changed files with 13 additions and 22 deletions
|
@ -11,6 +11,13 @@
|
||||||
(format :initform nil :initarg :format :accessor post-format)
|
(format :initform nil :initarg :format :accessor post-format)
|
||||||
(content :initform nil :initarg :content :accessor post-content)))
|
(content :initform nil :initarg :content :accessor post-content)))
|
||||||
|
|
||||||
|
(defmethod render ((content post) &key prev next)
|
||||||
|
(funcall (theme-fn 'post)
|
||||||
|
(list :config *config*
|
||||||
|
:post content
|
||||||
|
:prev prev
|
||||||
|
:next next)))
|
||||||
|
|
||||||
(defun load-posts ()
|
(defun load-posts ()
|
||||||
"Read the stored .post files from the repo."
|
"Read the stored .post files from the repo."
|
||||||
(clrhash *posts*)
|
(clrhash *posts*)
|
||||||
|
@ -22,10 +29,6 @@
|
||||||
(post-slug post))
|
(post-slug post))
|
||||||
(setf (gethash (post-slug post) *posts*) post))))))
|
(setf (gethash (post-slug post) *posts*) post))))))
|
||||||
|
|
||||||
(defun post-url (post)
|
|
||||||
"Return the relative URL for a given post."
|
|
||||||
(format nil "~a.html" (post-slug post)))
|
|
||||||
|
|
||||||
(defun render-posts ()
|
(defun render-posts ()
|
||||||
"Iterate through the files in the repo to render+write the posts out to disk."
|
"Iterate through the files in the repo to render+write the posts out to disk."
|
||||||
(load-posts)
|
(load-posts)
|
||||||
|
@ -34,8 +37,7 @@
|
||||||
for prev = nil then post
|
for prev = nil then post
|
||||||
for post = (nth (1- i) posts)
|
for post = (nth (1- i) posts)
|
||||||
for next = (nth i posts)
|
for next = (nth i posts)
|
||||||
do (write-post post :prev (and prev (post-url prev))
|
do (render-page post nil :prev prev :next next)))
|
||||||
:next (and next (post-url next)))))
|
|
||||||
|
|
||||||
(defgeneric render-content (text format)
|
(defgeneric render-content (text format)
|
||||||
(:documentation "Compile TEXT from the given FORMAT to HTML for display.")
|
(:documentation "Compile TEXT from the given FORMAT to HTML for display.")
|
||||||
|
@ -73,17 +75,6 @@
|
||||||
(getf args :format))
|
(getf args :format))
|
||||||
:slug (slugify (getf args :title))))))))
|
:slug (slugify (getf args :title))))))))
|
||||||
|
|
||||||
(defun write-post (post &key prev next)
|
|
||||||
"Write out the HTML for POST in SLUG.html."
|
|
||||||
(render-page (format nil "posts/~a" (post-url post))
|
|
||||||
(funcall (theme-fn 'post)
|
|
||||||
(list :title (post-title post)
|
|
||||||
:tags (taglinks (post-tags post))
|
|
||||||
:date (post-date post)
|
|
||||||
:content (post-content post)
|
|
||||||
:prev prev
|
|
||||||
:next next))))
|
|
||||||
|
|
||||||
(defun slug-char-p (char)
|
(defun slug-char-p (char)
|
||||||
"Determine if CHAR is a valid slug (i.e. URL) character."
|
"Determine if CHAR is a valid slug (i.e. URL) character."
|
||||||
(or (char<= #\0 char #\9)
|
(or (char<= #\0 char #\9)
|
||||||
|
|
|
@ -2,19 +2,19 @@
|
||||||
|
|
||||||
{template post}
|
{template post}
|
||||||
<div class="article-meta">{\n}
|
<div class="article-meta">{\n}
|
||||||
<h1 class="title">{$title}</h1>{\n}
|
<h1 class="title">{$post.title}</h1>{\n}
|
||||||
<div class="tags">{\n}
|
<div class="tags">{\n}
|
||||||
Tagged as {foreach $tag in $tags}
|
Tagged as {foreach $tag in $post.tags}
|
||||||
<a href="../{$tag.url |noAutoescape}">{$tag.name}</a>
|
<a href="../tag/{$tag}.html">{$tag}</a>
|
||||||
{if not isLast($tag)}, {/if}
|
{if not isLast($tag)}, {/if}
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</div>{\n}
|
</div>{\n}
|
||||||
<div class="date">{\n}
|
<div class="date">{\n}
|
||||||
Written on {$date}
|
Written on {$post.date}
|
||||||
</div>{\n}
|
</div>{\n}
|
||||||
</div>{\n}
|
</div>{\n}
|
||||||
<div class="article-content">{\n}
|
<div class="article-content">{\n}
|
||||||
{$content |noAutoescape}
|
{$post.content |noAutoescape}
|
||||||
</div>{\n}
|
</div>{\n}
|
||||||
<div class="relative-nav">{\n}
|
<div class="relative-nav">{\n}
|
||||||
{if $prev} <a href="{$prev}">Previous</a><br> {/if}{\n}
|
{if $prev} <a href="{$prev}">Previous</a><br> {/if}{\n}
|
||||||
|
|
Loading…
Add table
Reference in a new issue