/[suikacvs]/test/html-webhacc/WebHACC/Language/CacheManifest.pm
Suika

Contents of /test/html-webhacc/WebHACC/Language/CacheManifest.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Sun Jul 20 14:58:24 2008 UTC (16 years, 11 months ago) by wakaba
Branch: MAIN
++ ChangeLog	20 Jul 2008 14:58:20 -0000
2008-07-20  Wakaba  <wakaba@suika.fam.cx>

	* cc.cgi: Modularized.

	* WebHACC/: New directory.

1 wakaba 1.1 package WebHACC::Language::CacheManifest;
2     use strict;
3     require WebHACC::Language::Base;
4     push our @ISA, 'WebHACC::Langauge::Base';
5    
6     sub new ($) {
7     my $self = bless {}, shift;
8     return $self;
9     } # new
10    
11     sub generate_syntax_error_section ($) {
12     my $self = shift;
13    
14     require Whatpm::CacheManifest;
15    
16     my $out = $self->output;
17    
18     $out->start_section (id => 'parse-errors', title => 'Parse Errors');
19     $out->start_tag ('dl', id => 'parse-errors-list');
20    
21     my $input = $self->input;
22     my $result = $self->result;
23    
24     my $onerror = sub {
25     my (%opt) = @_;
26     my ($type, $cls, $msg) = get_text ($opt{type}, $opt{level});
27     $out->html (qq[<dt class="$cls">], get_error_label ($input, \%opt));
28     $type =~ tr/ /-/;
29     $type =~ s/\|/%7C/g;
30     $msg .= qq[ [<a href="../error-description#@{[htescape ($type)]}">Description</a>]];
31     $out->html (qq[<dd class="$cls">], get_error_level_label (\%opt) . $msg);
32    
33     add_error ('syntax', \%opt => $result);
34     };
35    
36     my $m = $input->{is_char_string} ? 'parse_char_string' : 'parse_byte_string';
37     $self->{structure} = Whatpm::CacheManifest->$m
38     ($input->{s}, $input->{uri}, $input->{base_uri}, $onerror);
39    
40     $out->end_tag ('dl');
41     $out->end_section;
42     } # generate_syntax_error_section
43    
44     sub generate_structure_dump_section ($) {
45     my $self = shift;
46     my $manifest = $self->{structure};
47    
48     $self->start_section (id => 'dump-manifest', title => 'Cache Manifest');
49    
50     $self->html (qq[<dl><dt>Explicit entries</dt>]);
51     my $i = 0;
52     for my $uri (@{$manifest->[0]}) {
53     $out->start_tag ('dd', id => 'index-' . $i++);
54     $out->url ($uri);
55     }
56    
57     $out->html (qq[<dt>Fallback entries</dt><dd>
58     <table><thead><tr><th scope=row>Oppotunistic Caching Namespace</th>
59     <th scope=row>Fallback Entry</tr><tbody>]);
60     for my $uri (sort {$a cmp $b} keys %{$manifest->[1]}) {
61     $out->start_tag ('tr');
62    
63     $out->start_tag ('td', id => 'index-' . $i++);
64     $out->url ($uri);
65    
66     $out->start_tag ('td', id => 'index-' . $i++);
67     $out->url ($manifest->[1]->{$uri});
68     }
69    
70     $out->html (qq[</table><dt>Online whitelist</dt>]);
71     for my $uri (@{$manifest->[2]}) {
72     $out->start_tag ('dd', id => 'index-' . $i++);
73     $out->url ($uri);
74     }
75    
76     $out->end_section;
77     } # generate_structure_dump_section
78    
79     sub generate_structure_error_section ($) {
80     my $self = shift;
81    
82     my $out = $self->output;
83    
84     $out->start_section (id => 'document-errors', title => 'Document Errors');
85     $out->start_tag ('dl');
86    
87     my $result = $out->result;
88    
89     Whatpm::CacheManifest->check_manifest ($self->{structure}, sub {
90     my %opt = @_;
91     my ($type, $cls, $msg) = get_text ($opt{type}, $opt{level}, $opt{node});
92     $type =~ tr/ /-/;
93     $type =~ s/\|/%7C/g;
94     $msg .= qq[ [<a href="../error-description#@{[htescape ($type)]}">Description</a>]];
95     $out->html (qq[<dt class="$cls">] . get_error_label ($input, \%opt) .
96     qq[</dt>\n<dd class="$cls">], $msg, "</dd>\n");
97     add_error ('structure', \%opt => $result);
98     });
99    
100     $out->end_section;
101     } # generate_structure_error_section
102    
103     sub source_charset ($) {
104     return 'utf-8';
105     } # source_charset
106    
107     1;

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24