line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Kwiki::HanConvert; |
2
|
1
|
|
|
1
|
|
1207
|
use Kwiki::Plugin -Base; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
use mixin 'Kwiki::Installer'; |
4
|
|
|
|
|
|
|
use Encode::HanConvert qw(simple trad); |
5
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
const class_id => 'han_convert'; |
8
|
|
|
|
|
|
|
const cgi_class => 'Kwiki::HanConvert::CGI'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub register { |
11
|
|
|
|
|
|
|
my $registry = shift; |
12
|
|
|
|
|
|
|
$registry->add(hook => 'display:display', post => 'convert'); |
13
|
|
|
|
|
|
|
$registry->add(toolbar => 'han_convert_button', |
14
|
|
|
|
|
|
|
template => 'han_convert_button.html'); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub convert { |
18
|
|
|
|
|
|
|
my $hook = pop; |
19
|
|
|
|
|
|
|
my $display = $self; |
20
|
|
|
|
|
|
|
$self = $display->hub->load_class('han_convert'); |
21
|
|
|
|
|
|
|
my ($page_content) = $hook->returned; |
22
|
|
|
|
|
|
|
my $ret; |
23
|
|
|
|
|
|
|
if($self->cgi->mode eq 'trad') { |
24
|
|
|
|
|
|
|
$ret = trad($page_content); |
25
|
|
|
|
|
|
|
} elsif($self->cgi->mode eq 'simp') { |
26
|
|
|
|
|
|
|
$ret = simple($page_content); |
27
|
|
|
|
|
|
|
} else { |
28
|
|
|
|
|
|
|
$ret = $page_content; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
return $ret; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
package Kwiki::HanConvert::CGI; |
34
|
|
|
|
|
|
|
use base 'Kwiki::CGI'; |
35
|
|
|
|
|
|
|
cgi mode => qw(-utf8); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
package Kwiki::HanConvert; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
__DATA__ |