| 4 |
use lib qw[/home/httpd/html/www/markup/html/whatpm |
use lib qw[/home/httpd/html/www/markup/html/whatpm |
| 5 |
/home/wakaba/public_html/-temp/wiki/lib]; |
/home/wakaba/public_html/-temp/wiki/lib]; |
| 6 |
use CGI::Carp qw[fatalsToBrowser]; |
use CGI::Carp qw[fatalsToBrowser]; |
| 7 |
|
use Time::HiRes qw/time/; |
| 8 |
|
|
| 9 |
use SuikaWiki::Input::HTTP; ## TODO: Use some better CGI module |
use SuikaWiki::Input::HTTP; ## TODO: Use some better CGI module |
| 10 |
|
|
| 26 |
exit; |
exit; |
| 27 |
} |
} |
| 28 |
|
|
| 29 |
|
my $time1 = time; |
| 30 |
$s = Encode::decode ('utf-8', $s); |
$s = Encode::decode ('utf-8', $s); |
| 31 |
|
my $time2 = time; |
| 32 |
|
my %time = (decode => $time2 - $time1); |
| 33 |
|
|
| 34 |
print STDOUT "Content-Type: text/plain; charset=utf-8\n\n"; |
print STDOUT "Content-Type: text/plain; charset=utf-8\n\n"; |
| 35 |
|
|
| 36 |
print STDOUT "#errors\n"; |
print STDOUT "#errors\n"; |
| 40 |
print STDOUT "$opt{line},$opt{column},$opt{type}\n"; |
print STDOUT "$opt{line},$opt{column},$opt{type}\n"; |
| 41 |
}; |
}; |
| 42 |
|
|
| 43 |
|
$time1 = time; |
| 44 |
my $doc = Whatpm::HTML->parse_string |
my $doc = Whatpm::HTML->parse_string |
| 45 |
($s => Whatpm::NanoDOM::Document->new, $onerror); |
($s => Whatpm::NanoDOM::Document->new, $onerror); |
| 46 |
|
$time2 = time; |
| 47 |
|
$time{parse} = $time2 - $time1; |
| 48 |
|
|
| 49 |
print "#document\n"; |
print "#document\n"; |
| 50 |
|
|
| 51 |
my $out; |
my $out; |
| 52 |
|
$time1 = time; |
| 53 |
if ($mode eq '/html') { |
if ($mode eq '/html') { |
| 54 |
$out = Whatpm::HTML->get_inner_html ($doc); |
$out = Whatpm::HTML->get_inner_html ($doc); |
| 55 |
} else { # test |
} else { # test |
| 56 |
$out = test_serialize ($doc); |
$out = test_serialize ($doc); |
| 57 |
} |
} |
| 58 |
|
$time2 = time; |
| 59 |
|
$time{serialize} = $time2 - $time1; |
| 60 |
print STDOUT Encode::encode ('utf-8', $$out); |
print STDOUT Encode::encode ('utf-8', $$out); |
| 61 |
print STDOUT "\n"; |
print STDOUT "\n"; |
| 62 |
|
|
| 63 |
if ($http->parameter ('dom5')) { |
if ($http->parameter ('dom5')) { |
| 64 |
require Whatpm::ContentChecker; |
require Whatpm::ContentChecker; |
| 65 |
print STDOUT "#domerrors\n"; |
print STDOUT "#domerrors\n"; |
| 66 |
my $docel = $doc->document_element; |
$time1 = time; |
| 67 |
my $docel_nsuri = $docel->namespace_uri; |
Whatpm::ContentChecker->check_document ($doc, sub { |
|
if (defined $docel_nsuri and |
|
|
$docel_nsuri eq q<http://www.w3.org/1999/xhtml> and |
|
|
$docel->manakai_local_name eq 'html') { |
|
|
# |
|
|
} else { |
|
|
print STDOUT get_node_path ($docel) . ";element not allowed\n"; |
|
|
} |
|
|
my $cc = Whatpm::ContentChecker->new; |
|
|
$cc->check_element ($docel, sub { |
|
| 68 |
my %opt = @_; |
my %opt = @_; |
| 69 |
print STDOUT get_node_path ($opt{node}) . ';' . $opt{type} . "\n"; |
print STDOUT get_node_path ($opt{node}) . ';' . $opt{type} . "\n"; |
| 70 |
}); |
}); |
| 71 |
|
$time2 = time; |
| 72 |
|
$time{check} = $time2 - $time1; |
| 73 |
} |
} |
| 74 |
|
|
| 75 |
|
print STDOUT "#log\n"; |
| 76 |
|
print STDOUT "byte->char\t", $time{decode}, "s\n"; |
| 77 |
|
print STDOUT "html5->dom5\t", $time{parse}, "s\n"; |
| 78 |
|
print STDOUT "dom5->serialize\t", $time{serialize}, "s\n"; |
| 79 |
|
print STDOUT "dom5 check\t", $time{check}, "s\n" if defined $time{check}; |
| 80 |
} else { |
} else { |
| 81 |
print STDOUT "Status: 404 Not Found\nContent-Type: text/plain; charset=us-ascii\n\n404"; |
print STDOUT "Status: 404 Not Found\nContent-Type: text/plain; charset=us-ascii\n\n404"; |
| 82 |
} |
} |