.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "Mojolicious::Plugin::AssetPack::Store 3pm" .TH Mojolicious::Plugin::AssetPack::Store 3pm "2017-01-29" "perl v5.24.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Mojolicious::Plugin::AssetPack::Store \- Storage for assets .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Mojolicious::Lite; \& \& # Load plugin and pipes in the right order \& plugin AssetPack => {pipes => \e@pipes}; \& \& # Change where assets can be found \& app\->asset\->store\->paths([ \& app\->home\->rel_file("some/directory"), \& "/some/other/directory", \& ]); \& \& # Change where assets are stored \& app\->asset\->store\->paths\->[0] = app\->home\->rel_file("some/directory"); \& \& # Define asset \& app\->asset\->process($moniker => @assets); \& \& # Retrieve a Mojolicious::Plugin::AssetPack::Asset object \& my $asset = app\->asset\->store\->asset("some/file.js"); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Mojolicious::Plugin::AssetPack::Store is an object to manage cached assets on disk. .PP The idea is that a Mojolicious::Plugin::AssetPack::Pipe object can store an asset after it is processed. This will speed up development, since only changed assets will be processed and it will also allow processing tools to be optional in production environment. .PP This module will document meta data about each asset which is saved to disk, so it can be looked up later as a unique item using \*(L"load\*(R". .SH "ATTRIBUTES" .IX Header "ATTRIBUTES" Mojolicious::Plugin::AssetPack::Store inherits all attributes from Mojolicious::Static implements the following new ones. .SS "default_headers" .IX Subsection "default_headers" .Vb 2 \& $hash_ref = $self\->default_headers; \& $self = $self\->default_headers({"Cache\-Control" => "max\-age=31536000"}); .Ve .PP Used to set default headers used by \*(L"serve_asset\*(R". .SS "ua" .IX Subsection "ua" .Vb 1 \& $ua = $self\->ua; .Ve .PP See \*(L"ua\*(R" in Mojolicious::Plugin::AssetPack. .SH "METHODS" .IX Header "METHODS" Mojolicious::Plugin::AssetPack::Store inherits all attributes from Mojolicious::Static implements the following new ones. .SS "asset" .IX Subsection "asset" .Vb 1 \& $asset = $self\->asset($url, $paths); .Ve .PP Retuns a Mojolicious::Plugin::AssetPack::Asset object or undef unless \&\f(CW$url\fR can be found in \f(CW$paths\fR. \f(CW$paths\fR default to \&\*(L"paths\*(R" in Mojolicious::Static. \f(CW$paths\fR and \f(CW$url\fR can be... .IP "\(bu" 2 http://example.com/foo/bar .Sp An absolute \s-1URL\s0 will be downloaded from web, unless the host is \*(L"local\*(R": \&\*(L"local\*(R" is a special host which will run the request through the current Mojolicious application. .IP "\(bu" 2 foo/bar .Sp An relative \s-1URL\s0 will be looked up using \*(L"file\*(R" in Mojolicious::Static. .PP Note that assets from web will be cached locally, which means that you need to delete the files on disk to download a new version. .SS "load" .IX Subsection "load" .Vb 1 \& $bool = $self\->load($asset, \e%attr); .Ve .PP Used to load an existing asset from disk. \f(CW%attr\fR will override the way an asset is looked up. The example below will ignore minified and rather use the value from \f(CW%attr\fR: .PP .Vb 1 \& $bool = $self\->load($asset, {minified => $bool}); .Ve .SS "save" .IX Subsection "save" .Vb 1 \& $bool = $self\->save($asset, \e%attr); .Ve .PP Used to save an asset to disk. \f(CW%attr\fR are usually the same as \&\*(L"\s-1TO_JSON\*(R"\s0 in Mojolicious::Plugin::AssetPack::Asset and used to document metadata about the \f(CW$asset\fR so it can be looked up using \*(L"load\*(R". .SS "serve_asset" .IX Subsection "serve_asset" Override \*(L"serve_asset\*(R" in Mojolicious::Static with the functionality to set response headers first, from \*(L"default_headers\*(R". .SH "SEE ALSO" .IX Header "SEE ALSO" Mojolicious::Plugin::AssetPack.