[Belfast-pm] Kwiki 0.33, MT Version 3.01D, and Plugins

Andrew McFarland andrew.mcfarland.lists at aamcf.co.uk
Wed Nov 3 13:02:11 CST 2004


Hello,

I'm trying to write a plugin for MT. I have two reasons for this:

* I need an MT plugin that lets me use Kwiki formatting, using
   Kwiki 0.33. Marty has a plugin[1] based on 0.18, which I have
   used, but because it is based on an old Kwiki it doesn't add
   closing li tags, which I need. [2]

* I want to learn how to write MT plugins, so even if somebody
   can point me in the direction of SomeoneElsesSolution for the
   above, I'd still appreciate feedback on this.

On www.kwiki.org[4], there is the following one liner for 
Kwiki-formatting a text file:

perl -MKwiki -e 'undef $/; print 
Kwiki->new->load_hub->load_class(q(formatter))->text_to_html(<>)' kwiki.txt

This works on my server, and makes me happy.

Mindlessly hacking at Marty's Kwiki plugin, I come up with the attached 
plugin - which I know could be tidier: I did say my hacking was 
mindless. If I create an entry in MT and select this plugin to do the 
formatting I can preview the entry, and everything has worked. No errors 
are written to the error log. This also makes me happy.

However, when I try to save the entry, MT appears to build everything as 
normal, but it gives me the error message on the screen:

Can't locate object method "database_directory" via package 
"Kwiki::Config" at /usr/local/share/perl/5.8.4/Kwiki/Pages.pm line 128.

This makes me sad.

Can anyone here tell me what I'm doing wrong? I'll ask on the MT forums 
if nobody can help[5], I just want to make sure I'm not doing something 
obviously stupid.

Andrew

[1] http://www.martian.org/marty/archives/000766.html

[2] I need a plugin that will allow me to use Kwiki formatting with 
well-formed lists (which requires Kwiki 0.33, I think), blockquotes, 
line breaks, and possibly footnotes. [3] This will require some messing 
around with Kwiki at some point, but not right now.

[3] So I can use MT to maintain pages like 
http://www.mcfarland.co.uk/andrew/testimony_articles/2004-01-01 and 
http://www.mcfarland.co.uk/andrew/exhortations/2004-05-16. Both of those 
pages are religious, so don't follow those links if you are allergic to 
such things.

[4] http://www.kwiki.org/?KwikiFormatterModule

[5] Because I'm too much of a gentleman to bug Tony, Marty, and Karen 
about this at work.
-------------- next part --------------
#!/usr/bin/perl
# see http://www.kwiki.org/?KwikiFormatterModule

# This doesn't work


package MT::Kwiki;
use Kwiki;
$VERSION = 0.02;
use strict;
use warnings;
use MT;

# TODO: until we know where the wiki is, don't make a link
sub wiki_link_format { $_[1] }

MT->add_text_filter(
  kwiki => {
    label     => 'Andrews Kwiki',
    on_format => sub {Kwiki->new->load_hub->load_class(q(formatter))->text_to_html($_[0])},
    docs      => 'none yet',
  }
);

1;


More information about the Belfast-pm mailing list