Pages

Wednesday, September 8, 2010

improved code for googlecl blog

Click here for newer code hosted on git-hub.

(defcustom org-googlecl-blogname "My Blog Name"
"The name of the default blogger/blogspot blog you wish to blog to."
:group 'org-googlecl
:type 'string)

(defcustom org-googlecl-username "changeme@googlemail.com"
"The google user id you wish to authenticate with. e.g mydevusername@googlemail.com"
:group 'org-googlecl
:type 'string)

(defun rgr/org-blog-entry ()
(interactive)
(if current-prefix-arg
; WOuld be nice to be able to query possible blogs and allow tab completion on legal names.
(setq org-googlecl-blogname (read-from-minibuffer "Blog Name:")))
(save-excursion
(let ((tmpheading (org-get-heading))
tmptags (org-get-tags-string))
(goto-char (org-entry-beginning-position))
(set-mark (org-entry-end-position))
(let*((tmpfile (make-temp-file "org-blog-html-"))
(blog-command (concat "google blogger post --blog \"" org-googlecl-blogname "\" --title \"" tmpheading "\" --user \"" org-googlecl-username (if (length tmptags) (concat "\" --tags \"org-googlecl," tmptags "\" ") "") tmpfile )))
(message "google blog command is : %s" blog-command)
(org-export-as-html 1 nil nil (find-file-noselect tmpfile) t)
(with-current-buffer (get-file-buffer tmpfile) (save-buffer))
(start-process-shell-command "Google Blog" "*googlecl*" blog-command)))))

1 comment:

  1. This code is nos superceded by http://splash-of-open-sauce.blogspot.com/2010/09/new-test-code_3708.html

    ReplyDelete