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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.62 - (show annotations) (download)
Thu Aug 14 15:50:42 2008 UTC (16 years, 3 months ago) by wakaba
Branch: MAIN
Changes since 1.61: +13 -9 lines
++ ChangeLog	14 Aug 2008 15:42:17 -0000
	* cc.cgi: Generate result summary sections for
	each subdocument.

	* error-description-source.xml: New entries to
	support localization of result sections.

2008-08-14  Wakaba  <wakaba@suika.fam.cx>

	* cc-style.css: Support for revised version of result summary
	section styling.

2008-08-14  Wakaba  <wakaba@suika.fam.cx>

++ html/WebHACC/Language/ChangeLog	14 Aug 2008 15:50:38 -0000
	* Base.pm, CSS.pm, CacheManifest.pm, DOM.pm, Default.pm,
	HTML.pm, WebIDL.pm, XML.pm: Set |layer_applicable|
	or |layer_uncertain| flag appropriately.

2008-08-14  Wakaba  <wakaba@suika.fam.cx>

++ html/WebHACC/ChangeLog	14 Aug 2008 15:48:38 -0000
	* Input.pm: Methods |generate_transfer_sections|
	and |generate_http_header_section| are moved to HTTP
	subclass, since they are irrelevant to non-HTTP inputs.
	(_get_document): Forbidden host error was not represented
	by WebHACC::Input::Error subclass.
	(WebHACC::Input::Error generate_transfer_sections): Use
	role name for the section.
	(WebHACC::Input::HTTPError generate_transfer_sections): New method
	added, since the main superclass, i.e. WebHACC::Input::Error,
	no longer dumps HTTP headers due to the change mentioned above.

	* Output.pm (start_section): New roles "transfer-errors" and "result".

	* Result.pm (parent_result): New attribute.
	(layer_applicable, layer_uncertain): New methods to set flags.
	(add_error): Natural language strings are now handled
	by the catalog mechanism.  Use new scoring mechanism.
	(generate_result_section): Use catalog for all natural
	language strings.  Table generation is now much more sophiscated
	that it was.  Support for subdoc result summary.  Support
	for the column of the number of informational message.  Support
	for "N/A" status.

2008-08-14  Wakaba  <wakaba@suika.fam.cx>

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24