++ed by:

1 non-PAUSE user(s).

Matthias Dietrich

NAME

CatalystX::UriForStatic - Implements an uri_for_static method for Catalyst applications!

VERSION

Version 0.01

SYNOPSIS

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') %>

DESCRIPTION

uri_for_static

Pass a path like you would do to "uri_for" in Catalyst. Doesn't accept Controller paths or blessed references etc.

On a 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.

CONFIGURATION

To work properly, CatalystX::UriForStatic needs some small configuration.

envkey

Specifies the key in the config that is responsible for defining if the environment is a development or production environment. The default is sysenv.

local_value

Specifies what the value of the envkey is when the environment is a development/local environment. The default is local.

sysenv

This key's name is whatever envkey is set to! Change this to the value of local_value to tell CatalystX::UriForStatic if the environment is a development/local environment. If it differs from local_value the environment is considered as production.

static_host

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.

Examples:

http://static.example.net
http://static.example.net/my/static/files
https://whatever.example.net

AUTHOR

Matthias Dietrich, <perl@rainboxx.de>

http://www.rainboxx.de

LICENSE AND COPYRIGHT

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.




Hosting generously
sponsored by Bytemark