Parent Directory
|
Revision Log
++ ChangeLog 6 May 2008 08:47:05 -0000 * cc.cgi: Use table object returned by the checker; don't form a table by itself. * table-script.js: Use different coloring for empty data cells. * cc.cgi, table.cgi: Remove table reference for JSON convertion. 2008-05-06 Wakaba <wakaba@suika.fam.cx>
| 1 | wakaba | 1.1 | #!/usr/bin/perl |
| 2 | use strict; | ||
| 3 | |||
| 4 | use lib qw[/home/httpd/html/www/markup/html/whatpm | ||
| 5 | /home/wakaba/public_html/-temp/wiki/lib]; | ||
| 6 | use CGI::Carp qw[fatalsToBrowser]; | ||
| 7 | |||
| 8 | use SuikaWiki::Input::HTTP; ## TODO: Use some better CGI module | ||
| 9 | |||
| 10 | my $http = SuikaWiki::Input::HTTP->new; | ||
| 11 | |||
| 12 | ## TODO: _charset_ | ||
| 13 | |||
| 14 | my $mode = $http->meta_variable ('PATH_INFO'); | ||
| 15 | ## TODO: decode unreserved characters | ||
| 16 | |||
| 17 | if ($mode eq '/table') { | ||
| 18 | require Encode; | ||
| 19 | require Whatpm::HTML; | ||
| 20 | require Whatpm::NanoDOM; | ||
| 21 | |||
| 22 | my $s = $http->parameter ('s'); | ||
| 23 | if (length $s > 1000_000) { | ||
| 24 | print STDOUT "Status: 400 Document Too Long\nContent-Type: text/plain; charset=us-ascii\n\nToo long"; | ||
| 25 | exit; | ||
| 26 | } | ||
| 27 | |||
| 28 | $s = Encode::decode ('utf-8', $s); | ||
| 29 | my $doc = Whatpm::HTML->parse_string | ||
| 30 | ($s => Whatpm::NanoDOM::Document->new); | ||
| 31 | |||
| 32 | my @table_el; | ||
| 33 | my @node = @{$doc->child_nodes}; | ||
| 34 | while (@node) { | ||
| 35 | my $node = shift @node; | ||
| 36 | if ($node->node_type == 1) { | ||
| 37 | if ($node->namespace_uri eq q<http://www.w3.org/1999/xhtml> and | ||
| 38 | $node->manakai_local_name eq 'table') { | ||
| 39 | push @table_el, $node; | ||
| 40 | } | ||
| 41 | } | ||
| 42 | push @node, @{$node->child_nodes}; | ||
| 43 | } | ||
| 44 | |||
| 45 | print STDOUT "Content-Type: text/html; charset=utf-8\n\n"; | ||
| 46 | |||
| 47 | use JSON; | ||
| 48 | require Whatpm::HTMLTable; | ||
| 49 | |||
| 50 | print STDOUT '<!DOCTYPE html> | ||
| 51 | <html lang="en"> | ||
| 52 | <head> | ||
| 53 | <title>HTML5 Table Structure Viewer</title> | ||
| 54 | wakaba | 1.2 | <!--[if IE]><script type="text/javascript" src="../excanvas.js"></script><![endif]--> |
| 55 | wakaba | 1.1 | <script src="../table-script.js" type="text/javascript"></script> |
| 56 | </head> | ||
| 57 | <body> | ||