forked from robertkrimen/YUI-Loader
/
README
356 lines (253 loc) · 10.6 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
NAME
YUI::Loader - Load (and cache) the Yahoo JavaScript YUI framework
VERSION
version 0.071
SYNOPSIS
use YUI::Loader;
my $loader = YUI::Loader->new_from_yui_host;
$loader->include->yuitest->reset->fonts->base;
print $loader->html;
# The above will yield:
# <link rel="stylesheet" href="http://yui.yahooapis.com/2.5.1/build/reset/reset.css" type="text/css"/>
# <link rel="stylesheet" href="http://yui.yahooapis.com/2.5.1/build/fonts/fonts.css" type="text/css"/>
# <link rel="stylesheet" href="http://yui.yahooapis.com/2.5.1/build/base/base.css" type="text/css"/>
# <script src="http://yui.yahooapis.com/2.5.1/build/yahoo/yahoo.js" type="text/javascript"></script>
# <script src="http://yui.yahooapis.com/2.5.1/build/dom/dom.js" type="text/javascript"></script>
# <script src="http://yui.yahooapis.com/2.5.1/build/event/event.js" type="text/javascript"></script>
# <script src="http://yui.yahooapis.com/2.5.1/build/logger/logger.js" type="text/javascript"></script>
# <script src="http://yui.yahooapis.com/2.5.1/build/yuitest/yuitest.js" type="text/javascript"></script>
You can also cache YUI locally:
my $loader = YUI::Loader->new_from_yui_host(cache => { dir => "htdocs/assets", uri => "http://example.com/assets" });
$loader->include->yuitest->reset->fonts->base;
print $loader->html;
# The above will yield:
# <link rel="stylesheet" href="http://example.com/assets/reset.css" type="text/css"/>
# <link rel="stylesheet" href="http://example.com/assets/fonts.css" type="text/css"/>
# <link rel="stylesheet" href="http://example.com/assets/base.css" type="text/css"/>
# <script src="http://example.com/assets/yahoo.js" type="text/javascript"></script>
# <script src="http://example.com/assets/dom.js" type="text/javascript"></script>
# <script src="http://example.com/assets/event.js" type="text/javascript"></script>
# <script src="http://example.com/assets/logger.js" type="text/javascript"></script>
# <script src="http://example.com/assets/yuitest.js" type="text/javascript"></script>
DESCRIPTION
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, or you can cache assets locally or
serve them from an exploded yui_x.x.x.zip dir.
METHODS
YUI::Loader->new_from_yui_host([ base => <base>, version => <version> ])
YUI::Loader->new_from_internet([ base => <base>, version => <version> ])
Return a new YUI::Loader object configured to fetch and/or serve assets
from http://yui.yahooapis.com/<version>
YUI::Loader->new_from_yui_dir([ dir => <dir>, version => <version> ])
Return a new YUI::Loader object configured to fetch/serve assets from a
local, exploded yui_x.x.x.zip dir
As an example, for a dir of "./assets", the "reset.css" asset should be
available as:
./assets/reset/reset.css
YUI::Loader->new_from_uri([ base => <base> ])
Return a new YUI::Loader object configured to serve assets from an
arbitrary uri
As an example, for a base of "http://example.com/assets", the
"reset.css" asset should be available as:
http://example.com/assets/reset.css
YUI::Loader->new_from_dir([ dir => <dir> ])
Return a new YUI::Loader object configured to serve assets from an
arbitrary dir
As an example, for a dir of "./assets", the "reset.css" asset should be
available as:
./assets/reset.css
select( <component>, <component>, ..., <component> )
Include each <component> in the "manifest" for the loader.
A <component> should correspond to an entry in the "YUI component
catalog" (see below)
include
Returns a chainable component selector that will include what is called
You can use the methods of the selector to choose components to include.
See "YUI component catalog" below
You can return to the loader by using the special ->then method:
$loader->include->reset->yuilogger->grids->fonts->then->html;
exclude
Returns a chainable component selector that will exclude what is called
You can use the methods of the selector to choose components to include.
See "YUI component catalog" below
You can return to the loader by using the special ->then method:
$loader->exclude->yuilogger->then->html;
filter_min
Turn on the -min filter for all included components
For example:
connection-min.js
yuilogger-min.js
base-min.css
fonts-min.css
filter_debug
Turn on the -debug filter for all included components
For example:
connection-debug.js
yuilogger-debug.js
base-debug.css
fonts-debug.css
no_filter
Disable filtering of included components
For example:
connection.js
yuilogger.js
base.css
fonts.css
uri( <component> )
Attempt to fetch a URI for <component> using the current filter setting
of the loader (-min, -debug, etc.)
If the loader has a cache, then this method will try to fetch from the
cache. Otherwise it will use the source.
file( <component> )
Attempt to fetch a Path::Class::File for <component> using the current
filter setting of the loader (-min, -debug, etc.)
If the loader has a cache, then this method will try to fetch from the
cache. Otherwise it will use the source.
cache_uri( <component> )
Attempt to fetch a URI for <component> using the current filter setting
of the loader (-min, -debug, etc.) from the cache
cache_file( <component> )
Attempt to fetch a Path::Class::File for <component> using the current
filter setting of the loader (-min, -debug, etc.) from the cache
source_uri( <component> )
Attempt to fetch a URI for <component> using the current filter setting
of the loader (-min, -debug, etc.) from the source
source_file( <component> )
Attempt to fetch a Path::Class::File for <component> using the current
filter setting of the loader (-min, -debug, etc.) from the source
item( <component> )
Return a YUI::Loader::Item for <component> using the current filter
setting of the loader (-min, -debug, etc.)
item_path( <component> )
Return the item path for <component> using the current filter setting of
the loader (-min, -debug, etc.)
item_file( <component> )
Return the item file for <component> using the current filter setting of
the loader (-min, -debug, etc.)
html
Generate and return a string containing HTML describing how to include
components. For example, you can use this in the <head> section of a web
page.
If the loader has a cache, then it will attempt to generate URIs from
the cache, otherwise it will use the source.
Here is an example:
<link rel="stylesheet" href="http://example.com/assets/reset.css" type="text/css"/>
<link rel="stylesheet" href="http://example.com/assets/fonts.css" type="text/css"/>
<link rel="stylesheet" href="http://example.com/assets/base.css" type="text/css"/>
<script src="http://example.com/assets/yahoo.js" type="text/javascript"></script>
<script src="http://example.com/assets/dom.js" type="text/javascript"></script>
<script src="http://example.com/assets/event.js" type="text/javascript"></script>
<script src="http://example.com/assets/logger.js" type="text/javascript"></script>
<script src="http://example.com/assets/yuitest.js" type="text/javascript"></script>
source_html
Generate and return a string containing HTML describing how to include
components. For example, you can use this in the <head> section of a web
page.
Here is an example:
<link rel="stylesheet" href="http://example.com/assets/reset.css" type="text/css"/>
<link rel="stylesheet" href="http://example.com/assets/fonts.css" type="text/css"/>
<link rel="stylesheet" href="http://example.com/assets/base.css" type="text/css"/>
<script src="http://example.com/assets/yahoo.js" type="text/javascript"></script>
<script src="http://example.com/assets/dom.js" type="text/javascript"></script>
<script src="http://example.com/assets/event.js" type="text/javascript"></script>
<script src="http://example.com/assets/logger.js" type="text/javascript"></script>
<script src="http://example.com/assets/yuitest.js" type="text/javascript"></script>
YUI component catalog
animation
Animation Utility (utility)
autocomplete
AutoComplete Control (widget)
base
Base CSS Package (css)
button
Button Control (widget)
calendar
Calendar Control (widget)
charts
Charts Control (widget)
colorpicker
Color Picker Control (widget)
connection
Connection Manager (utility)
container
Container Family (widget)
containercore
Container Core (Module, Overlay) (widget)
cookie
Cookie Utility (utility)
datasource
DataSource Utility (utility)
datatable
DataTable Control (widget)
dom
Dom Collection (core)
dragdrop
Drag & Drop Utility (utility)
editor
Rich Text Editor (widget)
element
Element Utility (utility)
event
Event Utility (core)
fonts
Fonts CSS Package (css)
get
Get Utility (utility)
grids
Grids CSS Package (css)
history
Browser History Manager (utility)
imagecropper
ImageCropper Control (widget)
imageloader
ImageLoader Utility (utility)
json
JSON Utility (utility)
layout
Layout Manager (widget)
logger
Logger Control (tool)
menu
Menu Control (widget)
profiler
Profiler (tool)
profilerviewer
ProfilerViewer Control (tool)
reset
Reset CSS Package (css)
reset_fonts
reset_fonts_grids
resize
Resize Utility (utility)
selector
Selector Utility (utility)
simpleeditor
Simple Editor (widget)
slider
Slider Control (widget)
tabview
TabView Control (widget)
treeview
TreeView Control (widget)
uploader
Uploader (widget)
utilities
yahoo
Yahoo Global Object (core)
yahoo_dom_event
yuiloader
Loader Utility (utility)
yuiloader_dom_event
yuitest
YUI Test Utility (tool)
SEE ALSO
<http://developer.yahoo.com/yui/>
<http://developer.yahoo.com/yui/yuiloader/>
JS::jQuery::Loader
AUTHOR
Robert Krimen <robertkrimen@gmail.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by Robert Krimen.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.