From 2aa8b9d29821f75050589d31c07cc0664925af41 Mon Sep 17 00:00:00 2001 From: Brit Butler Date: Sun, 17 Apr 2011 19:07:04 -0400 Subject: [PATCH] Fix handling of newlines in import and errors in post template. --- plugins/import.lisp | 13 +++++++++---- static/posts.lisp | 11 +++++++---- themes/hyde/post.tmpl | 34 +++++++++++++++++----------------- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/plugins/import.lisp b/plugins/import.lisp index edf1233..e371b5d 100644 --- a/plugins/import.lisp +++ b/plugins/import.lisp @@ -1,15 +1,20 @@ (asdf:oos 'asdf:load-op 'cxml) (asdf:oos 'asdf:load-op 'split-sequence) (asdf:oos 'asdf:load-op 'local-time) +(asdf:oos 'asdf:load-op 'cl-ppcre) (defpackage :coleslaw-import (:use :cl :coleslaw :cxml) (:import-from :local-time #:+short-month-names+ #:encode-timestamp) - (:import-from :split-sequence #:split-sequence)) + (:import-from :split-sequence #:split-sequence) + (:import-from :cl-ppcre #:regex-replace-all)) (in-package :coleslaw-import) +;; TODO: +;; add comment handling ... (when comments ...) + (defgeneric import-post (service post) (:documentation "Import POST into *storage*. The method to construct the POST object is determined by SERVICE.")) @@ -42,11 +47,11 @@ object is determined by SERVICE.")) (let ((new-post (make-post (node-val "title") (format nil "~{~A~^, ~}" (node-val "category")) (make-timestamp (node-val "pubDate")) - (node-val "content:encoded") + (regex-replace-all (string #\Newline) + (node-val "content:encoded") + "
") :id (parse-integer (node-val "wp:post_id")))) (comments (nodes "wp:comment"))) - ;; TODO: - ;; add comment handling ... (when comments ...) (add-post new-post (post-id new-post)))))) (defgeneric import-posts (service filepath) diff --git a/static/posts.lisp b/static/posts.lisp index 28b81db..c4c17d3 100644 --- a/static/posts.lisp +++ b/static/posts.lisp @@ -28,15 +28,18 @@ (defmethod render-post (id) (flet ((fn (name) - (find-symbol name (theme-package)))) + (find-symbol name (theme-package))) + (pretty-date (date) + (subseq (local-time:format-rfc1123-timestring nil date) 0 16))) (let* ((post (find-post id)) (result (funcall (fn "POST") (list :title (post-title post) :tags (post-tags post) - :date (post-date post) + :date (pretty-date (post-date post)) :content (post-content post) - :prev (post-prev post) - :next (post-next post))))) + ; :prev (post-prev post) + ; :next (post-next post) + )))) result))) (defmethod find-post (id) diff --git a/themes/hyde/post.tmpl b/themes/hyde/post.tmpl index ed07ce2..0a60b37 100644 --- a/themes/hyde/post.tmpl +++ b/themes/hyde/post.tmpl @@ -1,23 +1,23 @@ {namespace coleslaw.theme.hyde} {template post} -
-

-
-
+{\n} +
{\n} +
{\n} + {$content |noAutoescape} +
{\n} +
{\n} + {if $prev} Previous {/if} + {if $next} Next {/if} +
{\n} +{if $comments}
{$comments |noAutoescape}
- {/if} -
+{/if} {/template}