miniblog

Miniblog: A command-line static blog system in Common Lisp
Log | Files | Refs | README | LICENSE

commit 3701397bce23d30653cfc5f883c9cf4023b504d6
parent bca9c85ce6727fff1e9df269f5099d60d2dcfee8
Author: Decay <decay@todayiwilllaunchmyinfantsonintoorbit.com>
Date:   Mon, 12 Oct 2020 23:32:25 -0700

Get rid of the date formatters passed to the templates

Diffstat:
Msrc/content.lisp | 13++++---------
Mtemplates/pagetemplate.lhtml | 6+++---
Mtemplates/rss.lxml | 8++++----
Mtemplates/template.lhtml | 8++++----
4 files changed, 15 insertions(+), 20 deletions(-)

diff --git a/src/content.lisp b/src/content.lisp @@ -34,9 +34,7 @@ :month month :pages pages :archive-date-list archive-date-list - :content-formatter #'miniblog.format:markdown - :short-date-formatter (lambda (datetime) (miniblog.format:short-date-format datetime)) - :long-date-formatter (lambda (datetime) (miniblog.format:long-date-format datetime))))))) + :content-formatter #'miniblog.format:markdown))))) (defun make-page-generator (&key title root-uri header links stylesheet) (lambda (entry path pages &key archive-date-list enable-rss) @@ -54,9 +52,7 @@ :post entry :path path :archive-date-list archive-date-list - :content-formatter #'miniblog.format:markdown - :short-date-formatter (lambda (datetime) (miniblog.format:short-date-format datetime)) - :long-date-formatter (lambda (datetime) (miniblog.format:long-date-format datetime))))))) + :content-formatter #'miniblog.format:markdown))))) (defun strip-html-tags (content) (format nil "~{~A~}" @@ -84,10 +80,9 @@ :webmaster webmaster :category category :posts entries - :build-date (now) + :build-date (miniblog.format:rfc-822-format (now)) :content-formatter #'miniblog.format:markdown - :content-stripper #'strip-html-tags - :rfc-822-date-formatter (lambda (datetime) (miniblog.format:rfc-822-format datetime)))))) + :content-stripper #'strip-html-tags)))) (lambda (entries) (declare (ignore entries))))) diff --git a/templates/pagetemplate.lhtml b/templates/pagetemplate.lhtml @@ -6,7 +6,7 @@ <% @include left-column.lhtml %> <section id="miniblog-main"> <% @if post/content %> - <% (destructuring-bind (&key ((:post (&key content created-at last-updated-at last-updated-by &allow-other-keys))) content-formatter long-date-formatter &allow-other-keys) env %> + <% (destructuring-bind (&key ((:post (&key content created-at last-updated-at created-at-long last-updated-at-long last-updated-by &allow-other-keys))) content-formatter &allow-other-keys) env %> <h2><% @var post/title %></h2> <article> <%= (funcall content-formatter content) %> @@ -14,11 +14,11 @@ <p> <small> Posted by <% @var post/created-by %> on - <%= (funcall long-date-formatter created-at) %> + <% @var post/created-at-long %> <% (if (local-time:timestamp/= created-at last-updated-at) (format t "<br>~%Last updated by ~A on ~A~%" last-updated-by - (funcall long-date-formatter last-updated-at))) %> + last-updated-at-long)) %> </small> </p> <% ) %> diff --git a/templates/rss.lxml b/templates/rss.lxml @@ -6,7 +6,7 @@ <generator>Miniblog</generator> <docs>https://validator.w3.org/feed/docs/rss2.html</docs> <lastBuildDate> - <%= (funcall (getf env :rfc-822-date-formatter) (getf env :build-date)) %> + <% @var build-date %> </lastBuildDate> <% @if image-url %> <image> @@ -32,18 +32,18 @@ <% @endif %> <% @if posts %> <pubDate> - <% (let* ((latest (first (getf env :posts))) (pub-date (funcall (getf env :rfc-822-date-formatter) (getf latest :last-updated-at)))) %> + <% (let* ((latest (first (getf env :posts))) (pub-date (getf latest :last-updated-at-rfc-822))) %> <%= pub-date %> <% ) %> </pubDate> <% (loop for post in (getf env :posts) do %> <% (destructuring-bind (&key id title content last-updated-at &allow-other-keys) post %> <item> - <% (let* ((short-date (funcall (getf env :rfc-822-date-formatter) last-updated-at)) (formatted-content (funcall (getf env :content-formatter) content)) (stripped-content (funcall (getf env :content-stripper) formatted-content)) (truncated-content (str:substring 0 200 stripped-content))) %> + <% (let* ((formatted-content (funcall (getf env :content-formatter) content)) (stripped-content (funcall (getf env :content-stripper) formatted-content)) (truncated-content (str:substring 0 200 stripped-content))) %> <title><%= title %></title> <link><% @var link %>#<%= id %></link> <description><%= (if (equal stripped-content truncated-content) stripped-content (concatenate 'string truncated-content "...")) %></description> - <pubDate><%= short-date %></pubDate> + <pubDate><% @var last-updated-at-rfc-822 %></pubDate> <% ) %> </item> <% ) %> diff --git a/templates/template.lhtml b/templates/template.lhtml @@ -8,8 +8,8 @@ <% @if posts %> <% (let ((short-date) (render-hr nil)) %> <% (loop for post in (getf env :posts) do %> - <% (destructuring-bind (&key id created-at last-updated-at title content created-by last-updated-by) post %> - <% (let ((curr-short-date (funcall (getf env :short-date-formatter) created-at))) %> + <% (destructuring-bind (&key id created-at created-at-short created-at-long last-updated-at last-updated-at-long title content created-by last-updated-by &allow-other-keys) post %> + <% (let ((curr-short-date created-at-short)) %> <% (if render-hr %> <hr> <% ) %> @@ -26,11 +26,11 @@ <p> <small> Posted by <%= created-by %> on - <%= (funcall (getf env :long-date-formatter) created-at) %> + <%= created-at-long %> <% (if (local-time:timestamp/= created-at last-updated-at) (format t "<br>~%Last updated by ~A on ~A~%" last-updated-by - (funcall (getf env :long-date-formatter) last-updated-at))) %> + last-updated-at-long)) %> </small> </p> <% ) %>