X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FHelper.pm;h=3b182addbd27ea23c284bb39ae572ba9b66a9b1c;hb=1a50c493813f72e440cf1975d41f4080f411a547;hp=b6b06759ab8014d8ef3d21c95285435c8933b7bf;hpb=68ccb5e5aaaffd5b17d9dc4144dca51b1942a8f7;p=catagits%2FCatalyst-Devel.git diff --git a/lib/Catalyst/Helper.pm b/lib/Catalyst/Helper.pm index b6b0675..3b182ad 100644 --- a/lib/Catalyst/Helper.pm +++ b/lib/Catalyst/Helper.pm @@ -1,15 +1,24 @@ package Catalyst::Helper; - -use strict; -use base 'Class::Accessor::Fast'; +use Moose; use Config; use File::Spec; +use File::Spec::Unix; use File::Path; -use IO::File; use FindBin; +use IO::File; +use POSIX 'strftime'; use Template; +use Catalyst::Devel; use Catalyst::Utils; use Catalyst::Exception; +use Path::Class qw/dir file/; +use File::ShareDir qw/dist_dir/; +use namespace::autoclean; + +with 'MooseX::Emulate::Class::Accessor::Fast'; + +# Change Catalyst/Devel.pm also +our $VERSION = '1.28'; my %cache; @@ -19,20 +28,31 @@ Catalyst::Helper - Bootstrap a Catalyst application =head1 SYNOPSIS -See L - -=head1 DESCRIPTION - -Bootstrap a Catalyst application. Autogenerates scripts - -=head2 METHODS - -=head3 get_file - -Slurp file from DATA. + catalyst.pl =cut +sub get_sharedir_file { + my ($self, @filename) = @_; + my $dist_dir; + if (exists $ENV{CATALYST_DEVEL_SHAREDIR}) { + $dist_dir = $ENV{CATALYST_DEVEL_SHAREDIR}; + } + elsif (-d "inc/.author" && -f "lib/Catalyst/Helper.pm" + ) { # Can't use sharedir if we're in a checkout + # this feels horrible, better ideas? + $dist_dir = 'share'; + } + else { + $dist_dir = dist_dir('Catalyst-Devel'); + } + my $file = file( $dist_dir, @filename); + Carp::confess("Cannot find $file") unless -r $file; + my $contents = $file->slurp; + return $contents; +} + +# Do not touch this method, *EVER*, it is needed for back compat. sub get_file { my ( $self, $class, $file ) = @_; unless ( $cache{$class} ) { @@ -40,6 +60,8 @@ sub get_file { $cache{$class} = eval "package $class; "; } my $data = $cache{$class}; + Carp::confess("Could not get data from __DATA__ segment for $class") + unless $data; my @files = split /^__(.+)__\r?\n/m, $data; shift @files; while (@files) { @@ -49,11 +71,6 @@ sub get_file { return 0; } -=head3 mk_app - -Create the main application skeleton. - -=cut sub mk_app { my ( $self, $name ) = @_; @@ -61,18 +78,22 @@ sub mk_app { # Needs to be here for PAR require Catalyst; - if ( $name =~ /[^\w\:]/ ) { + if ( $name =~ /[^\w:]/ || $name =~ /^\d/ || $name =~ /\b:\b|:{3,}/) { warn "Error: Invalid application name.\n"; return 0; } - $self->{name} = $name; - $self->{dir} = $name; - $self->{dir} =~ s/\:\:/-/g; - $self->{script} = File::Spec->catdir( $self->{dir}, 'script' ); - $self->{appprefix} = Catalyst::Utils::appprefix($name); - $self->{startperl} = "#!$Config{perlpath} -w"; - $self->{scriptgen} = $Catalyst::CATALYST_SCRIPT_GEN || 4; - $self->{author} = $self->{author} = $ENV{'AUTHOR'} + $self->{name } = $name; + $self->{dir } = $name; + $self->{dir } =~ s/\:\:/-/g; + $self->{script } = dir( $self->{dir}, 'script' ); + $self->{appprefix } = Catalyst::Utils::appprefix($name); + $self->{appenv } = Catalyst::Utils::class2env($name); + $self->{startperl } = -r '/usr/bin/env' + ? '#!/usr/bin/env perl' + : "#!$Config{perlpath}"; + $self->{scriptgen } = $Catalyst::Devel::CATALYST_SCRIPT_GEN; + $self->{catalyst_version} = $Catalyst::VERSION; + $self->{author } = $self->{author} = $ENV{'AUTHOR'} || eval { @{ [ getpwuid($<) ] }[6] } || 'Catalyst developer'; @@ -81,36 +102,27 @@ sub mk_app { my $gen_app = ( $self->{scripts} || $self->{makefile} ) ? 0 : 1; if ($gen_app) { - $self->_mk_dirs; - $self->_mk_config; - $self->_mk_appclass; - $self->_mk_rootclass; - $self->_mk_readme; - $self->_mk_changes; - $self->_mk_apptest; - $self->_mk_images; - $self->_mk_favicon; + for ( qw/ _mk_dirs _mk_config _mk_appclass _mk_rootclass _mk_readme + _mk_changes _mk_apptest _mk_images _mk_favicon/ ) { + + $self->$_; + } } if ($gen_makefile) { $self->_mk_makefile; } if ($gen_scripts) { - $self->_mk_cgi; - $self->_mk_fastcgi; - $self->_mk_server; - $self->_mk_test; - $self->_mk_create; + for ( qw/ _mk_cgi _mk_fastcgi _mk_server + _mk_test _mk_create _mk_information + / ) { + $self->$_; + } } return $self->{dir}; } -=head3 mk_component - -This method is called by create.pl to make new components -for your application. - -=cut - +## not much of this can really be changed, mk_compclass must be left for +## backcompat sub mk_component { my $self = shift; my $app = shift; @@ -118,7 +130,7 @@ sub mk_component { $self->{author} = $self->{author} = $ENV{'AUTHOR'} || eval { @{ [ getpwuid($<) ] }[6] } || 'A clever guy'; - $self->{base} ||= File::Spec->catdir( $FindBin::Bin, '..' ); + $self->{base} ||= dir( $FindBin::Bin, '..' ); unless ( $_[0] =~ /^(?:model|view|controller)$/i ) { my $helper = shift; my @args = @_; @@ -139,15 +151,15 @@ sub mk_component { my $name = shift || "Missing name for model/view/controller"; my $helper = shift; my @args = @_; - return 0 if $name =~ /[^\w\:]/; + return 0 if $name =~ /[^\w\:]/; $type = lc $type; $self->{long_type} = ucfirst $type; $type = 'M' if $type =~ /model/i; $type = 'V' if $type =~ /view/i; $type = 'C' if $type =~ /controller/i; - my $appdir = File::Spec->catdir( split /\:\:/, $app ); + my $appdir = dir( split /\:\:/, $app ); my $test_path = - File::Spec->catdir( $FindBin::Bin, '..', 'lib', $appdir, 'C' ); + dir( $self->{base}, 'lib', $appdir, 'C' ); $type = $self->{long_type} unless -d $test_path; $self->{type} = $type; $self->{name} = $name; @@ -155,19 +167,19 @@ sub mk_component { # Class my $path = - File::Spec->catdir( $FindBin::Bin, '..', 'lib', $appdir, $type ); + dir( $self->{base}, 'lib', $appdir, $type ); my $file = $name; if ( $name =~ /\:/ ) { my @path = split /\:\:/, $name; $file = pop @path; - $path = File::Spec->catdir( $path, @path ); + $path = dir( $path, @path ); } $self->mk_dir($path); - $file = File::Spec->catfile( $path, "$file.pm" ); + $file = file( $path, "$file.pm" ); $self->{file} = $file; # Test - $self->{test_dir} = File::Spec->catdir( $FindBin::Bin, '..', 't' ); + $self->{test_dir} = dir( $self->{base}, 't' ); $self->{test} = $self->next_test; # Helper @@ -184,12 +196,16 @@ sub mk_component { if ( $class->can('mk_compclass') ) { return 1 unless $class->mk_compclass( $self, @args ); } - else { return 1 unless $self->_mk_compclass } + else { + return 1 unless $self->_mk_compclass + } if ( $class->can('mk_comptest') ) { $class->mk_comptest( $self, @args ); } - else { $self->_mk_comptest } + else { + $self->_mk_comptest + } } # Fallback @@ -201,12 +217,6 @@ sub mk_component { return 1; } -=head3 mk_dir - -Surprisingly, this function makes a directory. - -=cut - sub mk_dir { my ( $self, $dir ) = @_; if ( -d $dir ) { @@ -221,15 +231,9 @@ sub mk_dir { Catalyst::Exception->throw( message => qq/Couldn't create "$dir", "$!"/ ); } -=head3 mk_file - -writes content to a file. - -=cut - sub mk_file { my ( $self, $file, $content ) = @_; - if ( -e $file ) { + if ( -e $file && -s _ ) { print qq/ exists "$file"\n/; return 0 unless ( $self->{'.newfiles'} @@ -243,6 +247,7 @@ sub mk_file { $file .= '.new'; } } + if ( my $f = IO::File->new("> $file") ) { binmode $f; print $f $content; @@ -253,10 +258,6 @@ sub mk_file { Catalyst::Exception->throw( message => qq/Couldn't create "$file", "$!"/ ); } -=head3 next_test - -=cut - sub next_test { my ( $self, $tname ) = @_; if ($tname) { $tname = "$tname.t" } @@ -274,94 +275,108 @@ sub next_test { my $dir = $self->{test_dir}; my $type = lc $self->{type}; $self->mk_dir($dir); - return File::Spec->catfile( $dir, "$type\_$tname" ); + return file( $dir, "$type\_$tname" ); } -=head3 render_file - -Render and create a file from a template in DATA using -Template Toolkit. - -=cut +# Do not touch this method, *EVER*, it is needed for back compat. +## addendum: we had to split this method so we could have backwards +## compatability. otherwise, we'd have no way to pass stuff from __DATA__ sub render_file { my ( $self, $file, $path, $vars ) = @_; + my $template = $self->get_file( ( caller(0) )[0], $file ); + $self->render_file_contents($template, $path, $vars); +} + +sub render_sharedir_file { + my ( $self, $file, $path, $vars ) = @_; + my $template = $self->get_sharedir_file( $file ); + die("Cannot get template from $file for $self\n") unless $template; + $self->render_file_contents($template, $path, $vars); +} + +sub render_file_contents { + my ( $self, $template, $path, $vars ) = @_; $vars ||= {}; my $t = Template->new; - my $template = $self->get_file( ( caller(0) )[0], $file ); return 0 unless $template; my $output; $t->process( \$template, { %{$self}, %$vars }, \$output ) || Catalyst::Exception->throw( - message => qq/Couldn't process "$file", / . $t->error() ); + message => qq/Couldn't process "$template", / . $t->error() ); $self->mk_file( $path, $output ); } +sub _mk_information { + my $self = shift; + print qq/Change to application directory and Run "perl Makefile.PL" to make sure your install is complete\n/; +} + sub _mk_dirs { my $self = shift; $self->mk_dir( $self->{dir} ); $self->mk_dir( $self->{script} ); - $self->{lib} = File::Spec->catdir( $self->{dir}, 'lib' ); + $self->{lib} = dir( $self->{dir}, 'lib' ); $self->mk_dir( $self->{lib} ); - $self->{root} = File::Spec->catdir( $self->{dir}, 'root' ); + $self->{root} = dir( $self->{dir}, 'root' ); $self->mk_dir( $self->{root} ); - $self->{static} = File::Spec->catdir( $self->{root}, 'static' ); + $self->{static} = dir( $self->{root}, 'static' ); $self->mk_dir( $self->{static} ); - $self->{images} = File::Spec->catdir( $self->{static}, 'images' ); + $self->{images} = dir( $self->{static}, 'images' ); $self->mk_dir( $self->{images} ); - $self->{t} = File::Spec->catdir( $self->{dir}, 't' ); + $self->{t} = dir( $self->{dir}, 't' ); $self->mk_dir( $self->{t} ); - $self->{class} = File::Spec->catdir( split( /\:\:/, $self->{name} ) ); - $self->{mod} = File::Spec->catdir( $self->{lib}, $self->{class} ); + $self->{class} = dir( split( /\:\:/, $self->{name} ) ); + $self->{mod} = dir( $self->{lib}, $self->{class} ); $self->mk_dir( $self->{mod} ); if ( $self->{short} ) { - $self->{m} = File::Spec->catdir( $self->{mod}, 'M' ); + $self->{m} = dir( $self->{mod}, 'M' ); $self->mk_dir( $self->{m} ); - $self->{v} = File::Spec->catdir( $self->{mod}, 'V' ); + $self->{v} = dir( $self->{mod}, 'V' ); $self->mk_dir( $self->{v} ); - $self->{c} = File::Spec->catdir( $self->{mod}, 'C' ); + $self->{c} = dir( $self->{mod}, 'C' ); $self->mk_dir( $self->{c} ); } else { - $self->{m} = File::Spec->catdir( $self->{mod}, 'Model' ); + $self->{m} = dir( $self->{mod}, 'Model' ); $self->mk_dir( $self->{m} ); - $self->{v} = File::Spec->catdir( $self->{mod}, 'View' ); + $self->{v} = dir( $self->{mod}, 'View' ); $self->mk_dir( $self->{v} ); - $self->{c} = File::Spec->catdir( $self->{mod}, 'Controller' ); + $self->{c} = dir( $self->{mod}, 'Controller' ); $self->mk_dir( $self->{c} ); } my $name = $self->{name}; $self->{rootname} = $self->{short} ? "$name\::C::Root" : "$name\::Controller::Root"; - $self->{base} = File::Spec->rel2abs( $self->{dir} ); + $self->{base} = dir( $self->{dir} )->absolute; } sub _mk_appclass { my $self = shift; my $mod = $self->{mod}; - $self->render_file( 'appclass', "$mod.pm" ); + $self->render_sharedir_file( file('lib', 'MyApp.pm.tt'), "$mod.pm" ); } sub _mk_rootclass { my $self = shift; - $self->render_file( 'rootclass', - File::Spec->catfile( $self->{c}, "Root.pm" ) ); + $self->render_sharedir_file( file('lib', 'MyApp', 'Controller', 'Root.pm.tt'), + file( $self->{c}, "Root.pm" ) ); } sub _mk_makefile { my $self = shift; - $self->{path} = File::Spec->catfile( 'lib', split( '::', $self->{name} ) ); + $self->{path} = dir( 'lib', split( '::', $self->{name} ) ); $self->{path} .= '.pm'; my $dir = $self->{dir}; - $self->render_file( 'makefile', "$dir\/Makefile.PL" ); + $self->render_sharedir_file( 'Makefile.PL.tt', file($dir, "Makefile.PL") ); if ( $self->{makefile} ) { # deprecate the old Build.PL file when regenerating Makefile.PL $self->_deprecate_file( - File::Spec->catdir( $self->{dir}, 'Build.PL' ) ); + file( $self->{dir}, 'Build.PL' ) ); } } @@ -369,81 +384,81 @@ sub _mk_config { my $self = shift; my $dir = $self->{dir}; my $appprefix = $self->{appprefix}; - $self->render_file( 'config', - File::Spec->catfile( $dir, "$appprefix.yml" ) ); + $self->render_sharedir_file( 'myapp.conf.tt', + file( $dir, "$appprefix.conf" ) ); } sub _mk_readme { my $self = shift; my $dir = $self->{dir}; - $self->render_file( 'readme', "$dir\/README" ); + $self->render_sharedir_file( 'README.tt', file($dir, "README") ); } sub _mk_changes { my $self = shift; my $dir = $self->{dir}; - my $time = localtime time; - $self->render_file( 'changes', "$dir\/Changes", { time => $time } ); + my $time = strftime('%Y-%m-%d %H:%M:%S', localtime time); + $self->render_sharedir_file( 'Changes.tt', file($dir, "Changes"), { time => $time } ); } sub _mk_apptest { my $self = shift; my $t = $self->{t}; - $self->render_file( 'apptest', "$t\/01app.t" ); - $self->render_file( 'podtest', "$t\/02pod.t" ); - $self->render_file( 'podcoveragetest', "$t\/03podcoverage.t" ); + $self->render_sharedir_file( file('t', '01app.t.tt'), file($t, "01app.t") ); + $self->render_sharedir_file( file('t', '02pod.t.tt'), file($t, "02pod.t") ); + $self->render_sharedir_file( file('t', '03podcoverage.t.tt'), file($t, "03podcoverage.t") ); } sub _mk_cgi { my $self = shift; my $script = $self->{script}; my $appprefix = $self->{appprefix}; - $self->render_file( 'cgi', "$script\/$appprefix\_cgi.pl" ); - chmod 0700, "$script/$appprefix\_cgi.pl"; + $self->render_sharedir_file( file('script', 'myapp_cgi.pl.tt'), file($script,"$appprefix\_cgi.pl") ); + chmod 0700, file($script,"$appprefix\_cgi.pl"); } sub _mk_fastcgi { my $self = shift; my $script = $self->{script}; my $appprefix = $self->{appprefix}; - $self->render_file( 'fastcgi', "$script\/$appprefix\_fastcgi.pl" ); - chmod 0700, "$script/$appprefix\_fastcgi.pl"; + $self->render_sharedir_file( file('script', 'myapp_fastcgi.pl.tt'), file($script, "$appprefix\_fastcgi.pl") ); + chmod 0700, file($script, "$appprefix\_fastcgi.pl"); } sub _mk_server { my $self = shift; my $script = $self->{script}; my $appprefix = $self->{appprefix}; - $self->render_file( 'server', "$script\/$appprefix\_server.pl" ); - chmod 0700, "$script/$appprefix\_server.pl"; + $self->render_sharedir_file( file('script', 'myapp_server.pl.tt'), file($script, "$appprefix\_server.pl") ); + chmod 0700, file($script, "$appprefix\_server.pl"); } sub _mk_test { my $self = shift; my $script = $self->{script}; my $appprefix = $self->{appprefix}; - $self->render_file( 'test', "$script/$appprefix\_test.pl" ); - chmod 0700, "$script/$appprefix\_test.pl"; + $self->render_sharedir_file( file('script', 'myapp_test.pl.tt'), file($script, "$appprefix\_test.pl") ); + chmod 0700, file($script, "$appprefix\_test.pl"); } sub _mk_create { my $self = shift; my $script = $self->{script}; my $appprefix = $self->{appprefix}; - $self->render_file( 'create', "$script\/$appprefix\_create.pl" ); - chmod 0700, "$script/$appprefix\_create.pl"; + $self->render_sharedir_file( file('script', 'myapp_create.pl.tt'), file($script, "$appprefix\_create.pl") ); + chmod 0700, file($script, "$appprefix\_create.pl"); } sub _mk_compclass { my $self = shift; my $file = $self->{file}; - return $self->render_file( 'compclass', "$file" ); + return $self->render_sharedir_file( file('lib', 'Helper', 'compclass.pm.tt'), $file ); } sub _mk_comptest { my $self = shift; my $test = $self->{test}; - $self->render_file( 'comptest', "$test" ); + $self->render_sharedir_file( file('t', 'comptest.tt'), $test ); ## wtf do i rename this to? } sub _mk_images { @@ -454,30 +469,29 @@ sub _mk_images { btn_120x50_powered btn_120x50_powered_shadow btn_88x31_built btn_88x31_built_shadow btn_88x31_powered btn_88x31_powered_shadow/; for my $name (@images) { - my $hex = $self->get_file( ( caller(0) )[0], $name ); - my $image = pack "H*", $hex; - $self->mk_file( File::Spec->catfile( $images, "$name.png" ), $image ); + my $image = $self->get_sharedir_file("root", "static", "images", "$name.png.bin"); + $self->mk_file( file( $images, "$name.png" ), $image ); } } sub _mk_favicon { my $self = shift; my $root = $self->{root}; - my $hex = $self->get_file( ( caller(0) )[0], 'favicon' ); - my $favicon = pack "H*", $hex; - $self->mk_file( File::Spec->catfile( $root, "favicon.ico" ), $favicon ); + my $favicon = $self->get_sharedir_file( 'root', 'favicon.ico.bin' ); + my $dest = dir( $root, "favicon.ico" ); + $self->mk_file( $dest, $favicon ); } sub _deprecate_file { my ( $self, $file ) = @_; if ( -e $file ) { - my $oldcontent; - if ( my $f = IO::File->new("< $file") ) { + my ($f, $oldcontent); + if ( $f = IO::File->new("< $file") ) { $oldcontent = join( '', (<$f>) ); } my $newfile = $file . '.deprecated'; - if ( my $f = IO::File->new("> $newfile") ) { + if ( $f = IO::File->new("> $newfile") ) { binmode $f; print $f $oldcontent; print qq/created "$newfile"\n/; @@ -490,676 +504,206 @@ sub _deprecate_file { } } -=head1 HELPERS - -Helpers are classes that provide two methods. - - * mk_compclass - creates the Component class - * mk_comptest - creates the Component test - -So when you call C, create would try to execute -Catalyst::Helper::View::TT->mk_compclass and -Catalyst::Helper::View::TT->mk_comptest. - -See L and L for -examples. - -All helper classes should be under one of the following namespaces. - - Catalyst::Helper::Model:: - Catalyst::Helper::View:: - Catalyst::Helper::Controller:: - -=head1 NOTE - -The helpers will read author name from /etc/passwd by default. -To override, please export the AUTHOR variable. - -=head1 SEE ALSO - -L, L, L, -L, L +=head1 DESCRIPTION -=head1 AUTHOR +This module is used by B to create a set of scripts for a +new catalyst application. The scripts each contain documentation and +will output help on how to use them if called incorrectly or in some +cases, with no arguments. -Sebastian Riedel, C +It also provides some useful methods for a Helper module to call when +creating a component. See L. -=head1 LICENSE +=head1 SCRIPTS -This library is free software, you can redistribute it and/or modify -it under the same terms as Perl itself. +=head2 _create.pl -=cut +Used to create new components for a catalyst application at the +development stage. -1; -__DATA__ - -__appclass__ -package [% name %]; +=head2 _server.pl -use strict; -use warnings; +The catalyst test server, starts an HTTPD which outputs debugging to +the terminal. -# -# Set flags and add plugins for the application -# -# -Debug: activates the debug mode for very useful log messages -# ConfigLoader: will load the configuration from a YAML file in the -# application's home directory -# Static::Simple: will serve static files from the application's root -# directory -# -use Catalyst qw/-Debug ConfigLoader Static::Simple/; +=head2 _test.pl -our $VERSION = '0.01'; +A script for running tests from the command-line. -# -# Configure the application -# -__PACKAGE__->config( name => '[% name %]' ); +=head2 _cgi.pl -# -# Start the application -# -__PACKAGE__->setup; +Run your application as a CGI. -# -# IMPORTANT: Please look into [% rootname %] for more -# +=head2 _fastcgi.pl -=head1 NAME +Run the application as a fastcgi app. Either by hand, or call this +from FastCgiServer in your http server config. -[% name %] - Catalyst based application +=head1 HELPERS -=head1 SYNOPSIS +The L script creates application components using Helper +modules. The Catalyst team provides a good number of Helper modules +for you to use. You can also add your own. - script/[% appprefix %]_server.pl +Helpers are classes that provide two methods. -=head1 DESCRIPTION + * mk_compclass - creates the Component class + * mk_comptest - creates the Component test -Catalyst based application. +So when you call C, create +will try to execute Catalyst::Helper::View::TT->mk_compclass and +Catalyst::Helper::View::TT->mk_comptest. -=head1 SEE ALSO +See L and +L for examples. -L<[% rootname %]>, L +All helper classes should be under one of the following namespaces. -=head1 AUTHOR + Catalyst::Helper::Model:: + Catalyst::Helper::View:: + Catalyst::Helper::Controller:: -[% author %] +=head2 COMMON HELPERS -=head1 LICENSE +=over -This library is free software, you can redistribute it and/or modify -it under the same terms as Perl itself. +=item * -=cut +L - DBIx::Class models -1; -__rootclass__ -package [% rootname %]; +=item * -use strict; -use warnings; -use base 'Catalyst::Controller'; +L - Template Toolkit view -# -# Sets the actions in this controller to be registered with no prefix -# so they function identically to actions created in MyApp.pm -# -__PACKAGE__->config->{namespace} = ''; +=item * -=head1 NAME +L -[% rootname %] - Root Controller for this Catalyst based application +=item * -=head1 SYNOPSIS +L - wrap any class into a Catalyst model -See L<[% name %]>. +=back -=head1 DESCRIPTION +=head3 NOTE -Root Controller for this Catalyst based application. +The helpers will read author name from /etc/passwd by default. +To override, please export the AUTHOR variable. =head1 METHODS -=cut - -=head2 default - -=cut - -# -# Output a friendly welcome message -# -sub default : Private { - my ( $self, $c ) = @_; - - # Hello World - $c->response->body( $c->welcome_message ); -} - -# -# Uncomment and modify this end action after adding a View component -# -#=head2 end -# -#=cut -# -#sub end : Private { -# my ( $self, $c ) = @_; -# -# # Forward to View unless response body is already defined -# $c->forward( $c->view('') ) unless $c->response->body; -#} +=head2 mk_compclass -=head1 AUTHOR +This method in your Helper module is called with C<$helper> +which is a L object, and whichever other arguments +the user added to the command-line. You can use the $helper to call methods +described below. -[% author %] +If the Helper module does not contain a C method, it +will fall back to calling L, with an argument of +C. -=head1 LICENSE +=head2 mk_comptest -This library is free software, you can redistribute it and/or modify -it under the same terms as Perl itself. +This method in your Helper module is called with C<$helper> +which is a L object, and whichever other arguments +the user added to the command-line. You can use the $helper to call methods +described below. -=cut +If the Helper module does not contain a C method, it +will fall back to calling L, with an argument of +C. -1; -__makefile__ -use inc::Module::Install; - -name '[% dir %]'; -all_from '[% path %]'; - -requires Catalyst => '5.64'; - -catalyst; - -install_script glob('script/*.pl'); -auto_install; -WriteAll; -__config__ ---- -name: [% name %] -__readme__ -Run script/[% appprefix %]_server.pl to test the application. -__changes__ -This file documents the revision history for Perl extension [% name %]. - -0.01 [% time %] - - initial revision, generated by Catalyst -__apptest__ -use strict; -use warnings; -use Test::More tests => 2; - -BEGIN { use_ok 'Catalyst::Test', '[% name %]' } - -ok( request('/')->is_success, 'Request should succeed' ); -__podtest__ -use strict; -use warnings; -use Test::More; - -eval "use Test::Pod 1.14"; -plan skip_all => 'Test::Pod 1.14 required' if $@; -plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD}; - -all_pod_files_ok(); -__podcoveragetest__ -use strict; -use warnings; -use Test::More; - -eval "use Test::Pod::Coverage 1.04"; -plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@; -plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD}; - -all_pod_coverage_ok(); -__cgi__ -[% startperl %] - -BEGIN { $ENV{CATALYST_ENGINE} ||= 'CGI' } - -use strict; -use FindBin; -use lib "$FindBin::Bin/../lib"; -use [% name %]; +=head2 mk_stuff -[% name %]->run; +This method is called if the user does not supply any of the usual +component types C, C, C. It is passed the +C<$helper> object (an instance of L), and any other +arguments the user typed. -1; +There is no fallback for this method. -=head1 NAME +=head1 INTERNAL METHODS -[% appprefix %]_cgi.pl - Catalyst CGI +These are the methods that the Helper classes can call on the +<$helper> object passed to them. -=head1 SYNOPSIS +=head2 render_file ($file, $path, $vars) -See L +Render and create a file from a template in DATA using Template +Toolkit. $file is the relevent chunk of the __DATA__ section, $path is +the path to the file and $vars is the hashref as expected by +L