Catalyst::Helper::Controller::Combine - Helper for Combine Controllers


Catalyst-Controller-Combine documentation Contained in the Catalyst-Controller-Combine distribution.

Index


Code Index:

NAME

Top

Catalyst::Helper::Controller::Combine - Helper for Combine Controllers

VERSION

Top

version 0.12

SYNOPSIS

Top

    script/create.pl controller Js Combine
    script/create.pl controller Css Combine

DESCRIPTION

Top

Helper for Combine Controllers.

METHODS

mk_compclass

SEE ALSO

Top

Catalyst::Manual, Catalyst::Helper

AUTHOR

Top

Wolfgang Kinkeldei, <wolfgang@kinkeldei.de>

LICENSE

Top

This library is free software . You can redistribute it and/or modify it under the same terms as perl itself.

NAME

Top

[% class %] - Combine View for [% app %]

DESCRIPTION

Top

Combine View for [% app %].

SEE ALSO

Top

[% app %]

AUTHOR

Top

[% author %]

LICENSE

Top

This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself.


Catalyst-Controller-Combine documentation Contained in the Catalyst-Controller-Combine distribution.
package Catalyst::Helper::Controller::Combine;
BEGIN {
  $Catalyst::Helper::Controller::Combine::VERSION = '0.12';
}

use strict;

sub mk_compclass {
    my ( $self, $helper ) = @_;
    my $file = $helper->{file};
    
    my $ext = lc($helper->{name}) || 'xx';
    $ext =~ s{\A .* ::}{}xms;
    
    my $mimetype = 'text/plain';
    my $minifier = '';
    my $depend = '';
    my $replace = '';
    if ($ext eq 'js')  { 
        $mimetype = 'application/javascript';
        $minifier = "# uncomment if desired and do not import namespace::autoclean!\n# use JavaScript::Minifier::XS qw(minify);";

        $depend =
        "    # aid for the prototype users\n" .
        "    #   --> place all .js files directly into root/static/js!\n" .
        "    #     scriptaculous => 'prototype',\n" .
        "    #     builder       => 'scriptaculous',\n" .
        "    #     effects       => 'scriptaculous',\n" .
        "    #     dragdrop      => 'effects',\n" .
        "    #     slider        => 'scriptaculous',\n" .
        "    #     default       => 'dragdrop',\n" .
        "\n" .
        "    # aid for the jQuery users\n" .
        "    #   --> place all .js files including version-no directly into root/static/js!\n" .
        "    #     'jquery.metadata'     => 'jquery-1.3.2'\n",
        "    #     'jquery.form-2.36'    => 'jquery-1.3.2'\n",
        "    #     'jquery.validate-1.6' => [qw(jquery.form-2.36 jquery.metadata)]\n",
        "    #     default               => [qw(jquery.validate-1.6 jquery-ui-1.7.2)]",
    }
    if ($ext eq 'css') { 
        $mimetype = 'text/css'; 
        $minifier = "# uncomment if desired and do not import namespace::autoclean!\n# use CSS::Minifier::XS qw(minify);";

        $depend =
        "    #     layout  => 'jquery-ui', \n" .
        "    #     default => 'layout',";

        $replace =
        "    #                    # change jQuery UI's links to images\n" .
        "    #                    # assumes that all images for jQuery UI reside under static/images\n" .
        "    #     'jquery-ui' => [ qr'url\(images/' => 'url(/static/images/' ],";
    }
    
    $helper->render_file( 'compclass', $file, 
                          {
                              ext       => $ext,
                              mimetype  => $mimetype,
                              minifier  => $minifier,
                              depend    => $depend,
                              replace   => $replace,
                          } );
}

1;

__DATA__

__compclass__
package [% class %];

use Moose;
BEGIN { extends 'Catalyst::Controller::Combine' }

[% minifier %]

__PACKAGE__->config(
    #   optional, defaults to static/<<action_namespace>>
    # dir => 'static/[% ext %]',
    #
    #   optional, defaults to <<action_namespace>>
    # extension => '[% ext %]',
    #
    #   specify dependencies (without file extensions)
    # depend => {
[% depend %]
    # },
    #
    #   optionally specify replacements to get done
    # replace => {
[% replace %]
    # },
    #
    #   will be guessed from extension
    # mimetype => '[% mimetype %]',
    #
    #   if you want another minifier change this
    # minifier => 'minify',
    #
    #   uncomment if you want to get the 'expire' header set (default:off)
    # expire => 1,
    #
    #   set a different value if wanted
    # expire_in => 60 * 60 * 24 * 365 * 3, # 3 years
);

#
# defined in base class Catalyst::Controller::Combine
# uncomment and modify if you like
#
# sub default :Path {
#     my $self = shift;
#     my $c = shift;
#     
#     $c->forward('do_combine');
# }

1;