CatalystX::UriForStatic either creates a local or production URI to your static files depending on your configuration! If your differences are that simple so you just can switch the host names, CatalystX::UriForStatic is for you.
Let's pretend this is your Catalyst application while
sysenv controls whether your application is a development or production instance and
static_host defines the host name of your static files for production environment:
package MyApp; use Moose; use namespace::autoclean; extends 'Catalyst'; with 'CatalystX::UriForStatic'; __PACKAGE__->config( static_host => 'http://static.example.net', sysenv => 'production', ... );
In your templates where you point to your images etc. change the URIs to:
<% $c->uri_for_static('/static/foo.png') %>
(Note this is Mason syntax.)
On your production environment like the one above this will return
Leave everything as it and add a new config file
myapp_local.yaml (See Catalyst::Plugin::ConfigLoader) with the following configuration line:
There are plenty of different ways of your specific CDN implementation like not having the same paths for both systems. While adding a folder name to the
static_host configuration is not an issue, removing one from the local path is. Suggestions are very welcome, as well as patches and so on.
To install this module, run the following commands:
perl Build.PL ./Build ./Build test ./Build install
Copyright (C) 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.