Skip to content

Commit

Permalink
Sort the export-as-post function.
Browse files Browse the repository at this point in the history
  • Loading branch information
punchagan committed May 28, 2014
1 parent 18d236d commit 75d8f9e
Showing 1 changed file with 35 additions and 35 deletions.
70 changes: 35 additions & 35 deletions org2blog.el
Expand Up @@ -906,6 +906,35 @@ various export options."
(org2blog/wp-upload-files-replace-urls
(org-no-properties (org-wp-export-as-string nil subtree-p export-options)))))

(defun org2blog/wp--export-as-post (&optional subtree-p)
"Parse an org2blog post (subtree or buffer)."

(let* ((export-options (org2blog/wp--collect-export-options))
(tags-as-categories (plist-get export-options :tags-as-categories)))

(save-restriction
(save-excursion
;; Get the required parameters for posting the blog-post
(setq post (if subtree-p
(org2blog/wp--parse-subtree-entry)
(org2blog/wp--parse-buffer-entry)))

(when tags-as-categories
(setcdr (assoc "categories" post) (cdr (assoc "tags" post)))
(setcdr (assoc "tags" post) nil))

(setcdr (assoc "date" post)
;; Convert post date to ISO timestamp
(org2blog/wp--convert-timestamp-to-iso
;; insert posting timestamp, else edits will change it
(org2blog/wp--insert-current-time subtree-p
(cdr (assoc "date" post)))))
(setcdr (assoc "description" post)
(org2blog/wp--export-as-html subtree-p export-options))

;; Return value
post))))

(defun org2blog/wp--insert-current-time (subtree-p time)
"Insert current time into the post, if no timestamp exists."
(or time
Expand All @@ -925,9 +954,9 @@ various export options."
The post object returned does not contain the exported html.
This post needs to be further processed by the
`org2blog/wp--export-as-post' function, to add the export html and
munge it a little to make it suitable to use with the `ox-wp'
functions. "
`org2blog/wp--export-as-post' function, to add the export html
and munge it a little to make it suitable to use with the
`metaweblog' functions. "

(let*
((parsed-entry
Expand Down Expand Up @@ -955,43 +984,14 @@ functions. "
;; Return value
parsed-entry))

(defun org2blog/wp--export-as-post (&optional subtree-p)
"Parse an org2blog post (subtree or buffer)."

(let* ((export-options (org2blog/wp--collect-export-options))
(tags-as-categories (plist-get export-options :tags-as-categories)))

(save-restriction
(save-excursion
;; Get the required parameters for posting the blog-post
(setq post (if subtree-p
(org2blog/wp--parse-subtree-entry)
(org2blog/wp--parse-buffer-entry)))

(when tags-as-categories
(setcdr (assoc "categories" post) (cdr (assoc "tags" post)))
(setcdr (assoc "tags" post) nil))

(setcdr (assoc "date" post)
;; Convert post date to ISO timestamp
(org2blog/wp--convert-timestamp-to-iso
;; insert posting timestamp, else edits will change it
(org2blog/wp--insert-current-time subtree-p
(cdr (assoc "date" post)))))
(setcdr (assoc "description" post)
(org2blog/wp--export-as-html subtree-p export-options))

;; Return value
post))))

(defun org2blog/wp--parse-subtree-entry ()
"Parse an org2blog subtree entry.
The post object returned does not contain the exported html.
This post needs to be further processed by the
`org2blog/wp--export-as-post' function, to add the export html and
munge it a little to make it suitable to use with the `ox-wp'
functions. "
`org2blog/wp--export-as-post' function, to add the export html
and munge it a little to make it suitable to use with the
`metaweblog' functions. "

(let*
((parsed-entry
Expand Down

0 comments on commit 75d8f9e

Please sign in to comment.