New blog (again)

@public

I've been dithering, ever since Stikkit went offline, what to do about my blog. I was storing the content in stikkit, and filtering it's RSS by the /public/ tag to redisplay on desert-island as a blog feed. Luckily I already had an export system in place.. I just don't like trusting my data entirely to someone elses servers, also being able to reach it when my ISP/Telephone co/lines/router/network is down, is a handy thing.

So yesterday I looked around a bit. Typepad, Wordpress, JoeUser. But failed to even determine my criteria, let alone why I didn't like most of them. Most of these someone-elses-server systems make out like they're communities, with friends systems, with displays of random folkses blog contents on their frontpage, I don't want that. I'd already disgarded Vox for not being browser friendly (and admitting it). I'm a member of LiveJournal already, but the same as above also applies.. not to mention they may go the way of stikkit.

I want a local software, I think, I'd also like to keep using Markdown syntax to write in, since that's what I've already got a heap of, and I like it. I looked at Angerwhale, which is a Catalyst application which supports using text files as articles. I even went to install it, but was put off slightly at the prompt to install another thousand (ok 10) CPAN modules I didn't already have.. And a sysadmin friend claimed it was a pain to manage.

So in the end, here we are again, on a home-made kludge of a system, that may someday support comments, and an actual front page, and some css.. and it may not. I hope I'll add images at least.

It took me 4 hours or so yesterday after work to come up with the current system, it consists of 2 files of code, a template wrapper and a bundle of markdown content files.

This is the main handler:

package Blog::Handler;

use strict;
use warnings;

use Apache2::RequestRec;
use Apache2::Const;
use Text::Markdown 'markdown';
use Path::Class;
use Template;

sub handler 
{
    my $r = shift;

    my $filename = file($r->filename)->basename;

    if(!$filename) {
        print STDERR "No file dropping through\n";
        return DECLINED;
    }

    $filename =~ s/\.html$/\.txt/;
    my $filedir = $r->dir_config('files');
    my $file = dir($filedir, $filename);
    if(!-e $file) {
        print STDERR "Failed to find $file\n";
        return DECLINED;
    }
    my $wrapper = $r->dir_config('wrapper');
    if(!-e $wrapper) {
        print STDERR "Failed to find $wrapper\n";
        return DECLINED;
    }

    my $tt = Template->new({
        ABSOLUTE => 1,
        WRAPPER => $wrapper,
        INCLUDE_PATH => $filedir });

    $r->content_type('text/html');
    $tt->process("$filename") || die $tt->error;

    return OK;

}

1;

Last modified: 2009-01-12T13:40:21

WTF