line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Plugin::KwikiFormat; |
2
|
4
|
|
|
4
|
|
303432
|
use strict; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
172
|
|
3
|
4
|
|
|
4
|
|
35
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
131
|
|
4
|
4
|
|
|
4
|
|
2332
|
use Kwiki; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use Kwiki::Formatter; |
6
|
|
|
|
|
|
|
use base 'Template::Plugin'; |
7
|
|
|
|
|
|
|
use vars qw($VERSION $FILTER_NAME); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
$VERSION = '1.04'; |
10
|
|
|
|
|
|
|
$FILTER_NAME = 'kwiki'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
|
|
|
|
|
|
my ($self, $context, @args) = @_; |
14
|
|
|
|
|
|
|
my $name = $args[0] || $FILTER_NAME; |
15
|
|
|
|
|
|
|
$context->define_filter($name, \&kwiki, 0); |
16
|
|
|
|
|
|
|
return $self; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use constant USE_CLASS_COMPLIENT => Kwiki->VERSION < 0.38; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $kwiki; |
22
|
|
|
|
|
|
|
if (USE_CLASS_COMPLIENT) { |
23
|
|
|
|
|
|
|
$kwiki = Kwiki->new; |
24
|
|
|
|
|
|
|
$kwiki->load_hub({formatter_class => 'Kwiki::Formatter' }); |
25
|
|
|
|
|
|
|
$kwiki->use_class('formatter'); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
else { |
28
|
|
|
|
|
|
|
$kwiki = Kwiki::Formatter->new; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub kwiki { |
32
|
|
|
|
|
|
|
my $text=shift; |
33
|
|
|
|
|
|
|
return USE_CLASS_COMPLIENT |
34
|
|
|
|
|
|
|
? $kwiki->formatter->text_to_html($text) |
35
|
|
|
|
|
|
|
: $kwiki->text_to_html($text); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
{ |
39
|
|
|
|
|
|
|
no warnings; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub Kwiki::Formatter::ForcedLink::pattern_start { |
42
|
|
|
|
|
|
|
return qr/\[([\w\s\/\.\-]+)\]/; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
sub Kwiki::Formatter::ForcedLink::html { |
45
|
|
|
|
|
|
|
my $self=shift; |
46
|
|
|
|
|
|
|
my $text = $self->escape_html($self->matched); |
47
|
|
|
|
|
|
|
$text=~s/\[|\]//g; |
48
|
|
|
|
|
|
|
my @text=split(/\s+/,$text); |
49
|
|
|
|
|
|
|
my ($target,@title); |
50
|
|
|
|
|
|
|
foreach my $frag (@text) { |
51
|
|
|
|
|
|
|
if ($frag=~m{^\w+://}) { |
52
|
|
|
|
|
|
|
$target=$frag; |
53
|
|
|
|
|
|
|
} elsif ($frag=~m{^/}) { |
54
|
|
|
|
|
|
|
$target=$frag; |
55
|
|
|
|
|
|
|
} else { |
56
|
|
|
|
|
|
|
push(@title,$frag); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
my $title=join(' ',@title); |
60
|
|
|
|
|
|
|
return $title unless $target; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
$title = $target unless $title =~ /\S/; |
63
|
|
|
|
|
|
|
return qq($title); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub Kwiki::Formatter::WikiLink::html { |
67
|
|
|
|
|
|
|
my $self=shift; |
68
|
|
|
|
|
|
|
return $self->matched |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub Kwiki::Formatter::TitledWikiLink::html { |
72
|
|
|
|
|
|
|
my $self=shift; |
73
|
|
|
|
|
|
|
return $self->matched |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__END__ |