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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by wakaba, Sun Jul 15 06:14:30 2007 UTC revision 1.6 by wakaba, Sat Aug 11 13:54:55 2007 UTC
# Line 2  Line 2 
2  use strict;  use strict;
3    
4  use lib qw[/home/httpd/html/www/markup/html/whatpm  use lib qw[/home/httpd/html/www/markup/html/whatpm
5             /home/wakaba/work/manakai/lib             /home/wakaba/work/manakai2/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/;  use Time::HiRes qw/time/;
8    
9  use SuikaWiki::Input::HTTP; ## TODO: Use some better CGI module  use Message::CGI::HTTP;
10    my $http = Message::CGI::HTTP->new;
 my $http = SuikaWiki::Input::HTTP->new;  
11    
12  ## TODO: _charset_  ## TODO: _charset_
13    
14  my @mode = split m#/#, scalar $http->meta_variable ('PATH_INFO'), -1;  my @mode = split m#/#, scalar $http->get_meta_variable ('PATH_INFO'), -1;
15  shift @mode if @mode and $mode[0] == '';  shift @mode if @mode and $mode[0] == '';
16  ## TODO: decode unreserved characters  ## TODO: decode unreserved characters
17    
18    my $s = $http->parameter ('s');    my $s = $http->get_parameter ('s');
19    if (length $s > 1000_000) {    if (length $s > 1000_000) {
20      print STDOUT "Status: 400 Document Too Long\nContent-Type: text/plain; charset=us-ascii\n\nToo long";      print STDOUT "Status: 400 Document Too Long\nContent-Type: text/plain; charset=us-ascii\n\nToo long";
21      exit;      exit;
# Line 120  if (@mode == 3 and $mode[0] eq 'html' an Line 118  if (@mode == 3 and $mode[0] eq 'html' an
118    }    }
119    print STDOUT Encode::encode ('utf-8', $$out);    print STDOUT Encode::encode ('utf-8', $$out);
120    print STDOUT "\n";    print STDOUT "\n";
121    } elsif (@mode == 3 and $mode[0] eq 'h2h' and $mode[1] eq '' and
122             ($mode[2] eq 'html' or $mode[2] eq 'test')) {
123      print STDOUT "Content-Type: text/plain; charset=utf-8\n\n";
124    
125      require Encode;
126      $time1 = time;
127      $s = Encode::decode ('utf-8', $s);
128      $time2 = time;
129      $time{decode} = $time2 - $time1;
130    
131      require Whatpm::H2H;
132      $doc = $dom->create_document;
133      Whatpm::H2H->parse_string ($s => $doc);
134    
135      print "#document\n";
136    
137      my $out;
138      if ($mode[2] eq 'html') {
139        $time1 = time;
140        $out = \( $doc->inner_html );
141        $time2 = time;
142        $time{serialize_xml} = $time2 - $time1;
143      } else { # test
144        $time1 = time;
145        $out = test_serialize ($doc);
146        $time2 = time;
147        $time{serialize_test} = $time2 - $time1;
148      }
149      print STDOUT Encode::encode ('utf-8', $$out);
150      print STDOUT "\n";
151  } else {  } else {
152    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";
153    exit;    exit;
154  }  }
155    
156    if ($http->parameter ('dom5')) {    if ($http->get_parameter ('dom5')) {
157      require Whatpm::ContentChecker;      require Whatpm::ContentChecker;
158      my $onerror = sub {      my $onerror = sub {
159        my %opt = @_;        my %opt = @_;

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.6

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24