Tonλ's blog May the λ be with you

Blogging with org-mode/org2blog/wordpress

by @ardumont on

Statements

When I execute something, I want it to answer quickly, no lag is acceptable.

  • I found out that there is no faster way than using the keyboard to input quickly (at least as fast as my fingers go)

The mouse is slow because you need to break the position of your hands…

But you have too much to do and click to succeed in making one article.

Consequence

I have difficulties in blogging directly in wordpress (it is in the click world and I'm not anymore).

But… help me org-mode-wan, you are my only hope

I know org-mode. And as soon as I become aware of org-mode's abilities to export, I used the html export to make my articles.

You write offline (no network problem then) your article in org-mode (simple yet ultra powerfull text dsl). Then you export in html (C-c C-e b), this will open a tab in your browser almost immediately.

It is way cool…

But the html need to be :

  • copy/paste to wordpress the rendered html
  • the rendering of org-mode table via the copy/past of the exported html is not good
  • as the exported html is a standalone one, it comes with some css we need to remove too (as wordpress already has one)
  • if images there are, you must upload first one at a time… and then remodify the either the org-mode or the html exported
  • etc…

In short, a lot of manual adaptation needs to be done. It's neither feedback oriented nor fun!

In even shorter, it's not perfect!

Then along came… org2blog!

What is it?

It's an adapter between org-mode files and wordpress. Given minor setup steps (to do once), you can never leave your org-mode buffer until you're done!

It's the ultimate blogging way for an org-mode user like me!

Advantages?

  • No network needed (at least until the publishing step)
  • No need to manage the pictures, there will be uploaded and be coherent with the blog
  • You will be prompted to create the categories if they do not already exist.

install?

Here we go, add this to your init.el This is a snippet of code that permits you to automatically search and install the packages you want at startup.

(require 'package)

(add-to-list 'package-archives
             '("marmalade" . "http://marmalade-repo.org/packages/") t)
(add-to-list 'package-archives
             '("melpa" . "http://melpa.milkbox.net/packages/") t)
(package-initialize)

(when (not package-archive-contents)
  (package-refresh-contents))

(defvar my-packages '(org
                      xml-rpc
                      org2blog)
  "A list of packages to ensure are installed at launch.")

(dolist (p my-packages)
  (when (not (package-installed-p p))
    (package-install p)))

Here is the details about packages:

org org-mode
xml-rpc An elisp implementation of clientside XML-RPC
org2blog Blog from Org mode to wordpress

setup?

~/.netrc

To setup the credentials to login into the wordpress.

Here is a sample:

machine some-dummy-machine login some-login password some-password

Each line represents one blog.

machine some-dummy-machine (Note that this will be used in the emacs-lisp code)
login some-login
password some-password

~/.emacs

Add this to your ~/.emacs

;; depends on netrc, xml-rpc
(require 'netrc)
(require 'org2blog-autoloads)
(require 'metaweblog)

;; load the entry 'some-dummy-machine' in the ~/.netrc, we obtain a hash-map with the needed data
(setq blog (netrc-machine (netrc-parse "~/.netrc") "some-dummy-machine" t))

;; now enter the data in the org2blog list of blogs
(setq org2blog/wp-blog-alist
      '(("some-dummy-machine"
         :url "http://your-wordpress-blog/xmlrpc.php"
         :username (netrc-get blog "login")
         :password (netrc-get blog "password"))))

(add-hook 'org-mode-hook 'org2blog/wp-mode)

This will load your credentials and activate the org2blog/wp-mode each time a org-mode file is launched.

Use

Here is my way, you can go from this at first and then improve :D

  • Add some metadata on your file
#+TITLE: Blogging with org-mode and org2blog to publish on wordpress
#+AUTHOR: Antoine R. Dumont
#+OPTIONS:
#+TAGS: org-mode, emacs, wordpress, blog
#+CATEGORIES: org-mode, blog, wordpress
#+DESCRIPTION: Syncing one's org-mode files with one's blog
  • Then You edit normally your org-mode file article, here is a full example
#+BLOG: tony-blog
#+POSTID: 589
#+DATE: [2012-12-22 Sat 20:00]
#+TITLE: Dummy sample to prove org2blog rocks!
#+AUTHOR: Antoine R. Dumont
#+OPTIONS:
#+CATEGORIES: dummy
#+DESCRIPTION: a dummy file
#+STARTUP: indent
#+STARTUP: hidestars odd

* some
** dummy
*** org
* to prove that everything work
  • To check the rendering is ok, export locally your article via C-c C-e b (M-x org-export-as-html-and-open)

export-dummy.png

  • Once you're almost ready, you can upload a draft to your wordpress C-c d (M-x org2blog/wp-post-buffer)

export-dummy-and-upload-draft.png

  • New metadata has been generated at the top of your org-mode file
#+BLOG: tony-blog
#+POSTID: 589
#+DATE: [2012-12-22 Sat 20:00]

This will help in updating your post throughout the time.

  • When ready to publish, hit C-c p (or C-u M-x org2blog/wp-post-buffer)
  • Of course, you can republish after updating some errors/typos (hit C-c p again when you're done updating it)

Enjoy

At last, the perfect way of blogging through emacs! At least for me!

Long live org2blog!

Latest posts