Another thing that has been on my shitlist for quite a while now - is this site.

The original system for this website was custom PERL/PHP loading articles straight from a MySQL database - I would use phpmyadmin as an editor of sorts and all was good, for a time.

In 2005 I wanted more flexibility on what kind of entries I could post. I wanted to move to a format including the main article content, as well as a micro-blogging feed. This lasted for a few years until around 2007-8 when social media started being the outlet for this kind of dribble.

But the move to Drupal was my main choice, it was a compromise between getting things done and having some control over the content. That and I never quite figured out how to get Xaraya to do what I wanted.

One of the things that really bothered me though is that themeing for Drupal is a pain in the butt (ain't nobody got time for that). Back in the day my website used to be both designed and built end-to-end by yours truly. Moving to Drupal had the unintended side-effect of making this too-hard(tm) to do and carry over between upgrades.

Add on top the difficulty of reformatting content and managing comment spam and I'm finally shitted off to do something about it...

Without further ado...

Tada! Here's the new site... pretty, huh?

The site itself is statically generated HTML, driven by a nifty piece of software called Pelican.

Pelican takes a path full of files and converts them from their source format (in this case, Markdown) and generates static html pages from them using templates.

I've been looking at a setup like this for a while, as I've been keen to get my website content in something presentation-agnostic like docbook/markdown for quite a while now. One of my mates has also done this with his website recently, with great success.

Out of the box, Pelican hits 90% of what I want from it.. but to convert the site over I had to write some modules.

URL Redirection

My old site used a horrible URL scheme, generating content at URIs like: /node/###. The way I have the new site uses a much more sensible scheme of /YYYY/SHORTNAME.

That being said, it would be nice to make sure any links on social media or elsewhere pointing to my site (hah), continue to work. Something that Pelican doesn't support.

So the first module hooks each article and looks for a metadata tag oldurl. If present, it will add it to the site's global .htaccess file.

Page media

One thing that seems particularly broken is page media, ie: images or downloads attached to a page. In Pelican's standard model, these files need to be stored in a special folder in your content root called static, where they will be copied into the final output folder. Files copied from this location can be linked to using the standard |filename|blah.jpg tag in Pelican's template engine.

This doesn't make a lot of sense to me, as I'm using my own structure in my content hierachy:

- content/
     - YYYY/ 
          - MMDD_SHORT/
               - *.md
               - (other files)

I'd like to keep the files for each post alongside the post itself. And in case I add new source formats or whatnot later, I don't want to blind copy things either. And I want the |filename|blah.jpg syntax to work too, so Pelican needs to know that there's a file with that name being copied.

This ended up being fairly tricky, at first I wrote a generator plugin to scan the content folders and find any file that wouldn't be picked up by other generators. However this got tricky, because without actually parsing the content alongside it, I wouldn't know where to put the file (eg: ipv6.png on my IPv6 Article should be output to /2013/IPv6/ipv6.png).

Itch: Scratched.

And that's about it. I'm reasonably happy with the way it's turned out. The sites content is now tracked in a git repository, and looks a hell of a lot better (even if the styling is blatently ripped from svbtle).

I'll try and remember to push the two python modules above onto my github, as well as the changes I'm contributing back to core also.

The logo is likely to change, as there's an ongoing discussion about how poor it looks currently - when that's finalised I'll generate some matching busines cards and move onto the next project in the pipeline!

Category: blog

Tags: website

Comments

This is the personal website of Will Dowling, a DevOps Engineer hailing from Perth, Western Australia.

Twitter

I talk shit here sometimes.

GitHub

My terrible code. For free.

LinkedIn

Pay me to write bad code and talk shit for you.

Tumblr

Pretty pictures, rarely my own.

Flickr

Pretty pictures, actually mine.