/[suikacvs]/markup/html/whatpm/Whatpm/CacheManifest.pod
Suika

Contents of /markup/html/whatpm/Whatpm/CacheManifest.pod

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Sun Nov 4 11:49:44 2007 UTC (18 years, 10 months ago) by wakaba
Branch: MAIN
++ ChangeLog	4 Nov 2007 11:48:54 -0000
2007-11-04  Wakaba  <wakaba@suika.fam.cx>

	* readme.en.html: Link to |Whatpm::CacheManifest|.

++ whatpm/Whatpm/ChangeLog	4 Nov 2007 11:49:27 -0000
	* Makefile: |CacheManifest.html| is added.

	* CacheManifest.pod: New file.

2007-11-04  Wakaba  <wakaba@suika.fam.cx>

1 =head1 NAME
2
3 Whatpm::CacheManifest - An HTML5 Cache Manifest Parser
4
5 =head1 SYNOPSIS
6
7 use Whatpm::CacheManifest;
8
9 my $manifest_uri = q<http://www.example.com/manifest>;
10 my ($manifest_data, $manifest_base_uri)
11 = some_function_to_retrieve_content ($manifest_uri);
12
13 # or,
14
15 my $manifest = Whatpm::CacheManifest->parse_byte_string
16 ($manifest_data, $manifest_uri, $manifest_base_uri, sub {
17 my %err = @_;
18 warn $err{type}, "\n";
19 });
20
21 $manifest_data = Encode::decode ('utf-8', $manifest_data);
22 my $manifest = Whatpm::CacheManifest->parse_char_string
23 ($manifest_data, $manifest_uri, $manifest_base_uri, sub {
24 my %err = @_;
25 warn $err{type}, "\n";
26 });
27
28 # $manifest->[0]: Array reference of explicit URIs.
29 # $manifest->[1]: Hash reference of fallback URIs.
30 # $manifest->[2]: Array reference of online whitelist.
31
32 =head1 DESCRIPTION
33
34 The C<Whatpm::CacheManifest> module implements the parsing algorithm
35 for HTML5 cache manifest format, used to describe an offline Web
36 application.
37
38 =head1 METHODS
39
40 This module provides two class methods to parse cache manifests:
41
42 =over 4
43
44 =item I<$manifest> = Whatpm::CacheManifest->parse_byte_string (I<$manifest_bytes>, I<$manifest_uri>, I<$manifest_base_uri>, I<$onerror>)
45
46 =item I<$manifest> = Whatpm::CacheManifest->parse_char_string (I<$manifest_chars>, I<$manifest_uri>, I<$manifest_base_uri>, I<$onerror>)
47
48 =back
49
50 These methods parse a cache manifest and return that cache manifest
51 in the L<MANIFEST DATA STRUCTURE>.
52
53 Parameters:
54
55 =over 4
56
57 =item I<$manifest_bytes>
58
59 The content of the manifest files, as a Perl byte string.
60 It may or may not be a valid cache manifest. It will be processed
61 as defined by HTML5 cache manifest parsing specification.
62 It will be interpreted as UTF-8 string, as defined in the specification.
63
64 =item I<$manfiest_chars>
65
66 The content of the manifest files, as a Perl character string.
67 It may or may not be a valid cache manifest. It will be processed
68 as defined by HTML5 cache manifest parsing specification. It may
69 contain C<U+0000> C<NULL> characters; they are converted to
70 C<U+FFFD> C<REPLACEMENT CHARACTER>s as defined in the specification.
71
72 =item I<$manifest_uri>
73
74 The IRI of the cache manifest.
75
76 =item I<$manifest_base_uri>
77
78 The base IRI of the cache manifest.
79
80 =item I<$onerror>
81
82 The callback function that will be invoked if the manifest cache
83 has an error (or a warning). It may be omitted. If omitted,
84 any error (or warning) is C<warn>ed with its C<type>.
85
86 @@ TBW
87
88 For the list of the error types, see Whatpm Error Types
89 <http://suika.fam.cx/gate/2005/sw/Whatpm%20Error%20Types>.
90
91 =back
92
93 In addition, a class method to check conformance of cache manifests
94 is provided:
95
96 =over 4
97
98 =item Whatpm::CacheManifest->check_manifest (I<$manifest>, I<$onerror>)
99
100 Check conformance of a cache manifest, given as I<$manifest>.
101
102 =over 4
103
104 =item I<$manifest>
105
106 The cache manifest to check, in the L<MANIFEST DATA STRUCTURE>.
107
108 =item I<$onerror>
109
110
111 The callback function that will be invoked if the manifest cache
112 has an error (or a warning). It may be omitted. If omitted,
113 any error (or warning) is C<warn>ed with its C<type>.
114
115 @@ TBW
116
117 For the list of the error types, see Whatpm Error Types
118 <http://suika.fam.cx/gate/2005/sw/Whatpm%20Error%20Types>.
119
120 =back
121
122 A cache manifest is conforming if (a) it is correctly labeled
123 as a cache manifest (e.g. as Internet media type C<text/cache-manifest>)
124 in the transfer layer, (b) parsing the cache manifest by
125 C<parse_byte_string> or C<parse_char_string> raises no error
126 with level C<m> or C<s>, and (c) checking the cache manifest by
127 C<check_manifest> raises no error with level C<m> or C<s>.
128
129 =back
130
131 =head1 MANIFEST DATA STRUCTURE
132
133 If I<$m> is in manifest data structure, I<$m> is a reference to
134 the array with three items: I<$explicit_uris>, I<$fallback_uris>,
135 and I<$online_whitelist>.
136
137 I<$explicit_uris> is a reference to the array, which
138 contains zero or more strings. The strings are IRI references
139 of the explicit entries.
140
141 I<$fallback_uris> is a reference to the hash, which
142 contains zero or more mappings of strings (keys) to strings (values).
143 The keys are IRI references of the oppotunistic caching namespaces.
144 The values are IRI references of the fallback entries corresponding
145 to the oppotunistic caching namespaces.
146
147 I<$online_whitelist> is a reference to the array, which
148 contains zero or more strings. The strings are IRI references
149 in the online whitelist.
150
151 =head1 DEPENDENCY
152
153 This module depends on L<Message::URI::URIReference>, which is
154 part of manakai.
155
156 =head1 SEE ALSO
157
158 Whatpm Error Types
159 <http://suika.fam.cx/gate/2005/sw/Whatpm%20Error%20Types>.
160
161 HTML5
162 <http://whatwg.org/html5>.
163
164 L<Message::URI::URIReference>
165 <http://suika.fam.cx/www/manakai-core/lib/Message/URI/URIReference.html>.
166
167 =head1 TODO
168
169 "Same scheme/host/port" comparison algorithm is not correctly implemented
170 yet.
171
172 =head1 AUTHOR
173
174 Wakaba <[email protected]>
175
176 =head1 LICENSE
177
178 Copyright 2007 Wakaba <[email protected]>
179
180 This library is free software; you can redistribute it
181 and/or modify it under the same terms as Perl itself.
182
183 =cut
184
185 # $Date: 2007/08/06 10:56:50 $
186

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24