Fix handling of newlines in import and errors in post template.
This commit is contained in:
parent
ce344d703e
commit
2aa8b9d298
3 changed files with 33 additions and 25 deletions
|
@ -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"))
|
||||
(regex-replace-all (string #\Newline)
|
||||
(node-val "content:encoded")
|
||||
"<br>")
|
||||
: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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
{namespace coleslaw.theme.hyde}
|
||||
|
||||
{template post}
|
||||
<div class="article-meta">
|
||||
<h1 class="title" {$title}>
|
||||
<div class="tags"
|
||||
Tagged as: {$tags}
|
||||
</div>
|
||||
<div class="date">
|
||||
<div class="article-meta">{\n}
|
||||
<h1 class="title">{$title}</h1>{\n}
|
||||
<div class="tags">{\n}
|
||||
Tagged as {$tags}
|
||||
</div>{\n}
|
||||
<div class="date">{\n}
|
||||
Written on {$date}
|
||||
</div>
|
||||
<div class="article-content">
|
||||
</div>{\n}
|
||||
</div>{\n}
|
||||
<div class="article-content">{\n}
|
||||
{$content |noAutoescape}
|
||||
</div>
|
||||
<div class="relative-nav">
|
||||
</div>{\n}
|
||||
<div class="relative-nav">{\n}
|
||||
{if $prev} <a href="{$prev}">Previous</a> {/if}
|
||||
{if $next} <a href="{$next}">Next</a> {/if}
|
||||
</div>
|
||||
{if $comments}
|
||||
</div>{\n}
|
||||
{if $comments}
|
||||
<div class="comments">{$comments |noAutoescape}</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{/template}
|
||||
|
|
Loading…
Add table
Reference in a new issue