1 |
wakaba |
1.1 |
#!/usr/bin/perl |
2 |
|
|
use strict; |
3 |
|
|
use warnings; |
4 |
|
|
use CGI::Carp qw/fatalsToBrowser/; |
5 |
|
|
|
6 |
|
|
use lib qw[/home/wakaba/work/manakai2/lib]; |
7 |
|
|
|
8 |
|
|
use Message::CGI::Util qw/htescape/; |
9 |
|
|
|
10 |
|
|
require Message::CGI::HTTP; |
11 |
|
|
my $cgi = Message::CGI::HTTP->new; |
12 |
|
|
$cgi->{decoder}->{'#default'} = sub { |
13 |
|
|
return Encode::decode ('utf-8', $_[1]); |
14 |
|
|
}; |
15 |
|
|
|
16 |
|
|
my $input = my $input_orig = $cgi->get_parameter ('s'); |
17 |
|
|
my $charset = $cgi->get_parameter ('c') || 'utf-8'; |
18 |
|
|
$input = Encode::encode ($charset, $input); |
19 |
|
|
|
20 |
|
|
print "Content-Type: text/html; charset=utf-8\n\n"; |
21 |
|
|
|
22 |
|
|
my $output = ''; |
23 |
|
|
if (length $input) { |
24 |
|
|
require Template; |
25 |
|
|
my $template = Template->new ({ |
26 |
|
|
INCLUDE_PATH => '/tmp/no-such-directory/', |
27 |
|
|
}); |
28 |
|
|
$template->process (\$input, {}, \$output) or $output = $template->error; |
29 |
|
|
} |
30 |
|
|
|
31 |
|
|
print qq[<!DOCTYPE HTML> |
32 |
|
|
<html lang=en> |
33 |
|
|
<title>TT Viewer</title> |
34 |
|
|
<link rel=stylesheet href="/www/style/html/xhtml"> |
35 |
|
|
<style> |
36 |
|
|
p { |
37 |
|
|
text-indent: 0 !important; |
38 |
|
|
} |
39 |
|
|
|
40 |
|
|
textarea { |
41 |
|
|
height: 10em; |
42 |
|
|
} |
43 |
|
|
|
44 |
|
|
textarea#result { |
45 |
|
|
height: 30em; |
46 |
|
|
} |
47 |
|
|
</style> |
48 |
|
|
|
49 |
|
|
<form action=live method=get accept-charset=utf-8> |
50 |
|
|
|
51 |
|
|
<p><textarea name=s>@{[htescape $input_orig]}</textarea> |
52 |
|
|
|
53 |
|
|
<button type=submit>Process</button></p> |
54 |
|
|
</form> |
55 |
|
|
|
56 |
|
|
<h2>Result</h2> |
57 |
|
|
|
58 |
|
|
<textarea id=result> |
59 |
|
|
Input: |
60 |
|
|
[PRE(code)[ |
61 |
|
|
@{[htescape $input]} |
62 |
|
|
]PRE] |
63 |
|
|
|
64 |
|
|
Result: |
65 |
|
|
[PRE(code)[ |
66 |
|
|
@{[htescape $output]} |
67 |
|
|
]PRE] |
68 |
|
|
|
69 |
|
|
</textarea> |
70 |
|
|
<script> |
71 |
|
|
document.getElementById ('result').value += ';; <' + location.href + '>\\n'; |
72 |
|
|
</script> |
73 |
|
|
|
74 |
|
|
]; |
75 |
|
|
|
76 |
|
|
|