line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package YUI::Loader; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
4
|
|
|
4
|
|
325079
|
$YUI::Loader::VERSION = '0.071'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
# ABSTRACT: Load (and cache) the Yahoo JavaScript YUI framework |
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
41
|
use warnings; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
123
|
|
8
|
4
|
|
|
4
|
|
21
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
151
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
4
|
|
|
4
|
|
23
|
use constant LATEST_YUI_VERSION => "2.8.1"; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
301
|
|
12
|
|
|
|
|
|
|
|
13
|
4
|
|
|
4
|
|
7663
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use YUI::Loader::Carp; |
16
|
|
|
|
|
|
|
use YUI::Loader::Catalog; |
17
|
|
|
|
|
|
|
use HTML::Declare qw/LINK SCRIPT/; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has catalog => qw/is ro required 1 isa YUI::Loader::Catalog lazy 1/, default => sub { shift->source->catalog }; |
20
|
|
|
|
|
|
|
has manifest => qw/is ro required 1 isa YUI::Loader::Manifest lazy 1/, handles => [qw/include exclude clear select parse schedule/], default => sub { |
21
|
|
|
|
|
|
|
my $self = shift; |
22
|
|
|
|
|
|
|
require YUI::Loader::Manifest; |
23
|
|
|
|
|
|
|
return YUI::Loader::Manifest->new(catalog => $self->catalog, loader => $self); |
24
|
|
|
|
|
|
|
}; |
25
|
|
|
|
|
|
|
has list => qw/is ro required 1 isa YUI::Loader::List lazy 1/, default => sub { |
26
|
|
|
|
|
|
|
my $self = shift; |
27
|
|
|
|
|
|
|
require YUI::Loader::List; |
28
|
|
|
|
|
|
|
return YUI::Loader::List->new(loader => $self); |
29
|
|
|
|
|
|
|
}; |
30
|
|
|
|
|
|
|
has source => qw/is ro required 1 isa YUI::Loader::Source/; |
31
|
|
|
|
|
|
|
has cache => qw/is ro isa YUI::Loader::Cache/; |
32
|
|
|
|
|
|
|
has filter => qw/is rw isa Str/, default => ""; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub new_from_yui_host { |
37
|
|
|
|
|
|
|
return shift->new_from_internet(@_); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub new_from_internet { |
41
|
|
|
|
|
|
|
my $class = shift; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my ($given, $catalog) = $class->_new_given_catalog(@_); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
my %source; |
46
|
|
|
|
|
|
|
$source{version} = delete $given->{version} if exists $given->{version}; |
47
|
|
|
|
|
|
|
$source{base} = delete $given->{base} if exists $given->{base}; |
48
|
|
|
|
|
|
|
require YUI::Loader::Source::Internet; |
49
|
|
|
|
|
|
|
my $source = YUI::Loader::Source::Internet->new(catalog => $catalog, %source); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
return $class->_new_finish($given, $source); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub new_from_yui_dir { |
56
|
|
|
|
|
|
|
my $class = shift; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my ($given, $catalog) = $class->_new_given_catalog(@_); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my %source; |
61
|
|
|
|
|
|
|
$source{version} = delete $given->{version} if exists $given->{version}; |
62
|
|
|
|
|
|
|
$source{base} = delete $given->{base} if exists $given->{base}; |
63
|
|
|
|
|
|
|
$source{dir} = delete $given->{dir} if exists $given->{dir}; |
64
|
|
|
|
|
|
|
require YUI::Loader::Source::YUIDir; |
65
|
|
|
|
|
|
|
my $source = YUI::Loader::Source::YUIDir->new(catalog => $catalog, %source); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
return $class->_new_finish($given, $source); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub new_from_uri { |
72
|
|
|
|
|
|
|
my $class = shift; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
my ($given, $catalog) = $class->_new_given_catalog(@_); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
my %source; |
77
|
|
|
|
|
|
|
$source{base} = delete $given->{base} if exists $given->{base}; |
78
|
|
|
|
|
|
|
require YUI::Loader::Source::URI; |
79
|
|
|
|
|
|
|
my $source = YUI::Loader::Source::URI->new(catalog => $catalog, %source); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
return $class->_new_finish($given, $source); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub new_from_dir { |
86
|
|
|
|
|
|
|
my $class = shift; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
my ($given, $catalog) = $class->_new_given_catalog(@_); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
my %source; |
91
|
|
|
|
|
|
|
$source{base} = delete $given->{base} if exists $given->{base}; |
92
|
|
|
|
|
|
|
$source{dir} = delete $given->{dir} if exists $given->{dir}; |
93
|
|
|
|
|
|
|
require YUI::Loader::Source::Dir; |
94
|
|
|
|
|
|
|
my $source = YUI::Loader::Source::Dir->new(catalog => $catalog, %source); |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
return $class->_new_finish($given, $source); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub filter_min { |
102
|
|
|
|
|
|
|
my $self = shift; |
103
|
|
|
|
|
|
|
return $self->filter("min"); |
104
|
|
|
|
|
|
|
return $self; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub filter_debug { |
109
|
|
|
|
|
|
|
my $self = shift; |
110
|
|
|
|
|
|
|
$self->filter("debug"); |
111
|
|
|
|
|
|
|
return $self; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub no_filter { |
116
|
|
|
|
|
|
|
my $self = shift; |
117
|
|
|
|
|
|
|
$self->filter(""); |
118
|
|
|
|
|
|
|
return $self; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub uri { |
123
|
|
|
|
|
|
|
my $self = shift; |
124
|
|
|
|
|
|
|
return $self->cache_uri(@_) if $self->cache; |
125
|
|
|
|
|
|
|
return $self->source_uri(@_); |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub file { |
130
|
|
|
|
|
|
|
my $self = shift; |
131
|
|
|
|
|
|
|
return $self->cache_file(@_) if $self->cache; |
132
|
|
|
|
|
|
|
return $self->source_file(@_); |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub cache_uri { |
137
|
|
|
|
|
|
|
my $self = shift; |
138
|
|
|
|
|
|
|
my $name = shift; |
139
|
|
|
|
|
|
|
return $self->cache->uri([ $name => $self->filter ]) || croak "Unable to get uri for $name from cache ", $self->cache; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub cache_file { |
144
|
|
|
|
|
|
|
my $self = shift; |
145
|
|
|
|
|
|
|
my $name = shift; |
146
|
|
|
|
|
|
|
return $self->cache->file([ $name => $self->filter ]) || croak "Unable to get file for $name from cache ", $self->cache; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub source_uri { |
151
|
|
|
|
|
|
|
my $self = shift; |
152
|
|
|
|
|
|
|
my $name = shift; |
153
|
|
|
|
|
|
|
return $self->source->uri([ $name => $self->filter ]) || croak "Unable to get uri for $name from source ", $self->source; |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub source_file { |
158
|
|
|
|
|
|
|
my $self = shift; |
159
|
|
|
|
|
|
|
my $name = shift; |
160
|
|
|
|
|
|
|
return $self->source->file([ $name => $self->filter ]) || croak "Unable to get file for $name from source ", $self->source; |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub item { |
165
|
|
|
|
|
|
|
my $self = shift; |
166
|
|
|
|
|
|
|
my $name = shift; |
167
|
|
|
|
|
|
|
return $self->catalog->item([ $name => $self->filter ]); |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
sub item_path { |
172
|
|
|
|
|
|
|
my $self = shift; |
173
|
|
|
|
|
|
|
my $name = shift; |
174
|
|
|
|
|
|
|
return $self->item($name)->path; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub item_file { |
179
|
|
|
|
|
|
|
my $self = shift; |
180
|
|
|
|
|
|
|
my $name = shift; |
181
|
|
|
|
|
|
|
return $self->item($name)->file; |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
sub name_list { |
185
|
|
|
|
|
|
|
my $self = shift; |
186
|
|
|
|
|
|
|
return $self->manifest->schedule; |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
sub _html { |
190
|
|
|
|
|
|
|
my $self = shift; |
191
|
|
|
|
|
|
|
my $uri_list = shift; |
192
|
|
|
|
|
|
|
my $separator = shift || "\n"; |
193
|
|
|
|
|
|
|
my @uri_list = $self->list->uri; |
194
|
|
|
|
|
|
|
my @html; |
195
|
|
|
|
|
|
|
for my $uri (@uri_list) { |
196
|
|
|
|
|
|
|
if ($uri =~ m/\.css/) { |
197
|
|
|
|
|
|
|
push @html, LINK({ rel => "stylesheet", type => "text/css", href => $uri }); |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
else { |
200
|
|
|
|
|
|
|
push @html, SCRIPT({ type => "text/javascript", src => $uri, _ => "" }); |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
return join $separator, @html; |
204
|
|
|
|
|
|
|
} |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
sub html { |
208
|
|
|
|
|
|
|
my $self = shift; |
209
|
|
|
|
|
|
|
return $self->_html([ $self->list->uri ], @_); |
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
sub source_html { |
214
|
|
|
|
|
|
|
my $self = shift; |
215
|
|
|
|
|
|
|
return $self->_html([ $self->list->source_uri ], @_); |
216
|
|
|
|
|
|
|
} |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
sub _new_given { |
219
|
|
|
|
|
|
|
my $class = shift; |
220
|
|
|
|
|
|
|
return @_ == 1 && ref $_[0] eq "HASH" ? shift : { @_ }; |
221
|
|
|
|
|
|
|
} |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
sub _new_catalog { |
224
|
|
|
|
|
|
|
my $class = shift; |
225
|
|
|
|
|
|
|
my $given = shift; |
226
|
|
|
|
|
|
|
my $catalog = delete $given->{catalog} || {}; |
227
|
|
|
|
|
|
|
return $given->{catalog} = $catalog if blessed $catalog; |
228
|
|
|
|
|
|
|
return $given->{catalog} = YUI::Loader::Catalog->new(%$catalog); |
229
|
|
|
|
|
|
|
} |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
sub _build_cache { |
232
|
|
|
|
|
|
|
my $class = shift; |
233
|
|
|
|
|
|
|
my $given = shift; |
234
|
|
|
|
|
|
|
my $source = shift; |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
my (%cache, $cache_class); |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
if (ref $given eq "ARRAY") { |
239
|
|
|
|
|
|
|
$cache_class = "YUI::Loader::Cache::URI"; |
240
|
|
|
|
|
|
|
my ($uri, $dir) = @$given; |
241
|
|
|
|
|
|
|
%cache = (uri => $uri, dir => $dir); |
242
|
|
|
|
|
|
|
} |
243
|
|
|
|
|
|
|
elsif (ref $given eq "HASH") { |
244
|
|
|
|
|
|
|
$cache_class = "YUI::Loader::Cache::URI"; |
245
|
|
|
|
|
|
|
my ($uri, $dir) = @$given{qw/uri dir/}; |
246
|
|
|
|
|
|
|
%cache = (uri => $uri, dir => $dir); |
247
|
|
|
|
|
|
|
} |
248
|
|
|
|
|
|
|
elsif (ref $given eq "Path::Resource") { |
249
|
|
|
|
|
|
|
$cache_class = "YUI::Loader::Cache::URI"; |
250
|
|
|
|
|
|
|
%cache = (uri => $given->uri, dir => $given->dir); |
251
|
|
|
|
|
|
|
} |
252
|
|
|
|
|
|
|
else { |
253
|
|
|
|
|
|
|
$cache_class = "YUI::Loader::Cache::Dir"; |
254
|
|
|
|
|
|
|
%cache = (dir => $given); |
255
|
|
|
|
|
|
|
} |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
eval "require $cache_class;" or die $@; |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
return $cache_class->new(source => $source, %cache); |
260
|
|
|
|
|
|
|
} |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
sub _new_cache { |
263
|
|
|
|
|
|
|
my $class = shift; |
264
|
|
|
|
|
|
|
my $given = shift; |
265
|
|
|
|
|
|
|
my $source = shift; |
266
|
|
|
|
|
|
|
if (my $cache = delete $given->{cache}) { |
267
|
|
|
|
|
|
|
$given->{cache} = $class->_build_cache($cache, $source); |
268
|
|
|
|
|
|
|
} |
269
|
|
|
|
|
|
|
} |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
sub _new_given_catalog { |
272
|
|
|
|
|
|
|
my $class = shift; |
273
|
|
|
|
|
|
|
my $given = $class->_new_given(@_); |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
my $catalog = $class->_new_catalog($given); |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
return ($given, $catalog); |
278
|
|
|
|
|
|
|
} |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
sub _new_finish { |
281
|
|
|
|
|
|
|
my $class = shift; |
282
|
|
|
|
|
|
|
my $given = shift; |
283
|
|
|
|
|
|
|
my $source = shift; |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
$class->_new_cache($given, $source); |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
return $class->new(%$given, source => $source); |
288
|
|
|
|
|
|
|
} |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
1; |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
__END__ |
295
|
|
|
|
|
|
|
=pod |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
=head1 NAME |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
YUI::Loader - Load (and cache) the Yahoo JavaScript YUI framework |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
=head1 VERSION |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
version 0.071 |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
=head1 SYNOPSIS |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
use YUI::Loader; |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
my $loader = YUI::Loader->new_from_yui_host; |
310
|
|
|
|
|
|
|
$loader->include->yuitest->reset->fonts->base; |
311
|
|
|
|
|
|
|
print $loader->html; |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
# The above will yield: |
314
|
|
|
|
|
|
|
# <link rel="stylesheet" href="http://yui.yahooapis.com/2.5.1/build/reset/reset.css" type="text/css"/> |
315
|
|
|
|
|
|
|
# <link rel="stylesheet" href="http://yui.yahooapis.com/2.5.1/build/fonts/fonts.css" type="text/css"/> |
316
|
|
|
|
|
|
|
# <link rel="stylesheet" href="http://yui.yahooapis.com/2.5.1/build/base/base.css" type="text/css"/> |
317
|
|
|
|
|
|
|
# <script src="http://yui.yahooapis.com/2.5.1/build/yahoo/yahoo.js" type="text/javascript"></script> |
318
|
|
|
|
|
|
|
# <script src="http://yui.yahooapis.com/2.5.1/build/dom/dom.js" type="text/javascript"></script> |
319
|
|
|
|
|
|
|
# <script src="http://yui.yahooapis.com/2.5.1/build/event/event.js" type="text/javascript"></script> |
320
|
|
|
|
|
|
|
# <script src="http://yui.yahooapis.com/2.5.1/build/logger/logger.js" type="text/javascript"></script> |
321
|
|
|
|
|
|
|
# <script src="http://yui.yahooapis.com/2.5.1/build/yuitest/yuitest.js" type="text/javascript"></script> |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
You can also cache YUI locally: |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
my $loader = YUI::Loader->new_from_yui_host(cache => { dir => "htdocs/assets", uri => "http://example.com/assets" }); |
326
|
|
|
|
|
|
|
$loader->include->yuitest->reset->fonts->base; |
327
|
|
|
|
|
|
|
print $loader->html; |
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
# The above will yield: |
330
|
|
|
|
|
|
|
# <link rel="stylesheet" href="http://example.com/assets/reset.css" type="text/css"/> |
331
|
|
|
|
|
|
|
# <link rel="stylesheet" href="http://example.com/assets/fonts.css" type="text/css"/> |
332
|
|
|
|
|
|
|
# <link rel="stylesheet" href="http://example.com/assets/base.css" type="text/css"/> |
333
|
|
|
|
|
|
|
# <script src="http://example.com/assets/yahoo.js" type="text/javascript"></script> |
334
|
|
|
|
|
|
|
# <script src="http://example.com/assets/dom.js" type="text/javascript"></script> |
335
|
|
|
|
|
|
|
# <script src="http://example.com/assets/event.js" type="text/javascript"></script> |
336
|
|
|
|
|
|
|
# <script src="http://example.com/assets/logger.js" type="text/javascript"></script> |
337
|
|
|
|
|
|
|
# <script src="http://example.com/assets/yuitest.js" type="text/javascript"></script> |
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
=head1 DESCRIPTION |
340
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
YUI::Loader is a tool for loading YUI assets within your application. Loader will either provide the URI/HTML to access http://yui.yahooapis.com directly, |
342
|
|
|
|
|
|
|
or you can cache assets locally or serve them from an exploded yui_x.x.x.zip dir. |
343
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
=head1 METHODS |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
=head2 YUI::Loader->new_from_yui_host([ base => <base>, version => <version> ]) |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
=head2 YUI::Loader->new_from_internet([ base => <base>, version => <version> ]) |
349
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
Return a new YUI::Loader object configured to fetch and/or serve assets from http://yui.yahooapis.com/<version> |
351
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
=head2 YUI::Loader->new_from_yui_dir([ dir => <dir>, version => <version> ]) |
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
Return a new YUI::Loader object configured to fetch/serve assets from a local, exploded yui_x.x.x.zip dir |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
As an example, for a dir of C<./assets>, the C<reset.css> asset should be available as: |
357
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
./assets/reset/reset.css |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
=head2 YUI::Loader->new_from_uri([ base => <base> ]) |
361
|
|
|
|
|
|
|
|
362
|
|
|
|
|
|
|
Return a new YUI::Loader object configured to serve assets from an arbitrary uri |
363
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
As an example, for a base of C<http://example.com/assets>, the C<reset.css> asset should be available as: |
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
http://example.com/assets/reset.css |
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
=head2 YUI::Loader->new_from_dir([ dir => <dir> ]) |
369
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
Return a new YUI::Loader object configured to serve assets from an arbitrary dir |
371
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
As an example, for a dir of C<./assets>, the C<reset.css> asset should be available as: |
373
|
|
|
|
|
|
|
|
374
|
|
|
|
|
|
|
./assets/reset.css |
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
=head2 select( <component>, <component>, ..., <component> ) |
377
|
|
|
|
|
|
|
|
378
|
|
|
|
|
|
|
Include each <component> in the "manifest" for the loader. |
379
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
A <component> should correspond to an entry in the C<YUI component catalog> (see below) |
381
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
=head2 include |
383
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
Returns a chainable component selector that will include what is called |
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
You can use the methods of the selector to choose components to include. See C<YUI component catalog> below |
387
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
You can return to the loader by using the special ->then method: |
389
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
$loader->include->reset->yuilogger->grids->fonts->then->html; |
391
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
=head2 exclude |
393
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
Returns a chainable component selector that will exclude what is called |
395
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
You can use the methods of the selector to choose components to include. See C<YUI component catalog> below |
397
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
You can return to the loader by using the special ->then method: |
399
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
$loader->exclude->yuilogger->then->html; |
401
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
=head2 filter_min |
403
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
Turn on the -min filter for all included components |
405
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
For example: |
407
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
connection-min.js |
409
|
|
|
|
|
|
|
yuilogger-min.js |
410
|
|
|
|
|
|
|
base-min.css |
411
|
|
|
|
|
|
|
fonts-min.css |
412
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
=head2 filter_debug |
414
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
Turn on the -debug filter for all included components |
416
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
For example: |
418
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
connection-debug.js |
420
|
|
|
|
|
|
|
yuilogger-debug.js |
421
|
|
|
|
|
|
|
base-debug.css |
422
|
|
|
|
|
|
|
fonts-debug.css |
423
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
=head2 no_filter |
425
|
|
|
|
|
|
|
|
426
|
|
|
|
|
|
|
Disable filtering of included components |
427
|
|
|
|
|
|
|
|
428
|
|
|
|
|
|
|
For example: |
429
|
|
|
|
|
|
|
|
430
|
|
|
|
|
|
|
connection.js |
431
|
|
|
|
|
|
|
yuilogger.js |
432
|
|
|
|
|
|
|
base.css |
433
|
|
|
|
|
|
|
fonts.css |
434
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
=head2 uri( <component> ) |
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
Attempt to fetch a L<URI> for <component> using the current filter setting of the loader (-min, -debug, etc.) |
438
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
If the loader has a cache, then this method will try to fetch from the cache. Otherwise it will use the source. |
440
|
|
|
|
|
|
|
|
441
|
|
|
|
|
|
|
=head2 file( <component> ) |
442
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
Attempt to fetch a L<Path::Class::File> for <component> using the current filter setting of the loader (-min, -debug, etc.) |
444
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
If the loader has a cache, then this method will try to fetch from the cache. Otherwise it will use the source. |
446
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
=head2 cache_uri( <component> ) |
448
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
Attempt to fetch a L<URI> for <component> using the current filter setting of the loader (-min, -debug, etc.) from the cache |
450
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
=head2 cache_file( <component> ) |
452
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
Attempt to fetch a L<Path::Class::File> for <component> using the current filter setting of the loader (-min, -debug, etc.) from the cache |
454
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
=head2 source_uri( <component> ) |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
Attempt to fetch a L<URI> for <component> using the current filter setting of the loader (-min, -debug, etc.) from the source |
458
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
=head2 source_file( <component> ) |
460
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
Attempt to fetch a L<Path::Class::File> for <component> using the current filter setting of the loader (-min, -debug, etc.) from the source |
462
|
|
|
|
|
|
|
|
463
|
|
|
|
|
|
|
=head2 item( <component> ) |
464
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
Return a L<YUI::Loader::Item> for <component> using the current filter setting of the loader (-min, -debug, etc.) |
466
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
=head2 item_path( <component> ) |
468
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
Return the item path for <component> using the current filter setting of the loader (-min, -debug, etc.) |
470
|
|
|
|
|
|
|
|
471
|
|
|
|
|
|
|
=head2 item_file( <component> ) |
472
|
|
|
|
|
|
|
|
473
|
|
|
|
|
|
|
Return the item file for <component> using the current filter setting of the loader (-min, -debug, etc.) |
474
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
=head2 html |
476
|
|
|
|
|
|
|
|
477
|
|
|
|
|
|
|
Generate and return a string containing HTML describing how to include components. For example, you can use this in the <head> section |
478
|
|
|
|
|
|
|
of a web page. |
479
|
|
|
|
|
|
|
|
480
|
|
|
|
|
|
|
If the loader has a cache, then it will attempt to generate URIs from the cache, otherwise it will use the source. |
481
|
|
|
|
|
|
|
|
482
|
|
|
|
|
|
|
Here is an example: |
483
|
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
<link rel="stylesheet" href="http://example.com/assets/reset.css" type="text/css"/> |
485
|
|
|
|
|
|
|
<link rel="stylesheet" href="http://example.com/assets/fonts.css" type="text/css"/> |
486
|
|
|
|
|
|
|
<link rel="stylesheet" href="http://example.com/assets/base.css" type="text/css"/> |
487
|
|
|
|
|
|
|
<script src="http://example.com/assets/yahoo.js" type="text/javascript"></script> |
488
|
|
|
|
|
|
|
<script src="http://example.com/assets/dom.js" type="text/javascript"></script> |
489
|
|
|
|
|
|
|
<script src="http://example.com/assets/event.js" type="text/javascript"></script> |
490
|
|
|
|
|
|
|
<script src="http://example.com/assets/logger.js" type="text/javascript"></script> |
491
|
|
|
|
|
|
|
<script src="http://example.com/assets/yuitest.js" type="text/javascript"></script> |
492
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
=head2 source_html |
494
|
|
|
|
|
|
|
|
495
|
|
|
|
|
|
|
Generate and return a string containing HTML describing how to include components. For example, you can use this in the <head> section |
496
|
|
|
|
|
|
|
of a web page. |
497
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
Here is an example: |
499
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
<link rel="stylesheet" href="http://example.com/assets/reset.css" type="text/css"/> |
501
|
|
|
|
|
|
|
<link rel="stylesheet" href="http://example.com/assets/fonts.css" type="text/css"/> |
502
|
|
|
|
|
|
|
<link rel="stylesheet" href="http://example.com/assets/base.css" type="text/css"/> |
503
|
|
|
|
|
|
|
<script src="http://example.com/assets/yahoo.js" type="text/javascript"></script> |
504
|
|
|
|
|
|
|
<script src="http://example.com/assets/dom.js" type="text/javascript"></script> |
505
|
|
|
|
|
|
|
<script src="http://example.com/assets/event.js" type="text/javascript"></script> |
506
|
|
|
|
|
|
|
<script src="http://example.com/assets/logger.js" type="text/javascript"></script> |
507
|
|
|
|
|
|
|
<script src="http://example.com/assets/yuitest.js" type="text/javascript"></script> |
508
|
|
|
|
|
|
|
|
509
|
|
|
|
|
|
|
=head1 YUI component catalog |
510
|
|
|
|
|
|
|
|
511
|
|
|
|
|
|
|
=head2 animation |
512
|
|
|
|
|
|
|
|
513
|
|
|
|
|
|
|
Animation Utility (utility) |
514
|
|
|
|
|
|
|
|
515
|
|
|
|
|
|
|
=head2 autocomplete |
516
|
|
|
|
|
|
|
|
517
|
|
|
|
|
|
|
AutoComplete Control (widget) |
518
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
=head2 base |
520
|
|
|
|
|
|
|
|
521
|
|
|
|
|
|
|
Base CSS Package (css) |
522
|
|
|
|
|
|
|
|
523
|
|
|
|
|
|
|
=head2 button |
524
|
|
|
|
|
|
|
|
525
|
|
|
|
|
|
|
Button Control (widget) |
526
|
|
|
|
|
|
|
|
527
|
|
|
|
|
|
|
=head2 calendar |
528
|
|
|
|
|
|
|
|
529
|
|
|
|
|
|
|
Calendar Control (widget) |
530
|
|
|
|
|
|
|
|
531
|
|
|
|
|
|
|
=head2 charts |
532
|
|
|
|
|
|
|
|
533
|
|
|
|
|
|
|
Charts Control (widget) |
534
|
|
|
|
|
|
|
|
535
|
|
|
|
|
|
|
=head2 colorpicker |
536
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
Color Picker Control (widget) |
538
|
|
|
|
|
|
|
|
539
|
|
|
|
|
|
|
=head2 connection |
540
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
Connection Manager (utility) |
542
|
|
|
|
|
|
|
|
543
|
|
|
|
|
|
|
=head2 container |
544
|
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
Container Family (widget) |
546
|
|
|
|
|
|
|
|
547
|
|
|
|
|
|
|
=head2 containercore |
548
|
|
|
|
|
|
|
|
549
|
|
|
|
|
|
|
Container Core (Module, Overlay) (widget) |
550
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
=head2 cookie |
552
|
|
|
|
|
|
|
|
553
|
|
|
|
|
|
|
Cookie Utility (utility) |
554
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
=head2 datasource |
556
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
DataSource Utility (utility) |
558
|
|
|
|
|
|
|
|
559
|
|
|
|
|
|
|
=head2 datatable |
560
|
|
|
|
|
|
|
|
561
|
|
|
|
|
|
|
DataTable Control (widget) |
562
|
|
|
|
|
|
|
|
563
|
|
|
|
|
|
|
=head2 dom |
564
|
|
|
|
|
|
|
|
565
|
|
|
|
|
|
|
Dom Collection (core) |
566
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
=head2 dragdrop |
568
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
Drag & Drop Utility (utility) |
570
|
|
|
|
|
|
|
|
571
|
|
|
|
|
|
|
=head2 editor |
572
|
|
|
|
|
|
|
|
573
|
|
|
|
|
|
|
Rich Text Editor (widget) |
574
|
|
|
|
|
|
|
|
575
|
|
|
|
|
|
|
=head2 element |
576
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
Element Utility (utility) |
578
|
|
|
|
|
|
|
|
579
|
|
|
|
|
|
|
=head2 event |
580
|
|
|
|
|
|
|
|
581
|
|
|
|
|
|
|
Event Utility (core) |
582
|
|
|
|
|
|
|
|
583
|
|
|
|
|
|
|
=head2 fonts |
584
|
|
|
|
|
|
|
|
585
|
|
|
|
|
|
|
Fonts CSS Package (css) |
586
|
|
|
|
|
|
|
|
587
|
|
|
|
|
|
|
=head2 get |
588
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
Get Utility (utility) |
590
|
|
|
|
|
|
|
|
591
|
|
|
|
|
|
|
=head2 grids |
592
|
|
|
|
|
|
|
|
593
|
|
|
|
|
|
|
Grids CSS Package (css) |
594
|
|
|
|
|
|
|
|
595
|
|
|
|
|
|
|
=head2 history |
596
|
|
|
|
|
|
|
|
597
|
|
|
|
|
|
|
Browser History Manager (utility) |
598
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
=head2 imagecropper |
600
|
|
|
|
|
|
|
|
601
|
|
|
|
|
|
|
ImageCropper Control (widget) |
602
|
|
|
|
|
|
|
|
603
|
|
|
|
|
|
|
=head2 imageloader |
604
|
|
|
|
|
|
|
|
605
|
|
|
|
|
|
|
ImageLoader Utility (utility) |
606
|
|
|
|
|
|
|
|
607
|
|
|
|
|
|
|
=head2 json |
608
|
|
|
|
|
|
|
|
609
|
|
|
|
|
|
|
JSON Utility (utility) |
610
|
|
|
|
|
|
|
|
611
|
|
|
|
|
|
|
=head2 layout |
612
|
|
|
|
|
|
|
|
613
|
|
|
|
|
|
|
Layout Manager (widget) |
614
|
|
|
|
|
|
|
|
615
|
|
|
|
|
|
|
=head2 logger |
616
|
|
|
|
|
|
|
|
617
|
|
|
|
|
|
|
Logger Control (tool) |
618
|
|
|
|
|
|
|
|
619
|
|
|
|
|
|
|
=head2 menu |
620
|
|
|
|
|
|
|
|
621
|
|
|
|
|
|
|
Menu Control (widget) |
622
|
|
|
|
|
|
|
|
623
|
|
|
|
|
|
|
=head2 profiler |
624
|
|
|
|
|
|
|
|
625
|
|
|
|
|
|
|
Profiler (tool) |
626
|
|
|
|
|
|
|
|
627
|
|
|
|
|
|
|
=head2 profilerviewer |
628
|
|
|
|
|
|
|
|
629
|
|
|
|
|
|
|
ProfilerViewer Control (tool) |
630
|
|
|
|
|
|
|
|
631
|
|
|
|
|
|
|
=head2 reset |
632
|
|
|
|
|
|
|
|
633
|
|
|
|
|
|
|
Reset CSS Package (css) |
634
|
|
|
|
|
|
|
|
635
|
|
|
|
|
|
|
=head2 reset_fonts |
636
|
|
|
|
|
|
|
|
637
|
|
|
|
|
|
|
=head2 reset_fonts_grids |
638
|
|
|
|
|
|
|
|
639
|
|
|
|
|
|
|
=head2 resize |
640
|
|
|
|
|
|
|
|
641
|
|
|
|
|
|
|
Resize Utility (utility) |
642
|
|
|
|
|
|
|
|
643
|
|
|
|
|
|
|
=head2 selector |
644
|
|
|
|
|
|
|
|
645
|
|
|
|
|
|
|
Selector Utility (utility) |
646
|
|
|
|
|
|
|
|
647
|
|
|
|
|
|
|
=head2 simpleeditor |
648
|
|
|
|
|
|
|
|
649
|
|
|
|
|
|
|
Simple Editor (widget) |
650
|
|
|
|
|
|
|
|
651
|
|
|
|
|
|
|
=head2 slider |
652
|
|
|
|
|
|
|
|
653
|
|
|
|
|
|
|
Slider Control (widget) |
654
|
|
|
|
|
|
|
|
655
|
|
|
|
|
|
|
=head2 tabview |
656
|
|
|
|
|
|
|
|
657
|
|
|
|
|
|
|
TabView Control (widget) |
658
|
|
|
|
|
|
|
|
659
|
|
|
|
|
|
|
=head2 treeview |
660
|
|
|
|
|
|
|
|
661
|
|
|
|
|
|
|
TreeView Control (widget) |
662
|
|
|
|
|
|
|
|
663
|
|
|
|
|
|
|
=head2 uploader |
664
|
|
|
|
|
|
|
|
665
|
|
|
|
|
|
|
Uploader (widget) |
666
|
|
|
|
|
|
|
|
667
|
|
|
|
|
|
|
=head2 utilities |
668
|
|
|
|
|
|
|
|
669
|
|
|
|
|
|
|
=head2 yahoo |
670
|
|
|
|
|
|
|
|
671
|
|
|
|
|
|
|
Yahoo Global Object (core) |
672
|
|
|
|
|
|
|
|
673
|
|
|
|
|
|
|
=head2 yahoo_dom_event |
674
|
|
|
|
|
|
|
|
675
|
|
|
|
|
|
|
=head2 yuiloader |
676
|
|
|
|
|
|
|
|
677
|
|
|
|
|
|
|
Loader Utility (utility) |
678
|
|
|
|
|
|
|
|
679
|
|
|
|
|
|
|
=head2 yuiloader_dom_event |
680
|
|
|
|
|
|
|
|
681
|
|
|
|
|
|
|
=head2 yuitest |
682
|
|
|
|
|
|
|
|
683
|
|
|
|
|
|
|
YUI Test Utility (tool) |
684
|
|
|
|
|
|
|
|
685
|
|
|
|
|
|
|
=head1 SEE ALSO |
686
|
|
|
|
|
|
|
|
687
|
|
|
|
|
|
|
L<http://developer.yahoo.com/yui/> |
688
|
|
|
|
|
|
|
|
689
|
|
|
|
|
|
|
L<http://developer.yahoo.com/yui/yuiloader/> |
690
|
|
|
|
|
|
|
|
691
|
|
|
|
|
|
|
L<JS::jQuery::Loader> |
692
|
|
|
|
|
|
|
|
693
|
|
|
|
|
|
|
=head1 AUTHOR |
694
|
|
|
|
|
|
|
|
695
|
|
|
|
|
|
|
Robert Krimen <robertkrimen@gmail.com> |
696
|
|
|
|
|
|
|
|
697
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
698
|
|
|
|
|
|
|
|
699
|
|
|
|
|
|
|
This software is copyright (c) 2010 by Robert Krimen. |
700
|
|
|
|
|
|
|
|
701
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
702
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
703
|
|
|
|
|
|
|
|
704
|
|
|
|
|
|
|
=cut |
705
|
|
|
|
|
|
|
|