diff --git a/src/content.lisp b/src/content.lisp index c818e0c..a80fc1f 100644 --- a/src/content.lisp +++ b/src/content.lisp @@ -36,6 +36,11 @@ (date :initform nil :initarg :date :accessor content-date) (text :initform nil :initarg :text :accessor content-text))) +(defmethod initialize-instance :after ((object content) &key) + (with-accessors ((tags content-tags)) object + (when (stringp tags) + (setf tags (mapcar #'make-tag (cl-ppcre:split "," tags)))))) + (defun read-content (file) "Returns a plist of metadata from FILE with :text holding the content as a string." (flet ((slurp-remainder (stream) @@ -46,9 +51,7 @@ (parse-field (str) (nth-value 1 (cl-ppcre:scan-to-strings "[a-zA-Z]+: (.*)" str))) (field-name (line) - (make-keyword (string-upcase (subseq line 0 (position #\: line))))) - (read-tags (str) - (mapcar #'make-tag (cl-ppcre:split "," str)))) + (make-keyword (string-upcase (subseq line 0 (position #\: line)))))) (with-open-file (in file :external-format '(:utf-8)) (unless (string= (read-line in) (separator *config*)) (error "The provided file lacks the expected header.")) @@ -57,7 +60,6 @@ appending (list (field-name line) (aref (parse-field line) 0)))) (content (slurp-remainder in))) - (setf (getf meta :tags) (read-tags (getf meta :tags))) (append meta (list :text content)))))) ;; Helper Functions diff --git a/themes/hyde/post.tmpl b/themes/hyde/post.tmpl index 6406035..3c514cd 100644 --- a/themes/hyde/post.tmpl +++ b/themes/hyde/post.tmpl @@ -4,13 +4,17 @@
{\n}

{$post.title}

{\n}
{\n} - Tagged as {foreach $tag in $post.tags} - {$tag.name}{nil} - {if not isLast($tag)},{sp}{/if} - {/foreach} + {if $post.tags} + Tagged as {foreach $tag in $post.tags} + {$tag.name}{nil} + {if not isLast($tag)},{sp}{/if} + {/foreach} + {/if}
{\n}
{\n} - Written on {$post.date} + {if $post.date} + Written on {$post.date} + {/if}
{\n}
{\n}
{\n} diff --git a/themes/readable/post.tmpl b/themes/readable/post.tmpl index a5be92f..b655ce7 100644 --- a/themes/readable/post.tmpl +++ b/themes/readable/post.tmpl @@ -3,13 +3,19 @@ {template post}
{\n}

{$post.title}

{\n} -

Tagged as - {foreach $tag in $post.tags} - {$tag.name}{nil} - {if not isLast($tag)},{sp}{/if} - {/foreach} +

+ {if $post.tags} + Tagged as {foreach $tag in $post.tags} + {$tag.name}{nil} + {if not isLast($tag)},{sp}{/if} + {/foreach} + {/if} +

+

+ {if $post.date} + Written on {$post.date} + {/if}

-

Written on {$post.date}

{$post.text |noAutoescape}