home » 2014 » 11 » Reboot of my blog!

Reboot of my blog!

factor blogging

I was kind of unhappy with my previous blog at http://bjourne.blogspot.se/. Mostly because I wanted to have it on my own domain. And also because I want to have full control. Selecting among the templates Blogspot provides you just isn't interesting enough.

So I wrote my own static blog generator in Factor. What you see in front of you is the post I wrote while I was writing the software.

Factor is a concatenative language, so it is very well suited for expressing batch on the form "first this, then that, then something" succintly. My static blog generator is a batch job involving the following steps:

The last step, which I perform manually, is to copy the tre in build to a directory on my web server that serves static files.

Syntax Highlighting

What I like about the setup is that it automatically performs syntax highlighting. Here is a Factor snippet:

: generate-blog ( dir -- )
    [ "build" delete-directory ] ignore-errors
    "posts" make-pages "build" write-pages
    "chrome" "build/chrome" copy-tree
    "build" [
        { "sh" "-c" } scp-path "scp -r * %s" sprintf suffix try-process
    ] with-directory
] with-directory ;

And a Python one:

def simbets(count, bet_size, win_prob, capital):
    for n in range(count):
        won = random() < win_prob
        capital += bet_size if won else -bet_size
    return capital


Remaining problems to solve

Syntax hilighting is nice, but sometimes you wish to turn it off for some verbatim blocks. I think due to a bug in Python-Markdown turning it off isn't possible; guess_lang=False doesn't work? #374. A workaround is to explicitly mark the block as plain text using :::text.

Another limitation seem to be that syntax highlighting produces good colorizations for some languages but not for others. For example, here is the same code piece highlighted first with elips:

(unless (boundp 'org-html-cvt-link-fn)
    "Requires a different version of org-mode.  See README.org"))

and then with scheme:

(unless (boundp 'org-html-cvt-link-fn)
    "Requires a different version of org-mode.  See README.org"))

Missing features

Some non-essential features are missing too. Like I want you to be able to click on tag words, come to an url like /blog/factor and find all posts with that tag. Maybe I'll add those features in the coming days or maybe I won't. I don't think people often browse posts on someones blog.

Comments is something I'll never add. It's way to much work keeping the spammers away and the legit comments you get are incredibly few. People can mail me if they want to discuss.

Pagination is a maybe feature. The index page contains all my blogging for the last two years but is still easily scrollable. I just don't blog often enough. :)