Allow specifying the Wordpress import path in case of bare repos.
This commit is contained in:
parent
97749261db
commit
083d88462a
1 changed files with 8 additions and 8 deletions
|
@ -27,7 +27,7 @@
|
||||||
(format nil "~a-~2,'0d-~2,'0d ~a" year (position month +short-month-names+
|
(format nil "~a-~2,'0d-~2,'0d ~a" year (position month +short-month-names+
|
||||||
:test #'string=) date time)))
|
:test #'string=) date time)))
|
||||||
|
|
||||||
(defun import-post (post &optional (since nil since-supplied-p))
|
(defun import-post (post output &optional (since nil since-supplied-p))
|
||||||
(when (and (string= "publish" (node-val "wp:status" post)) ; is it public?
|
(when (and (string= "publish" (node-val "wp:status" post)) ; is it public?
|
||||||
(string= "post" (node-val "wp:post_type" post)) ; is it a post?
|
(string= "post" (node-val "wp:post_type" post)) ; is it a post?
|
||||||
(or (not since-supplied-p) (string>= (get-timestamp post) since)))
|
(or (not since-supplied-p) (string>= (get-timestamp post) since)))
|
||||||
|
@ -36,10 +36,10 @@
|
||||||
(error "No valid slug-title for post ~a." (get-timestamp post)))
|
(error "No valid slug-title for post ~a." (get-timestamp post)))
|
||||||
(export-post (node-val "title" post) (node-val "category" post)
|
(export-post (node-val "title" post) (node-val "category" post)
|
||||||
(get-timestamp post) (node-val "content:encoded" post)
|
(get-timestamp post) (node-val "content:encoded" post)
|
||||||
(format nil "~a.post" slug)))))
|
(format nil "~a.post" slug) output))))
|
||||||
|
|
||||||
(defun export-post (title tags date content path)
|
(defun export-post (title tags date content path output)
|
||||||
(with-open-file (out (merge-pathnames path (repo *config*))
|
(with-open-file (out (merge-pathnames path (or output (repo *config*)))
|
||||||
:direction :output
|
:direction :output
|
||||||
:if-exists :supersede
|
:if-exists :supersede
|
||||||
:if-does-not-exist :create)
|
:if-does-not-exist :create)
|
||||||
|
@ -52,13 +52,13 @@
|
||||||
(format out ";;;;;~%")
|
(format out ";;;;;~%")
|
||||||
(format out "~A~%" (regex-replace-all (string #\Newline) content "<br>"))))
|
(format out "~A~%" (regex-replace-all (string #\Newline) content "<br>"))))
|
||||||
|
|
||||||
(defun import-posts (filepath &optional since)
|
(defun import-posts (filepath output &optional since)
|
||||||
(when (probe-file filepath)
|
(when (probe-file filepath)
|
||||||
(ensure-directories-exist (repo *config*))
|
(ensure-directories-exist (repo *config*))
|
||||||
(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 post since))
|
(loop for post across posts do (import-post post output since))
|
||||||
(delete-file filepath))))
|
(delete-file filepath))))
|
||||||
|
|
||||||
(defun enable (&key filepath)
|
(defun enable (&key filepath output)
|
||||||
(import-posts filepath))
|
(import-posts filepath output))
|
||||||
|
|
Loading…
Add table
Reference in a new issue