Jason Kohles: April 2008 Archives

Back when I still had delusions that I would someday finish writing my own blogging software and get back to blogging, I wrote a little text-formatting library called an Text::Multi which uses a simple system to allow you to switch between multiple types of text filters in one file.

Now that I've given up on ever writing my own blog software, and just settled on Movable Type, I still wanted to be able to use the super-cool code highlighting that is in Text::Multi (which was in turn inspired by the code highlighting in Angerwhale).

To that end, I've written a short, simple Movable Type plugin which lets you use Text::Multi as a markup format. It's a little ugly (and while writing it I've also discovered there are a lot of problems with the documentation in Text::Multi that I'm going to have to clean up) but it works for me...

# JasonKohles::TextMulti plugin
# Copyright 2008 Jason Kohles
# <email@jasonkohles.com>
#  http://www.jasonkohles.com/
#
package JasonKohles::TextMulti;
use strictuse warnings;
our $VERSION = '0.1';
our $ID = '$Id$';
use base qw( MT::Plugin );
use Text::Multi;  

MT->add_plugin( __PACKAGE__->new( { 
    id              => 'textmulti',
    name            => 'TextMulti',
    version         => $VERSION,
    author_name     => 'Jason Kohles',
    author_link     => 'http://www.jasonkohles.com/',
    plugin_link     => 'http://code.jasonkohles.com/MTTextMulti/',
    doc_link        => 'docs.html',
    description     => 'Text::Multi Format Filter',
    registry        => {
        text_filters    => {
            text_multi      => {
                label           => 'Text::Multi',
                docs            => 'docs.html',
                code            => sub {
                    my $parser = Text::Multi->new(
                        default_type => 'Markdown'
                    );
                    $parser->process_text$_[0] );
                    return $parser->render;
                },
            },
        },
    },
} ) );

This is a little script I wrote to be used as a subversion post-commit hook. It automatically emails an encrypted archive of the repository after every commit, so you don't have to worry too much about the subversion server exploding.

#!/bin/sh

# Configuration #
REPODIR=/var/svn # where your repositories live
#export HOME=/home/jason
    # set this to your home directory if the hook
    # doesn't run as you, and therefore cannot find
    # your GPG keys...
EMAIL="example+backups@gmail.com" # where to send the backups
GPGID="12345678" # gpg key id to use for encrypting

REPO="$1"
REV="$2"

echo "Running gmail-backup-svn $REPO $REV"
R=`echo $REPO | sed s,$REPODIR,,`
(
    echo "From: $EMAIL"
    echo "To: $EMAIL"
    echo "Subject: [SVN-BACKUP] $R"
    echo ""
    if [ -n "$REV" ]then echo "Revision: $REV"fi
    for I in `seq 1 40`do echo ""done
    /usr/bin/svnadmin dump $REPO \
    | /bin/gzip -c - \
    | /usr/bin/gpg --armor --trust-model=always --recipient $GPGID --encrypt
) | /usr/sbin/sendmail -oi -oem -odq $EMAIL

About this Archive

This page is a archive of recent entries written by Jason Kohles in April 2008.

Find recent content on the main index or look in the archives to find all content.

Categories

Pages

Creative Commons License
This weblog is licensed under a Creative Commons License.