line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Kwiki::Spork; |
2
|
1
|
|
|
1
|
|
22862
|
use Kwiki::Plugin -Base; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
use Kwiki::Installer -Base; |
4
|
|
|
|
|
|
|
our $VERSION = '0.11'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
const class_id => 'spork'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub register { |
9
|
|
|
|
|
|
|
my $registry = shift; |
10
|
|
|
|
|
|
|
$registry->add(wafl => spork => 'Kwiki::Spork::Wafl'); |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
package Kwiki::Spork::Wafl; |
14
|
|
|
|
|
|
|
use base 'Spoon::Formatter::WaflBlock'; |
15
|
|
|
|
|
|
|
use Cwd; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub to_html { |
18
|
|
|
|
|
|
|
my $text = $self->block_text; |
19
|
|
|
|
|
|
|
$self->make_spork($text); |
20
|
|
|
|
|
|
|
return join '', |
21
|
|
|
|
|
|
|
qq{ \n}, |
22
|
|
|
|
|
|
|
$self->render($text), |
23
|
|
|
|
|
|
|
qq{\n}; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub make_spork { |
27
|
|
|
|
|
|
|
my $home = cwd; |
28
|
|
|
|
|
|
|
my $text = shift; |
29
|
|
|
|
|
|
|
my $page = $self->hub->pages->current; |
30
|
|
|
|
|
|
|
my $spork_dir = io->catdir( |
31
|
|
|
|
|
|
|
$self->hub->spork->plugin_directory, $page->id)->assert; |
32
|
|
|
|
|
|
|
if ((my @x = $spork_dir->all) == 0) { |
33
|
|
|
|
|
|
|
$self->require_spork; |
34
|
|
|
|
|
|
|
chdir $spork_dir; |
35
|
|
|
|
|
|
|
$self->spork_command->new_spork; |
36
|
|
|
|
|
|
|
chdir $home; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
my $slides = io->catfile("$spork_dir", 'Spork.slides'); |
39
|
|
|
|
|
|
|
unless (-f $slides->name and $slides->scalar eq $text) { |
40
|
|
|
|
|
|
|
$self->require_spork; |
41
|
|
|
|
|
|
|
$slides->print($text); |
42
|
|
|
|
|
|
|
$slides->close; |
43
|
|
|
|
|
|
|
chdir $spork_dir; |
44
|
|
|
|
|
|
|
my %env = %ENV; |
45
|
|
|
|
|
|
|
delete $env{GATEWAY_INTERFACE}; #XXX Ugly |
46
|
|
|
|
|
|
|
local %ENV = %env; |
47
|
|
|
|
|
|
|
$self->spork_command->make_spork; |
48
|
|
|
|
|
|
|
chdir $home; |
49
|
|
|
|
|
|
|
my $htaccess = io('template/tt2/spork_htaccess')->scalar; |
50
|
|
|
|
|
|
|
io("$spork_dir/slides/.htaccess")->print($htaccess); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub spork_command { |
55
|
|
|
|
|
|
|
local $main::HUB; #XXX tt2 hack |
56
|
|
|
|
|
|
|
Spork->new->load_hub->command; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub render { |
60
|
|
|
|
|
|
|
my $text = shift; |
61
|
|
|
|
|
|
|
$text =~ s/^\+//gm; |
62
|
|
|
|
|
|
|
$text = join "----\n", grep { |
63
|
|
|
|
|
|
|
/\S/ and not /^\w+:\s+\S+/ |
64
|
|
|
|
|
|
|
} split /^\-{4,}\s*\n/m, $text; |
65
|
|
|
|
|
|
|
$self->hub->template->process('spork_section.html', |
66
|
|
|
|
|
|
|
text => $text, |
67
|
|
|
|
|
|
|
); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
#XXX Something evil is happening and I need this ugly hack. |
71
|
|
|
|
|
|
|
sub require_spork { |
72
|
|
|
|
|
|
|
require Spork; |
73
|
|
|
|
|
|
|
require Spork::Config; |
74
|
|
|
|
|
|
|
require Spork::Hub; |
75
|
|
|
|
|
|
|
require Spork::Command; |
76
|
|
|
|
|
|
|
require Spork::Template::TT2; |
77
|
|
|
|
|
|
|
require Spork::Formatter; |
78
|
|
|
|
|
|
|
require Spork::Slides; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
package Kwiki::Spork; |
82
|
|
|
|
|
|
|
__DATA__ |