/[suikacvs]/test/html-whatpm/parser-manakai.cgi
Suika

Contents of /test/html-whatpm/parser-manakai.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (hide annotations) (download)
Sun Jul 15 06:14:30 2007 UTC (19 years, 4 months ago) by wakaba
Branch: MAIN
Changes since 1.3: +8 -5 lines
++ ChangeLog	15 Jul 2007 06:14:19 -0000
2007-07-15  Wakaba  <wakaba@suika.fam.cx>

	* parser-manakai.cgi: Set |Document| as HTML if it is.
	Use |inner_html| attribute for inner HTML value.
	XML documents are now serializable via |inner_html|.

1 wakaba 1.3 #!/usr/bin/perl
2 wakaba 1.1 use strict;
3    
4     use lib qw[/home/httpd/html/www/markup/html/whatpm
5     /home/wakaba/work/manakai/lib
6     /home/wakaba/public_html/-temp/wiki/lib];
7     use CGI::Carp qw[fatalsToBrowser];
8     use Time::HiRes qw/time/;
9    
10     use SuikaWiki::Input::HTTP; ## TODO: Use some better CGI module
11    
12     my $http = SuikaWiki::Input::HTTP->new;
13    
14     ## TODO: _charset_
15    
16 wakaba 1.2 my @mode = split m#/#, scalar $http->meta_variable ('PATH_INFO'), -1;
17     shift @mode if @mode and $mode[0] == '';
18 wakaba 1.1 ## TODO: decode unreserved characters
19    
20     my $s = $http->parameter ('s');
21     if (length $s > 1000_000) {
22     print STDOUT "Status: 400 Document Too Long\nContent-Type: text/plain; charset=us-ascii\n\nToo long";
23     exit;
24     }
25     my $char_length = length $s;
26     my %time;
27     my $time1;
28     my $time2;
29    
30     require Message::DOM::DOMImplementation;
31 wakaba 1.4 my $dom = Message::DOM::DOMImplementation->new;
32 wakaba 1.2 # $| = 1;
33 wakaba 1.1 my $doc;
34 wakaba 1.2 my $el;
35 wakaba 1.1
36 wakaba 1.2 if (@mode == 3 and $mode[0] eq 'html' and
37     ($mode[2] eq 'html' or $mode[2] eq 'test')) {
38 wakaba 1.1 print STDOUT "Content-Type: text/plain; charset=utf-8\n\n";
39    
40     require Encode;
41     require Whatpm::HTML;
42    
43     $time1 = time;
44     $s = Encode::decode ('utf-8', $s);
45     $time2 = time;
46     $time{decode} = $time2 - $time1;
47    
48    
49     print STDOUT "#errors\n";
50    
51     my $onerror = sub {
52     my (%opt) = @_;
53     print STDOUT "$opt{line},$opt{column},$opt{type}\n";
54     };
55    
56 wakaba 1.2 $doc = $dom->create_document;