/[suikacvs]/test/html-webhacc/cc.cgi
Suika

Contents of /test/html-webhacc/cc.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.69 - (hide annotations) (download)
Thu Dec 11 03:22:56 2008 UTC (15 years, 5 months ago) by wakaba
Branch: MAIN
CVS Tags: HEAD
Changes since 1.68: +5 -2 lines
++ ChangeLog	11 Dec 2008 03:20:10 -0000
2008-12-11  Wakaba  <wakaba@suika.fam.cx>

	* error-description-source.en.xml: Added descriptions for errors
	from Regexp::Parser and Regexp::Parser::JavaScript modules.

	* cc.cgi: Added support for JavaScript regular expressions.

++ html/WebHACC/Language/ChangeLog	11 Dec 2008 03:18:54 -0000
2008-12-11  Wakaba  <wakaba@suika.fam.cx>

	* RegExpJS.pm: New module.

++ html/WebHACC/ChangeLog	11 Dec 2008 03:22:42 -0000
2008-12-11  Wakaba  <wakaba@suika.fam.cx>

	* Output.pm (generate_input_section): Added support for JavaScript
	regular expressions.

2008-12-10  Wakaba  <wakaba@suika.fam.cx>

	* Result.pm: Added support for |valueref| parameter of an error.
	|pos_end| should point the (intercharacter) position where the
	highlighted substring ends, not the character before the position,
	otherwise empty substring cannot be represented well.

1 wakaba 1.67 #!/usr/bin/perl
2     # -d:DProf
3 wakaba 1.1 use strict;
4    
5     use lib qw[/home/httpd/html/www/markup/html/whatpm
6 wakaba 1.69 /home/wakaba/work/manakai2/lib
7     /home/httpd/html/regexp/lib
8     ];
9 wakaba 1.1 use CGI::Carp qw[fatalsToBrowser];
10    
11 wakaba 1.53 require WebHACC::Input;
12 wakaba 1.2
13 wakaba 1.35 {
14 wakaba 1.58 require Message::CGI::HTTP;
15 wakaba 1.16 my $http = Message::CGI::HTTP->new;
16 wakaba 1.1
17 wakaba 1.58 require WebHACC::Output;
18     my $out = WebHACC::Output->new;
19     $out->handle (*STDOUT);
20     $out->set_utf8;
21    
22 wakaba 1.16 if ($http->get_meta_variable ('PATH_INFO') ne '/') {
23 wakaba 1.58 $out->http_error (404);
24 wakaba 1.8 exit;
25     }
26 wakaba 1.59
27     ## TODO: We need real conneg support...
28     my $primary_language = 'en';
29     if ($ENV{HTTP_ACCEPT_LANGUAGE} =~ /ja/) {
30     $primary_language = 'ja';
31     }
32     $out->load_text_catalog ($primary_language);
33 wakaba 1.53
34     $out->set_flush;
35 wakaba 1.58 $out->http_header;
36     $out->html_header;
37     $out->unset_flush;
38 wakaba 1.55
39 wakaba 1.61 $out->generate_input_section ($http);
40    
41     my $u = $http->get_parameter ('uri');
42     my $s = $http->get_parameter ('s');
43     if ((not defined $u or not length $u) and
44     (not defined $s or not length $s)) {
45     exit;
46     }
47    
48 wakaba 1.58 require WebHACC::Result;
49 wakaba 1.55 my $result = WebHACC::Result->new;
50 wakaba 1.60 $result->output ($out);
51 wakaba 1.14
52 wakaba 1.60 require WebHACC::Input;
53     my $input = WebHACC::Input->get_document ($http => $result => $out);
54 wakaba 1.54
55 wakaba 1.55 check_and_print ($input => $result => $out);
56    
57 wakaba 1.53 $out->nav_list;
58 wakaba 1.16
59 wakaba 1.53 exit;
60 wakaba 1.35 }
61 wakaba 1.1
62 wakaba 1.53 sub check_and_print ($$$) {
63     my ($input, $result, $out) = @_;
64     my $original_input = $out->input;
65     $out->input ($input);
66 wakaba 1.31
67 wakaba 1.55 $input->generate_info_section ($result);
68    
69 wakaba 1.54 $input->generate_transfer_sections ($result);
70 wakaba 1.31
71 wakaba 1.55 unless (defined $input->{s}) {
72 wakaba 1.62 ## NOTE: This is an error of the implementation.
73     $result->layer_uncertain ('transfer');
74     $result->generate_result_section;
75 wakaba 1.63
76     $out->input ($original_input);
77 wakaba 1.55 return;
78     }
79 wakaba 1.31
80 wakaba 1.53 my $checker_class = {
81     'text/cache-manifest' => 'WebHACC::Language::CacheManifest',
82     'text/css' => 'WebHACC::Language::CSS',
83 wakaba 1.68 'text/x-css-inline' => 'WebHACC::Language::CSSInline',
84 wakaba 1.53 'text/html' => 'WebHACC::Language::HTML',
85 wakaba 1.64 'text/x-h2h' => 'WebHACC::Language::H2H',
86 wakaba 1.69 'text/x-regexp-js' => 'WebHACC::Language::RegExpJS',
87 wakaba 1.53 'text/x-webidl' => 'WebHACC::Language::WebIDL',
88    
89     'text/xml' => 'WebHACC::Language::XML',
90     'application/atom+xml' => 'WebHACC::Language::XML',
91     'application/rss+xml' => 'WebHACC::Language::XML',
92     'image/svg+xml' => 'WebHACC::Language::XML',
93     'application/xhtml+xml' => 'WebHACC::Language::XML',
94     'application/xml' => 'WebHACC::Language::XML',
95     ## TODO: Should we make all XML MIME Types fall
96     ## into this category?
97    
98     ## NOTE: This type has different model from normal XML types.
99     'application/rdf+xml' => 'WebHACC::Language::XML',
100     }->{$input->{media_type}} || 'WebHACC::Language::Default';
101    
102     eval qq{ require $checker_class } or die "$0: Loading $checker_class: $@";
103     my $checker = $checker_class->new;
104     $checker->input ($input);
105     $checker->output ($out);
106     $checker->result ($result);
107    
108     ## TODO: A cache manifest MUST be text/cache-manifest
109     ## TODO: WebIDL media type "text/x-webidl"
110    
111     $checker->generate_syntax_error_section;
112     $checker->generate_source_string_section;
113    
114 wakaba 1.55 my @subdoc;
115 wakaba 1.53 $checker->onsubdoc (sub {
116     push @subdoc, shift;
117     });
118    
119     $checker->generate_structure_dump_section;
120     $checker->generate_structure_error_section;
121     $checker->generate_additional_sections;
122    
123 wakaba 1.34 my $id_prefix = 0;
124 wakaba 1.53 for my $_subinput (@subdoc) {
125 wakaba 1.55 my $subinput = WebHACC::Input::Subdocument->new (++$id_prefix);
126 wakaba 1.53 $subinput->{$_} = $_subinput->{$_} for keys %$_subinput;
127 wakaba 1.34 $subinput->{base_uri} = $subinput->{container_node}->base_uri
128     unless defined $subinput->{base_uri};
129 wakaba 1.55 $subinput->{parent_input} = $input;
130 wakaba 1.34
131 wakaba 1.62 my $subresult = WebHACC::Result->new;
132     $subresult->output ($out);
133     $subresult->parent_result ($result);
134    
135     $subinput->start_section ($subresult);
136     check_and_print ($subinput => $subresult => $out);
137     $subinput->end_section ($subresult);
138 wakaba 1.34 }
139 wakaba 1.53
140 wakaba 1.62 $result->generate_result_section;
141    
142 wakaba 1.53 $out->input ($original_input);
143 wakaba 1.31 } # check_and_print
144    
145 wakaba 1.1 =head1 AUTHOR
146    
147     Wakaba <w@suika.fam.cx>.
148    
149     =head1 LICENSE
150    
151 wakaba 1.35 Copyright 2007-2008 Wakaba <w@suika.fam.cx>
152 wakaba 1.1
153     This library is free software; you can redistribute it
154     and/or modify it under the same terms as Perl itself.
155    
156     =cut
157    
158 wakaba 1.69 ## $Date: 2008/09/17 03:56:43 $

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24