Generate fresh IDs but preserve old ones via 'alias' system. Add post-url, update TODO.
This commit is contained in:
parent
2aa8b9d298
commit
ae9d51c79b
5 changed files with 38 additions and 27 deletions
15
TODO
15
TODO
|
@ -9,6 +9,21 @@ Ideas:
|
||||||
;; consider add-to-index/setf-index, create-index, create-post.
|
;; consider add-to-index/setf-index, create-index, create-post.
|
||||||
;; then ensure the indices API is okay and GET GOING.
|
;; then ensure the indices API is okay and GET GOING.
|
||||||
|
|
||||||
|
;;;; DYNAMIC
|
||||||
|
|
||||||
|
;;;; STATIC
|
||||||
|
;;; posts
|
||||||
|
;; Implement find-by-date.
|
||||||
|
;; Make post-url not suck.
|
||||||
|
;; Consider having find-by-range collect all the hash-values in :posts
|
||||||
|
;; and return the range of that list rather than the posts matching start->end.
|
||||||
|
;; Consider storing tags as a list.
|
||||||
|
|
||||||
|
;;;; PLUGINS
|
||||||
|
;;; import
|
||||||
|
;; add comment handling ... (when comments ...)
|
||||||
|
;; support old URLs via use of post-aliases?
|
||||||
|
|
||||||
;;;; rendering hooks (eg. :pygmentize, :xpost-lj?)
|
;;;; rendering hooks (eg. :pygmentize, :xpost-lj?)
|
||||||
;; may need pre- and post- but for now stick to post-.
|
;; may need pre- and post- but for now stick to post-.
|
||||||
;; get run on rendered html before "storage"
|
;; get run on rendered html before "storage"
|
||||||
|
|
|
@ -12,9 +12,6 @@
|
||||||
|
|
||||||
(in-package :coleslaw-import)
|
(in-package :coleslaw-import)
|
||||||
|
|
||||||
;; TODO:
|
|
||||||
;; add comment handling ... (when comments ...)
|
|
||||||
|
|
||||||
(defgeneric import-post (service post)
|
(defgeneric import-post (service post)
|
||||||
(:documentation "Import POST into *storage*. The method to construct the POST
|
(:documentation "Import POST into *storage*. The method to construct the POST
|
||||||
object is determined by SERVICE."))
|
object is determined by SERVICE."))
|
||||||
|
@ -50,7 +47,7 @@ object is determined by SERVICE."))
|
||||||
(regex-replace-all (string #\Newline)
|
(regex-replace-all (string #\Newline)
|
||||||
(node-val "content:encoded")
|
(node-val "content:encoded")
|
||||||
"<br>")
|
"<br>")
|
||||||
:id (parse-integer (node-val "wp:post_id"))))
|
:aliases (node-val "wp:post_id")))
|
||||||
(comments (nodes "wp:comment")))
|
(comments (nodes "wp:comment")))
|
||||||
(add-post new-post (post-id new-post))))))
|
(add-post new-post (post-id new-post))))))
|
||||||
|
|
||||||
|
|
|
@ -21,12 +21,14 @@
|
||||||
#:find-by-tag
|
#:find-by-tag
|
||||||
#:find-by-date
|
#:find-by-date
|
||||||
#:find-by-range
|
#:find-by-range
|
||||||
|
#:post-url
|
||||||
|
|
||||||
#:post-id
|
#:post-id
|
||||||
#:post-title
|
#:post-title
|
||||||
#:post-tags
|
#:post-tags
|
||||||
#:post-date
|
#:post-date
|
||||||
#:post-content
|
#:post-content
|
||||||
|
#:post-aliases
|
||||||
|
|
||||||
;; comments
|
;; comments
|
||||||
#:make-comment
|
#:make-comment
|
||||||
|
|
|
@ -10,7 +10,9 @@
|
||||||
(date :initform nil :initarg :date
|
(date :initform nil :initarg :date
|
||||||
:accessor post-date)
|
:accessor post-date)
|
||||||
(content :initform nil :initarg :content
|
(content :initform nil :initarg :content
|
||||||
:accessor post-content)))
|
:accessor post-content)
|
||||||
|
(aliases :initform nil :initarg :aliases
|
||||||
|
:accessor post-aliases)))
|
||||||
|
|
||||||
(defgeneric make-post (title tags date content &key id &allow-other-keys)
|
(defgeneric make-post (title tags date content &key id &allow-other-keys)
|
||||||
(:documentation "Create a POST with the given data."))
|
(:documentation "Create a POST with the given data."))
|
||||||
|
@ -36,3 +38,6 @@
|
||||||
(defgeneric find-by-range (start end)
|
(defgeneric find-by-range (start end)
|
||||||
(:documentation "Retrieve all posts from *storage* with ids between
|
(:documentation "Retrieve all posts from *storage* with ids between
|
||||||
START and END."))
|
START and END."))
|
||||||
|
|
||||||
|
(defgeneric post-url (id)
|
||||||
|
(:documentation "Return the URL for the post with the given ID."))
|
||||||
|
|
|
@ -1,24 +1,12 @@
|
||||||
(in-package :coleslaw)
|
(in-package :coleslaw)
|
||||||
|
|
||||||
;; TODO
|
(defmethod make-post (title tags date content &key id aliases)
|
||||||
;; How are we handling next/prev + ids?
|
(make-instance 'post :id (incf (gethash :posts-index *storage* 0))
|
||||||
;; Implement find-by-date.
|
|
||||||
;; Consider having find-by-range collect all the hash-values in :posts
|
|
||||||
;; and return the range of that list rather than the posts matching start->end.
|
|
||||||
;; Consider storing tags as a list.
|
|
||||||
|
|
||||||
(defmethod make-post :before (title tags date content &key id &allow-other-keys)
|
|
||||||
(when id
|
|
||||||
(let ((index (gethash :posts-index *storage* 0)))
|
|
||||||
(unless (<= id index)
|
|
||||||
(setf (gethash :posts-index *storage*) (1+ id))))))
|
|
||||||
|
|
||||||
(defmethod make-post (title tags date content &key id)
|
|
||||||
(make-instance 'post :id (or id (gethash :posts-index *storage* 0))
|
|
||||||
:title title
|
:title title
|
||||||
:tags tags
|
:tags tags
|
||||||
:date date
|
:date date
|
||||||
:content content))
|
:content content
|
||||||
|
:aliases aliases))
|
||||||
|
|
||||||
(defmethod add-post ((post post) id)
|
(defmethod add-post ((post post) id)
|
||||||
(setf (gethash id (gethash :posts *storage*)) post))
|
(setf (gethash id (gethash :posts *storage*)) post))
|
||||||
|
@ -37,9 +25,10 @@
|
||||||
:tags (post-tags post)
|
:tags (post-tags post)
|
||||||
:date (pretty-date (post-date post))
|
:date (pretty-date (post-date post))
|
||||||
:content (post-content post)
|
:content (post-content post)
|
||||||
; :prev (post-prev post)
|
:prev (when (find-post (1- id))
|
||||||
; :next (post-next post)
|
(post-url (1- id)))
|
||||||
))))
|
:next (when (find-post (1+ oid))
|
||||||
|
(post-url (1+ id)))))))
|
||||||
result)))
|
result)))
|
||||||
|
|
||||||
(defmethod find-post (id)
|
(defmethod find-post (id)
|
||||||
|
@ -53,6 +42,9 @@
|
||||||
results))
|
results))
|
||||||
|
|
||||||
(defmethod find-by-range (start end)
|
(defmethod find-by-range (start end)
|
||||||
(loop for i from start upto end
|
(loop for id from start upto end collecting (find-post id)))
|
||||||
collecting (find-post id) into results
|
|
||||||
finally (return (remove nil results))))
|
(defmethod post-url (id)
|
||||||
|
(flet ((escape (str)
|
||||||
|
(substitute #\- #\Space str)))
|
||||||
|
(concatenate 'string *site-root* (escape (post-title (find-post id))))))
|
||||||
|
|
Loading…
Add table
Reference in a new issue