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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.68 - (hide annotations) (download)
Wed Sep 17 03:56:43 2008 UTC (16 years, 2 months ago) by wakaba
Branch: MAIN
Changes since 1.67: +2 -1 lines
++ ChangeLog	17 Sep 2008 03:55:55 -0000
2008-09-17  Wakaba  <wakaba@suika.fam.cx>

	* cc.cgi: Support for |text/x-css-inline| type is added.

2008-09-17  Wakaba  <wakaba@suika.fam.cx>

	* standards.en.html: Updated.

++ html/WebHACC/Language/ChangeLog	17 Sep 2008 03:56:41 -0000
2008-09-17  Wakaba  <wakaba@suika.fam.cx>

	* CSSInline.pm: New module.

++ html/WebHACC/ChangeLog	17 Sep 2008 03:56:25 -0000
2008-09-17  Wakaba  <wakaba@suika.fam.cx>

	* Output.pm: Support for the |text/x-css-inline| type is added.

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24