/[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 - (show annotations) (download)
Thu Dec 11 03:22:56 2008 UTC (15 years, 11 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 #!/usr/bin/perl
2 # -d:DProf
3 use strict;
4
5 use lib qw[/home/httpd/html/www/markup/html/whatpm
6 /home/wakaba/work/manakai2/lib
7 /home/httpd/html/regexp/lib
8 ];
9 use CGI::Carp qw[fatalsToBrowser];
10
11 require WebHACC::Input;
12
13 {
14 require Message::CGI::HTTP;
15 my $http = Message::CGI::HTTP->new;
16
17 require WebHACC::Output;
18 my $out = WebHACC::Output->new;
19 $out->handle (*STDOUT);
20 $out->set_utf8;
21
22 if ($http->get_meta_variable ('PATH_INFO') ne '/') {
23 $out->http_error (404);
24 exit;
25 }
26
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
34 $out->set_flush;
35 $out->http_header;
36 $out->html_header;
37 $out->unset_flush;
38
39 $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 require WebHACC::Result;
49 my $result = WebHACC::Result->new;
50 $result->output ($out);
51
52 require WebHACC::Input;
53 my $input = WebHACC::Input->get_document ($http => $result => $out);
54
55 check_and_print ($input => $result => $out);
56
57 $out->nav_list;
58
59 exit;
60 }
61
62 sub check_and_print ($$$) {
63 my ($input, $result, $out) = @_;
64 my $original_input = $out->input;
65 $out->input ($input);
66
67 $input->generate_info_section ($result);
68
69 $input->generate_transfer_sections ($result);
70
71 unless (defined $input->{s}) {
72 ## NOTE: This is an error of the implementation.
73 $result->layer_uncertain ('transfer');
74 $result->generate_result_section;
75
76 $out->input ($original_input);
77 return;
78 }
79
80 my $checker_class = {
81 'text/cache-manifest' => 'WebHACC::Language::CacheManifest',
82 'text/css' => 'WebHACC::Language::CSS',
83 'text/x-css-inline' => 'WebHACC::Language::CSSInline',
84 'text/html' => 'WebHACC::Language::HTML',
85 'text/x-h2h' => 'WebHACC::Language::H2H',
86 'text/x-regexp-js' => 'WebHACC::Language::RegExpJS',
87 '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 my @subdoc;
115 $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 my $id_prefix = 0;
124 for my $_subinput (@subdoc) {
125 my $subinput = WebHACC::Input::Subdocument->new (++$id_prefix);
126 $subinput->{$_} = $_subinput->{$_} for keys %$_subinput;
127 $subinput->{base_uri} = $subinput->{container_node}->base_uri
128 unless defined $subinput->{base_uri};
129 $subinput->{parent_input} = $input;
130
131 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 }
139
140 $result->generate_result_section;
141
142 $out->input ($original_input);
143 } # check_and_print
144
145 =head1 AUTHOR
146
147 Wakaba <w@suika.fam.cx>.
148
149 =head1 LICENSE
150
151 Copyright 2007-2008 Wakaba <w@suika.fam.cx>
152
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 ## $Date: 2008/09/17 03:56:43 $

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24