Emacs

Publishing to WordPress with Org2Blog

1. Initialize your environment

Now when you begin, you should install these depencies: xml-rpc, metaweblog, org2blog, htmlize.
You can also download it by git clone or using melpa.
In here, I’m using melpa for getting these stuff.

M-x package-install RET xml-rpc
M-x package-install RET metaweblog
M-x package-install RET org2blog
M-x package-install RET htmlize

So now, you must define what you require package in ‘.emacs’ or ‘init.el’

(require 'xml-rpc)
(require 'org2blog-autoloads)
(require 'netrc)

And then you must key in your username and password in a file by creating’.netrc’.
The content of the file:

machine your-name-blog login your-user-name password your-password

Example:

machine myblog login noname00 password 12345

After finishing all of the user name and password, turn back to your init emacs file.
Now add these code for your init file.

;; This is for define location where your account file is.
;; I've referenced it to the emacs location for easily manage.
(setq your-name-blog (netrc-machine (netrc-parse "~/.emacs.d/.netrc") "your-name-blog" t))

;; Setting your Blog configuration.
(setq org2blog/wp-blog-alist
      `(("your-name-blog"
         :url "https://your-name-blog.wordpress.com/xmlrpc.php"
         :username ,(netrc-get your-name-blog "login")
         :password ,(netrc-get your-name-blog "password")
         :default-title "Hello World"
         :default-categories ("emacs")
         :tags-as-categories nil)))

Note: if your wordpress or any blog need https please add https prefix in the url

Note: There are different between ‘ and ` so you had better use as the template
      I have written. If not you will run error.

Note: When you switching to https, your emacs need to be installed gnutls for ssl
      encryption purpose. So you need to download here and then extract to your location of Emacs example C:\Program Files\Emacs:
http://sourceforge.net/projects/ezwinports/?source=typ_redirect

And now, you just only add some these for finishing the boring things.

;; implemented as HTML styling. Your pick!
(setq org2blog/wp-use-sourcecode-shortcode 't)

;; removed light="true"
(setq org2blog/wp-sourcecode-default-params nil)

;; target language needs to be in here
(setq org2blog/wp-sourcecode-langs
      '("actionscript3" "bash" "coldfusion" "cpp" "csharp" "css" "delphi"
        "erlang" "fsharp" "diff" "groovy" "html" "javascript" "java" "javafx" "matlab"
        "objc" "perl" "php" "text" "powershell" "python" "ruby" "scala" "sql"
        "vb" "xml"
        "sh" "emacs-lisp" "lisp" "lua"))

(setq org-src-fontify-natively t)

;; You want set the keymode map you can use these.
(global-set-key (kbd " l") 'org2blog/wp-login)
(global-set-key (kbd " p") 'org2blog/wp-post-buffer-and-publish)

2. Create a post and publish

After restarting your Emacs, and make sure there’s no error in warning buffer.
Now these step is very easy, you just create a ‘.org’ file, and follow these structure.

“#+TITLE: Your_Name_Title_Post”
“#+CATEGORY: Your_catergory”
“#+DESCRIPTION: Describe something on here.”

“* My heading here”
“** Small heading”
What you want to write it’s now here
For adding the shortcode please add the tag
“#+BEGIN_SRC” “your_language_here”

“#+END_SRC”

Adding a picture:
“[[./1.jpg]\]]”

Please remove “” and \, when typing in org mode, otherwise it will not work.

Now that’s all of the things for using Emacs to publish to WordPress.
If you have any opinion, questions. Please comment here.
References:
https://github.com/punchagan/org2blog
https://vxlabs.com/2014/05/25/emacs-24-with-prelude-org2blog-and-wordpress/

Solving the error: Wrong type argument: stringp, \, http://emacs.stackexchange.com/questions/10207/how-to-get-org2blog-to-use-authinfo-gpg

Solving Emacs HTTPS connection:
https://www.gnu.org/software/emacs/manual/html_mono/emacs-gnutls.html
http://xn--9dbdkw.se/diary/how_to_enable_GnuTLS_for_Emacs_24_on_Windows/index.en.html

wordpress-icon.jpg

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s