Using Octopress and Org-Mode for my website
Every few years I decide that it is time to use a new infrastructure to start blogging. This time Leif suggested that I look into Octopres. I like its original tag: A blogging framework for hackers, but its source infrastructure put me off (it uses ruby, of which I am no fan).
Nonetheless, after doing some research, I decided to try it and it works well.
It makes my website independent of the website where it runs. It moves the management from the deployment site to the author’s site. And no more need of a database. It simply creates a bunch of flat files.
What makes it even more interesting is that it uses flat, plain text files. I think that is the ultimate definition of hacking tools. Flat files are malleable, they are universal, they are easy to author, and easy to search, and they will surve the (software) Apocalypse.
So the next step was to see if I could get away from having to learn a new type of typesetting called markdown, and instead use org-mode. In my opinion org-mode is the most useful tool that has landed in my computer in the last 3 years. It has totally revolutionized the way that I author text (including the way that I write papers).
Well, as it happens, I was not the only one. There has been many people who have done the same (the church of emacs). At the end I used Yoshinari Nomura’s org-octopress, and customized it to export to Markdown rather than HTML (let octopress do the typesetting). This requires Org-mode from git (org-octopress uses many new features that have not been released yet).
Some examples:
A table
This is a table | 2nd column |
---|---|
Value1 | Value2 |
The table above was authored like this:
#+CAPTION: This is the caption
| This is a table | 2nd column |
|-----------------+------------|
| Value1 | Value2 |
How about code?
(defun org-octo-md--get-option (info property-name &optional default)
(let ((property (plist-get info property-name)))
(format "%s" (or property default ""))))
this is what I wrote:
#+BEGIN_SRC emacs-lisp
(defun org-octo-md--get-option (info property-name &optional default)
(let ((property (plist-get info property-name)))
(format "%s" (or property default ""))))
#+END_SRC
But here is where it excels: code execution inside text files
In org-mode you can have snippets of code that generate text that is then used in the document. It can also generate images that are then embedded in the document. Here is an example of a dotty generated image:
This is what I wrote:
:NOT:
#+NAME: dottyExample
#+BEGIN_SRC dot :file /assets/images/2013/exampleDotty.png :exports results
digraph G {
rankdir=RL;
node [shape=circle width="0.7cm" height="0.7cm" fontsize=16 penwidth=2];
edge [color=red penwidth=3]
"dots1" [label="..." color=white fontsize=30]
"r" [shape=circle fillcolor=white style=filled label="r"];
"h" [shape=circle fillcolor=white style=filled label="h"];
"c" [shape=circle fillcolor=green style=filled];
"dots2" [label="..." color=white fontsize=30]
"c" -> "r" [label=" "]
"r" -> "dots1" [label=" "]
"dots2" -> "r" [label=" "]
"h" -> "dots2" [label=" "]
}}
#+END_SRC
:END:
#+RESULTS[6d2ac873c0fc0e0232e317a2a88e734600e5ac0d]: dottyExample
#+CAPTION: Example of Dotty Image
[[file:/assets/images/2013/exampleDotty.png]]
I am a happy camper.
–dmg