Update coleslaw-static to not depend on S3. Add beginning of s3 plugin. Update import plugin to support writing posts out to files. Update TODO.
This commit is contained in:
parent
6a1e793016
commit
f821f105ec
4 changed files with 39 additions and 15 deletions
5
TODO
5
TODO
|
@ -10,13 +10,15 @@ TODO:
|
||||||
;;;; implement head-inject/body-inject/navigation!
|
;;;; implement head-inject/body-inject/navigation!
|
||||||
;;;; implement start-coleslaw, stop-coleslaw!
|
;;;; implement start-coleslaw, stop-coleslaw!
|
||||||
;;;; implement render-site!!!
|
;;;; implement render-site!!!
|
||||||
|
;;;; how many globals can we move into *storage* as keywords? ALL OF THEM!
|
||||||
|
;;;; -- What about generics?
|
||||||
;;;; implement atom feed. RSS too?
|
;;;; implement atom feed. RSS too?
|
||||||
;;;; implement non-disqus comment support?
|
;;;; implement non-disqus comment support?
|
||||||
;;;; What do post update semantics look like? i.e. edit file to change tags.
|
;;;; What do post update semantics look like? i.e. edit file to change tags.
|
||||||
;;; indices
|
;;; indices
|
||||||
;; what should it really look like, keeping in mind the API should be mostly
|
;; what should it really look like, keeping in mind the API should be mostly
|
||||||
;; identical between the static and dynamic backend?
|
;; identical between the static and dynamic backend?
|
||||||
;; indexes should be id/name, title + posts. rewrite indices to use them.
|
;; indexes should be id, type, title + posts. rewrite indices to use them.
|
||||||
;;; posts
|
;;; posts
|
||||||
;; post-url, improve escaping.
|
;; post-url, improve escaping.
|
||||||
|
|
||||||
|
@ -25,7 +27,6 @@ TODO:
|
||||||
;;;; implement: analytics, crossposting, disqus, mathjax, pygments, recaptcha, s3
|
;;;; implement: analytics, crossposting, disqus, mathjax, pygments, recaptcha, s3
|
||||||
;;;; support input or output dirs being git repos + have git hooks?
|
;;;; support input or output dirs being git repos + have git hooks?
|
||||||
;;; import
|
;;; import
|
||||||
;; add output to HTML files when static-p is true
|
|
||||||
;; add comment handling ... (when comments ...)
|
;; add comment handling ... (when comments ...)
|
||||||
;; support old URLs via use of post-aliases?
|
;; support old URLs via use of post-aliases?
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
:maintainer "Brit Butler <redline6561@gmail.com>"
|
:maintainer "Brit Butler <redline6561@gmail.com>"
|
||||||
:author "Brit Butler <redline6561@gmail.com>"
|
:author "Brit Butler <redline6561@gmail.com>"
|
||||||
:licence "LLGPL"
|
:licence "LLGPL"
|
||||||
:depends-on (:coleslaw :zs3 :trivial-timers :cl-store)
|
:depends-on (:coleslaw :trivial-timers :cl-store)
|
||||||
:components ((:module static
|
:components ((:module static
|
||||||
:components ((:file "coleslaw")
|
:components ((:file "coleslaw")
|
||||||
(:file "comments"
|
(:file "comments"
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
(asdf:oos 'asdf:load-op 'cxml)
|
(ql:quickload '(cxml split-sequence local-time cl-ppcre))
|
||||||
(asdf:oos 'asdf:load-op 'split-sequence)
|
|
||||||
(asdf:oos 'asdf:load-op 'local-time)
|
|
||||||
(asdf:oos 'asdf:load-op 'cl-ppcre)
|
|
||||||
|
|
||||||
(defpackage :coleslaw-import
|
(defpackage :coleslaw-import
|
||||||
(:use :cl :coleslaw :cxml)
|
(:use :cl :coleslaw :cxml)
|
||||||
|
@ -12,11 +9,11 @@
|
||||||
|
|
||||||
(in-package :coleslaw-import)
|
(in-package :coleslaw-import)
|
||||||
|
|
||||||
(defgeneric import-post (service post)
|
(defgeneric import-post (service post &key static-p)
|
||||||
(: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."))
|
||||||
|
|
||||||
(defmethod import-post ((service (eql :wordpress)) post)
|
(defmethod import-post ((service (eql :wordpress)) post &key static-p)
|
||||||
(labels ((nodes (name)
|
(labels ((nodes (name)
|
||||||
(dom:get-elements-by-tag-name post name))
|
(dom:get-elements-by-tag-name post name))
|
||||||
(value (node)
|
(value (node)
|
||||||
|
@ -49,14 +46,34 @@ object is determined by SERVICE."))
|
||||||
"<br>")
|
"<br>")
|
||||||
:aliases (parse-integer (node-val "wp:post_id"))))
|
:aliases (parse-integer (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))
|
||||||
|
(when static-p
|
||||||
|
(write-post post))))))
|
||||||
|
|
||||||
(defgeneric import-posts (service filepath)
|
(defun write-post (post)
|
||||||
|
(let ((filepath (merge-pathnames *input-dir*
|
||||||
|
(format nil "~5d,'0/~a.html"
|
||||||
|
(post-id post)
|
||||||
|
;; TODO: Write + use escaping fn.
|
||||||
|
(post-title post)))))
|
||||||
|
(with-open-file (out filepath :direction :output :if-exists :supersede)
|
||||||
|
;; TODO: What other data/metadata should we write out?
|
||||||
|
(format out ";;;;;~%")
|
||||||
|
(format out "title: ~A~%" (post-title post))
|
||||||
|
(format out "tags: ~A~%" (pretty-tags (post-tags post)))
|
||||||
|
(format out "date: ~A~%" (pretty-date (post-date post)))
|
||||||
|
(format out ";;;;;~%")
|
||||||
|
(format out "~A~%" (post-content post)))))
|
||||||
|
|
||||||
|
(defgeneric import-posts (service filepath &key static-p)
|
||||||
(:documentation "Import the posts (and potentially comments or other data)
|
(:documentation "Import the posts (and potentially comments or other data)
|
||||||
from FILEPATH, converting them to appropriate coleslaw objects and inserting
|
from FILEPATH, converting them to appropriate coleslaw objects and inserting
|
||||||
them into *storage*. The method to parse the file is determined by SERVICE."))
|
them into *storage*. The method to parse the file is determined by SERVICE.
|
||||||
|
If STATIC-P is true, the posts will also be written into *.html files in
|
||||||
|
*input-directory*."))
|
||||||
|
|
||||||
(defmethod import-posts ((service (eql :wordpress)) filepath)
|
(defmethod import-posts ((service (eql :wordpress)) filepath &key static-p)
|
||||||
(let* ((xml (cxml:parse-file filepath (cxml-dom:make-dom-builder)))
|
(let* ((xml (cxml:parse-file filepath (cxml-dom:make-dom-builder)))
|
||||||
(posts (dom:get-elements-by-tag-name xml "item")))
|
(posts (dom:get-elements-by-tag-name xml "item")))
|
||||||
(loop for post across posts do (import-post service post))))
|
(loop for post across posts do
|
||||||
|
(import-post service post :static-p static-p))))
|
||||||
|
|
|
@ -1,2 +1,8 @@
|
||||||
(in-package :coleslaw)
|
(ql:quickload '(zs3))
|
||||||
|
|
||||||
|
(defpackage :coleslaw-s3
|
||||||
|
(:use :cl :zs3))
|
||||||
|
|
||||||
|
(in-package :coleslaw-s3)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue