1 |
wakaba |
1.1 |
package WebHACC::Language::CacheManifest; |
2 |
|
|
use strict; |
3 |
|
|
require WebHACC::Language::Base; |
4 |
wakaba |
1.4 |
push our @ISA, 'WebHACC::Language::Base'; |
5 |
wakaba |
1.1 |
|
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 |
wakaba |
1.3 |
$out->start_section (role => 'parse-errors'); |
19 |
|
|
$out->start_error_list (role => 'parse-errors'); |
20 |
wakaba |
1.1 |
|
21 |
|
|
my $input = $self->input; |
22 |
|
|
my $result = $self->result; |
23 |
|
|
|
24 |
|
|
my $m = $input->{is_char_string} ? 'parse_char_string' : 'parse_byte_string'; |
25 |
|
|
$self->{structure} = Whatpm::CacheManifest->$m |
26 |
wakaba |
1.2 |
($input->{s}, $input->{uri}, $input->{base_uri}, sub { |
27 |
|
|
$result->add_error (@_, layer => 'syntax', index_has_link => 1); |
28 |
|
|
}); |
29 |
wakaba |
1.3 |
|
30 |
|
|
$out->end_error_list (role => 'parse-errors'); |
31 |
wakaba |
1.1 |
$out->end_section; |
32 |
|
|
} # generate_syntax_error_section |
33 |
|
|
|
34 |
|
|
sub generate_structure_dump_section ($) { |
35 |
|
|
my $self = shift; |
36 |
|
|
my $manifest = $self->{structure}; |
37 |
|
|
|
38 |
wakaba |
1.4 |
my $out = $self->output; |
39 |
|
|
|
40 |
|
|
$out->start_section (role => 'structure'); |
41 |
wakaba |
1.1 |
|
42 |
wakaba |
1.4 |
$out->html (qq[<dl><dt>Explicit entries</dt>]); |
43 |
wakaba |
1.1 |
my $i = 0; |
44 |
|
|
for my $uri (@{$manifest->[0]}) { |
45 |
|
|
$out->start_tag ('dd', id => 'index-' . $i++); |
46 |
|
|
$out->url ($uri); |
47 |
|
|
} |
48 |
|
|
|
49 |
|
|
$out->html (qq[<dt>Fallback entries</dt><dd> |
50 |
|
|
<table><thead><tr><th scope=row>Oppotunistic Caching Namespace</th> |
51 |
|
|
<th scope=row>Fallback Entry</tr><tbody>]); |
52 |
|
|
for my $uri (sort {$a cmp $b} keys %{$manifest->[1]}) { |
53 |
|
|
$out->start_tag ('tr'); |
54 |
|
|
|
55 |
|
|
$out->start_tag ('td', id => 'index-' . $i++); |
56 |
|
|
$out->url ($uri); |
57 |
|
|
|
58 |
|
|
$out->start_tag ('td', id => 'index-' . $i++); |
59 |
|
|
$out->url ($manifest->[1]->{$uri}); |
60 |
|
|
} |
61 |
|
|
|
62 |
|
|
$out->html (qq[</table><dt>Online whitelist</dt>]); |
63 |
|
|
for my $uri (@{$manifest->[2]}) { |
64 |
|
|
$out->start_tag ('dd', id => 'index-' . $i++); |
65 |
|
|
$out->url ($uri); |
66 |
|
|
} |
67 |
|
|
|
68 |
|
|
$out->end_section; |
69 |
|
|
} # generate_structure_dump_section |
70 |
|
|
|
71 |
|
|
sub generate_structure_error_section ($) { |
72 |
|
|
my $self = shift; |
73 |
|
|
|
74 |
|
|
my $out = $self->output; |
75 |
|
|
|
76 |
wakaba |
1.3 |
$out->start_section (role => 'structure-errors'); |
77 |
|
|
$out->start_error_list (role => 'structure-errors'); |
78 |
wakaba |
1.1 |
|
79 |
wakaba |
1.4 |
my $result = $self->result; |
80 |
wakaba |
1.1 |
|
81 |
|
|
Whatpm::CacheManifest->check_manifest ($self->{structure}, sub { |
82 |
wakaba |
1.2 |
$result->add_error (@_, layer => 'structure'); |
83 |
wakaba |
1.1 |
}); |
84 |
|
|
|
85 |
wakaba |
1.3 |
$out->end_error_list; |
86 |
wakaba |
1.1 |
$out->end_section; |
87 |
|
|
} # generate_structure_error_section |
88 |
|
|
|
89 |
|
|
sub source_charset ($) { |
90 |
|
|
return 'utf-8'; |
91 |
|
|
} # source_charset |
92 |
|
|
|
93 |
|
|
1; |