POST rendering cleanup.

This commit is contained in:
Brit Butler 2012-09-12 10:16:57 -04:00
parent 467f81098b
commit 8443a0bc3a
2 changed files with 13 additions and 22 deletions

View file

@ -11,6 +11,13 @@
(format :initform nil :initarg :format :accessor post-format)
(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 ()
"Read the stored .post files from the repo."
(clrhash *posts*)
@ -22,10 +29,6 @@
(post-slug 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 ()
"Iterate through the files in the repo to render+write the posts out to disk."
(load-posts)
@ -34,8 +37,7 @@
for prev = nil then post
for post = (nth (1- i) posts)
for next = (nth i posts)
do (write-post post :prev (and prev (post-url prev))
:next (and next (post-url next)))))
do (render-page post nil :prev prev :next next)))
(defgeneric render-content (text format)
(:documentation "Compile TEXT from the given FORMAT to HTML for display.")
@ -73,17 +75,6 @@
(getf args :format))
: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)
"Determine if CHAR is a valid slug (i.e. URL) character."
(or (char<= #\0 char #\9)

View file

@ -2,19 +2,19 @@
{template post}
<div class="article-meta">{\n}
<h1 class="title">{$title}</h1>{\n}
<h1 class="title">{$post.title}</h1>{\n}
<div class="tags">{\n}
Tagged as {foreach $tag in $tags}
<a href="../{$tag.url |noAutoescape}">{$tag.name}</a>
Tagged as {foreach $tag in $post.tags}
<a href="../tag/{$tag}.html">{$tag}</a>
{if not isLast($tag)}, {/if}
{/foreach}
</div>{\n}
<div class="date">{\n}
Written on {$date}
Written on {$post.date}
</div>{\n}
</div>{\n}
<div class="article-content">{\n}
{$content |noAutoescape}
{$post.content |noAutoescape}
</div>{\n}
<div class="relative-nav">{\n}
{if $prev} <a href="{$prev}">Previous</a><br> {/if}{\n}