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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.60 - (show annotations) (download)
Sat Jul 26 11:27:25 2008 UTC (16 years, 4 months ago) by wakaba
Branch: MAIN
Changes since 1.59: +4 -191 lines
++ ChangeLog	26 Jul 2008 11:26:00 -0000
2008-07-26  Wakaba  <wakaba@suika.fam.cx>

	* cc.cgi: get_input_document function is now handled
	by WebHACC::Input classes.  |cc-script| reference
	is now generated by |html_header| in WebHACC::Output.

	* error-description-source.xml: Document URL and Request URL
	are now just "URLs".

++ html/WebHACC/ChangeLog	26 Jul 2008 11:27:20 -0000
2008-07-26  Wakaba  <wakaba@suika.fam.cx>

	* Input.pod: New.

	* Input.pm (urls, url, add_url): New.  Originally handled
	as |$input->{uri}| and |$input->{request_uri}|.
	(get_document and related methods/classes): New.  Originally
	part of |cc.cgi|.

	* Output.pm (html_header): Link to |cc-script.js|.

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 require WebHACC::Result;
37 my $result = WebHACC::Result->new;
38 $result->{conforming_min} = 1;
39 $result->{conforming_max} = 1;
40 $result->output ($out);
41
42 require WebHACC::Input;
43 my $input = WebHACC::Input->get_document ($http => $result => $out);
44
45 check_and_print ($input => $result => $out);
46
47 $result->generate_result_section;
48
49 $out->nav_list;
50
51 exit;
52 }
53
54 sub check_and_print ($$$) {
55 my ($input, $result, $out) = @_;
56 my $original_input = $out->input;
57 $out->input ($input);
58
59 $input->generate_info_section ($result);
60
61 $input->generate_transfer_sections ($result);
62
63 unless (defined $input->{s}) {
64 $result->{conforming_min} = 0;
65 return;
66 }
67
68 my $checker_class = {
69 'text/cache-manifest' => 'WebHACC::Language::CacheManifest',
70 'text/css' => 'WebHACC::Language::CSS',
71 'text/html' => 'WebHACC::Language::HTML',
72 'text/x-webidl' => 'WebHACC::Language::WebIDL',
73
74 'text/xml' => 'WebHACC::Language::XML',
75 'application/atom+xml' => 'WebHACC::Language::XML',
76 'application/rss+xml' => 'WebHACC::Language::XML',
77 'image/svg+xml' => 'WebHACC::Language::XML',
78 'application/xhtml+xml' => 'WebHACC::Language::XML',
79 'application/xml' => 'WebHACC::Language::XML',
80 ## TODO: Should we make all XML MIME Types fall
81 ## into this category?
82
83 ## NOTE: This type has different model from normal XML types.
84 'application/rdf+xml' => 'WebHACC::Language::XML',
85 }->{$input->{media_type}} || 'WebHACC::Language::Default';
86
87 eval qq{ require $checker_class } or die "$0: Loading $checker_class: $@";
88 my $checker = $checker_class->new;
89 $checker->input ($input);
90 $checker->output ($out);
91 $checker->result ($result);
92
93 ## TODO: A cache manifest MUST be text/cache-manifest
94 ## TODO: WebIDL media type "text/x-webidl"
95
96 $checker->generate_syntax_error_section;
97 $checker->generate_source_string_section;
98
99 my @subdoc;
100 $checker->onsubdoc (sub {
101 push @subdoc, shift;
102 });
103
104 $checker->generate_structure_dump_section;
105 $checker->generate_structure_error_section;
106 $checker->generate_additional_sections;
107
108 my $id_prefix = 0;
109 for my $_subinput (@subdoc) {
110 my $subinput = WebHACC::Input::Subdocument->new (++$id_prefix);
111 $subinput->{$_} = $_subinput->{$_} for keys %$_subinput;
112 $subinput->{base_uri} = $subinput->{container_node}->base_uri
113 unless defined $subinput->{base_uri};
114 $subinput->{parent_input} = $input;
115
116 $subinput->start_section ($result);
117 check_and_print ($subinput => $result => $out);
118 $subinput->end_section ($result);
119 }
120
121 $out->input ($original_input);
122 } # check_and_print
123
124 =head1 AUTHOR
125
126 Wakaba <w@suika.fam.cx>.
127
128 =head1 LICENSE
129
130 Copyright 2007-2008 Wakaba <w@suika.fam.cx>
131
132 This library is free software; you can redistribute it
133 and/or modify it under the same terms as Perl itself.
134
135 =cut
136
137 ## $Date: 2008/07/21 12:56:33 $

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24