Parent Directory
|
Revision Log
++ ChangeLog 16 Aug 2008 07:38:01 -0000 * cc-script.js: Support for #index- fragment identifiers. * cc-style.css: Prety styling for reformatted sources. Support for new version of manifest dump sections. * error-description-source.xml: Support for Whatpm::CacheManifest, Whatpm::CSS::SelectorsParser, Whatpm::CSS::MediaQueryParser, and Whatpm::CSS::Parser errors. Support for l10n of cache manifest dump sections. 2008-08-16 Wakaba <wakaba@suika.fam.cx> ++ html/WebHACC/Language/ChangeLog 16 Aug 2008 07:42:17 -0000 * CSS.pm, CacheManifest.pm, HTML.pm, XML.pm: Use ->url attribute to obtain the URL of the document. * CacheManifest.pm (generate_structure_dump_section): It is now i18n'ed. In addition, since URLs are tend to be long, tables for fallback entries are replaced by |dd| entries and paragraphs. "No entry" message is now handled by catalog, rather than CSS. 2008-08-16 Wakaba <wakaba@suika.fam.cx> ++ html/WebHACC/ChangeLog 16 Aug 2008 07:39:54 -0000 * Input.pm (Subdocument new): Invoke superclass's new method such that |urls| attribute is initialized. * Result.pm (add_error): Use ->url attribute to obtain the URL of the document. No longer output |text| argument, since all error types except for those used in the WebIDL module are now defined in the catalog. 2008-08-16 Wakaba <wakaba@suika.fam.cx>
| 1 | package WebHACC::Input; |
| 2 | use strict; |
| 3 | |
| 4 | sub new ($) { |
| 5 | return bless {urls => []}, shift; |
| 6 | } # new |
| 7 | |
| 8 | sub id_prefix ($) { '' } |
| 9 | |
| 10 | sub nested ($) { 0 } |
| 11 | |
| 12 | sub subdocument_index ($) { 0 } |
| 13 | |
| 14 | sub full_subdocument_index ($) { 0 } |
| 15 | |
| 16 | sub url ($) { |
| 17 | my $self = shift; |
| 18 | if (@{$self->{urls}}) { |
| 19 | return $self->{urls}->[-1]; |
| 20 | } else { |
| 21 | return undef; |
| 22 | } |
| 23 | } # url |
| 24 | |
| 25 | sub add_url ($$) { |
| 26 | my ($self, $url) = @_; |
| 27 | push @{$self->{urls}}, ''.$url; |
| 28 | } # add_url |
| 29 | |
| 30 | sub urls ($) { |
| 31 | my $self = shift; |
| 32 | return [@{$self->{urls}}]; |
| 33 | } # urls |
| 34 | |
| 35 | sub get_document ($$$$) { |
| 36 | my $self = shift->new; |
| 37 | |
| 38 | my ($cgi => $result => $out) = @_; |
| 39 | |
| 40 | $out->input ($self); |
| 41 | |
| 42 | require Encode; |
| 43 | my $url_s = Encode::decode ('utf-8', $cgi->get_parameter ('uri')); |
| 44 | my $url_o; |
| 45 | if (defined $url_s and length $url_s) { |
| 46 | require Message::DOM::DOMImplementation; |
| 47 | my $dom = Message::DOM::DOMImplementation->new; |
| 48 | |
| 49 | $url_o = $dom->create_uri_reference ($url_s); |
| 50 | $url_o->uri_fragment (undef); |
| 51 | |
| 52 | $self->add_url ($url_o->uri_reference); |
| 53 | |
| 54 | my $url_scheme = lc $url_o->uri_scheme; ## TODO: html5_url_scheme |
| 55 | my $class = { |
| 56 | http => 'WebHACC::Input::HTTP', |
| 57 | }->{$url_scheme} || 'WebHACC::Input::UnsupportedURLSchemeError'; |
| 58 | bless $self, $class; |
| 59 | } else { |
| 60 | bless $self, 'WebHACC::Input::Text'; |
| 61 | } |
| 62 | |
| 63 | $self->_get_document ($cgi => $result => $out, $url_o); |
| 64 | |
| 65 | return $self unless defined $self->{s}; |
| 66 | |
| 67 | if (length $self->{s} > 1000_000) { |
| 68 | $self->{error_status_text} = 'Entity-body too large'; |
| 69 | delete $self->{s}; |
| 70 | bless $self, 'WebHACC::Input::Error'; |
| 71 | return $self; |
| 72 | } |
| 73 | |
| 74 | require Whatpm::ContentType; |
| 75 | ($self->{official_type}, $self->{media_type}) |
| 76 | = Whatpm::ContentType->get_sniffed_type |
| 77 | (get_file_head => sub { |
| 78 | return substr $self->{s}, 0, shift; |
| 79 | }, |
| 80 | http_content_type_byte => $self->{http_content_type_bytes}, |
| 81 | supported_image_types => {}); |
| 82 | |
| 83 | my $input_format = $cgi->get_parameter ('i'); |
| 84 | if (defined $input_format and lengt |