CatalystX::UriForStatic - Implements an uri_for_static method for Catalyst applications!
Returns an URI for static files. It distinguishes between a local and productive environment so it can return an URI pointing to a different host (eg. to a CDN) for productive environments.
package MyApp; use Moose; use namespace::autoclean; extends 'Catalyst'; with 'CatalystX::UriForStatic'; __PACKAGE__->config( envkey => 'sysenv', # optional, this is the default local_value => 'local', # optional, this is the default static_host => 'http://static.example.net', sysenv => 'local', ); # In your template <% $c->uri_for_static('/static/foo.png') %>
Pass a path like you would do to "uri_for" in Catalyst. Doesn't accept Controller paths or blessed references etc.
local environment it calls "uri_for" in Catalyst and returns what it returns.
On any other environment it prepends the
static_host to the path while it doesn't care about SSL or if your passed path is valid.
To work properly, CatalystX::UriForStatic needs some small configuration.
Specifies the key in the config that is responsible for defining if the environment is a development or production environment. The default is sysenv.
Specifies what the value of the envkey is when the environment is a development/local environment. The default is local.
This key's name is whatever envkey is set to! Change this to the value of local_value to tell
CatalystX::UriForStaticif the environment is a development/local environment. If it differs from local_value the environment is considered as production.
Contains the URI to the static files and should include the protocol (http or https) and as well the domain. Shouldn't contain a trailing slash.
Copyright 2011 Matthias Dietrich.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.