package Kwiki::Spork;
use Kwiki::Plugin -Base;
use Kwiki::Installer -Base;
our $VERSION = '0.11';

const class_id => 'spork';

sub register {
    my $registry = shift;
    $registry->add(wafl => spork => 'Kwiki::Spork::Wafl');

package Kwiki::Spork::Wafl;
use base 'Spoon::Formatter::WaflBlock';
use Cwd;

sub to_html {
    my $text = $self->block_text;
    return join '',
      qq{<div class="spork">\n},

sub make_spork {
    my $home = cwd;
    my $text = shift;
    my $page = $self->hub->pages->current;
    my $spork_dir = io->catdir(
        $self->hub->spork->plugin_directory, $page->id)->assert;
    if ((my @x = $spork_dir->all) == 0) {
        chdir $spork_dir;        
        chdir $home;
    my $slides = io->catfile("$spork_dir", 'Spork.slides');
    unless (-f $slides->name and $slides->scalar eq $text) {
        chdir $spork_dir;        
        my %env = %ENV;
        delete $env{GATEWAY_INTERFACE}; #XXX Ugly
        local %ENV = %env;
        chdir $home;
        my $htaccess = io('template/tt2/spork_htaccess')->scalar;

sub spork_command {
    local $main::HUB; #XXX tt2 hack

sub render {
    my $text = shift;
    $text =~ s/^\+//gm;
    $text = join "----\n", grep {
        /\S/ and not /^\w+:\s+\S+/
    } split /^\-{4,}\s*\n/m, $text;
        text => $text,

#XXX Something evil is happening and I need this ugly hack.
sub require_spork { 
    require Spork;
    require Spork::Config;
    require Spork::Hub;
    require Spork::Command;
    require Spork::Template::TT2;
    require Spork::Formatter;
    require Spork::Slides;

package Kwiki::Spork;

=head1 NAME 

Kwiki::Spork - Kwiki Spork Plugin



=head1 AUTHOR

Brian Ingerson <>


Copyright (c) 2004. Brian Ingerson. All rights reserved.

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.


Allow from all
<div class="spork">
<a target="spork" href="plugin/spork/[% %]/slides/start.html">Start Spork Slideshow</a>
<hr />
[% hub.formatter.text_to_html(text) %]