Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial import

  • Loading branch information...
commit 4847b6352ab786b39799ad8dd2be12165c81c82a 0 parents
Daisuke Murase authored
4 Changes
@@ -0,0 +1,4 @@
+This file documents the revision history for Perl extension CLON.
+
+0.01 2008-04-23 22:41:08
+ - initial revision, generated by Catalyst
16 Makefile.PL
@@ -0,0 +1,16 @@
+use inc::Module::Install;
+
+name 'CLON';
+all_from 'lib/CLON.pm';
+
+requires 'Catalyst::Runtime' => '5.7011';
+requires 'Catalyst::Plugin::ConfigLoader';
+requires 'Catalyst::Plugin::Static::Simple';
+requires 'Catalyst::Action::RenderView';
+requires 'YAML'; # This should reflect the config file format you've chosen
+ # See Catalyst::Plugin::ConfigLoader for supported formats
+catalyst;
+
+install_script glob('script/*.pl');
+auto_install;
+WriteAll;
1  README
@@ -0,0 +1 @@
+Run script/clon_server.pl to test the application.
7 clon.yml
@@ -0,0 +1,7 @@
+---
+name: CLON
+
+default_view: TT
+View::TT:
+ INCLUDE_PATH: __path_to(templates)__
+# WRAPPER: common/wrapper.tt
16 lib/CLON.pm
@@ -0,0 +1,16 @@
+package CLON;
+use strict;
+use warnings;
+
+use Catalyst::Runtime '5.70';
+use Catalyst qw/ConfigLoader/;
+
+our $VERSION = '0.02';
+
+__PACKAGE__->config(
+ 'Plugin::ConfigLoader' => { file => 'config' },
+);
+
+__PACKAGE__->setup;
+
+1;
22 lib/CLON/Controller/Root.pm
@@ -0,0 +1,22 @@
+package CLON::Controller::Root;
+use strict;
+use warnings;
+use base 'Catalyst::Controller';
+__PACKAGE__->config->{namespace} = '';
+
+sub default :Private {
+ my ($self, $c) = @_;
+ $c->res->status(404);
+ $c->stash->{template} = 'errors/404.tt';
+}
+
+sub index :Private {
+ my ($self, $c) = @_;
+}
+
+sub end :ActionClass('RenderView') {
+ my ($self, $c) = @_;
+ $c->res->header( 'Cache-Control' => 'private' );
+}
+
+1;
31 lib/CLON/View/TT.pm
@@ -0,0 +1,31 @@
+package CLON::View::TT;
+
+use strict;
+use base 'Catalyst::View::TT';
+
+__PACKAGE__->config(TEMPLATE_EXTENSION => '.tt');
+
+=head1 NAME
+
+CLON::View::TT - TT View for CLON
+
+=head1 DESCRIPTION
+
+TT View for CLON.
+
+=head1 AUTHOR
+
+=head1 SEE ALSO
+
+L<CLON>
+
+Daisuke Murase,,,
+
+=head1 LICENSE
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
37 script/clon_cgi.pl
@@ -0,0 +1,37 @@
+#!/usr/bin/perl -w
+
+BEGIN { $ENV{CATALYST_ENGINE} ||= 'CGI' }
+
+use strict;
+use warnings;
+use FindBin;
+use lib "$FindBin::Bin/../lib";
+use CLON;
+
+CLON->run;
+
+1;
+
+=head1 NAME
+
+clon_cgi.pl - Catalyst CGI
+
+=head1 SYNOPSIS
+
+See L<Catalyst::Manual>
+
+=head1 DESCRIPTION
+
+Run a Catalyst application as a cgi script.
+
+=head1 AUTHOR
+
+Sebastian Riedel, C<sri@oook.de>
+
+=head1 COPYRIGHT
+
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
75 script/clon_create.pl
@@ -0,0 +1,75 @@
+#!/usr/bin/perl -w
+
+use strict;
+use warnings;
+use Getopt::Long;
+use Pod::Usage;
+use Catalyst::Helper;
+
+my $force = 0;
+my $mech = 0;
+my $help = 0;
+
+GetOptions(
+ 'nonew|force' => \$force,
+ 'mech|mechanize' => \$mech,
+ 'help|?' => \$help
+ );
+
+pod2usage(1) if ( $help || !$ARGV[0] );
+
+my $helper = Catalyst::Helper->new( { '.newfiles' => !$force, mech => $mech } );
+
+pod2usage(1) unless $helper->mk_component( 'CLON', @ARGV );
+
+1;
+
+=head1 NAME
+
+clon_create.pl - Create a new Catalyst Component
+
+=head1 SYNOPSIS
+
+clon_create.pl [options] model|view|controller name [helper] [options]
+
+ Options:
+ -force don't create a .new file where a file to be created exists
+ -mechanize use Test::WWW::Mechanize::Catalyst for tests if available
+ -help display this help and exits
+
+ Examples:
+ clon_create.pl controller My::Controller
+ clon_create.pl controller My::Controller BindLex
+ clon_create.pl -mechanize controller My::Controller
+ clon_create.pl view My::View
+ clon_create.pl view MyView TT
+ clon_create.pl view TT TT
+ clon_create.pl model My::Model
+ clon_create.pl model SomeDB DBIC::Schema MyApp::Schema create=dynamic\
+ dbi:SQLite:/tmp/my.db
+ clon_create.pl model AnotherDB DBIC::Schema MyApp::Schema create=static\
+ dbi:Pg:dbname=foo root 4321
+
+ See also:
+ perldoc Catalyst::Manual
+ perldoc Catalyst::Manual::Intro
+
+=head1 DESCRIPTION
+
+Create a new Catalyst Component.
+
+Existing component files are not overwritten. If any of the component files
+to be created already exist the file will be written with a '.new' suffix.
+This behavior can be suppressed with the C<-force> option.
+
+=head1 AUTHOR
+
+Sebastian Riedel, C<sri@oook.de>
+Maintained by the Catalyst Core Team.
+
+=head1 COPYRIGHT
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
80 script/clon_fastcgi.pl
@@ -0,0 +1,80 @@
+#!/usr/bin/perl -w
+
+BEGIN { $ENV{CATALYST_ENGINE} ||= 'FastCGI' }
+
+use strict;
+use warnings;
+use Getopt::Long;
+use Pod::Usage;
+use FindBin;
+use lib "$FindBin::Bin/../lib";
+use CLON;
+
+my $help = 0;
+my ( $listen, $nproc, $pidfile, $manager, $detach, $keep_stderr );
+
+GetOptions(
+ 'help|?' => \$help,
+ 'listen|l=s' => \$listen,
+ 'nproc|n=i' => \$nproc,
+ 'pidfile|p=s' => \$pidfile,
+ 'manager|M=s' => \$manager,
+ 'daemon|d' => \$detach,
+ 'keeperr|e' => \$keep_stderr,
+);
+
+pod2usage(1) if $help;
+
+CLON->run(
+ $listen,
+ { nproc => $nproc,
+ pidfile => $pidfile,
+ manager => $manager,
+ detach => $detach,
+ keep_stderr => $keep_stderr,
+ }
+);
+
+1;
+
+=head1 NAME
+
+clon_fastcgi.pl - Catalyst FastCGI
+
+=head1 SYNOPSIS
+
+clon_fastcgi.pl [options]
+
+ Options:
+ -? -help display this help and exits
+ -l -listen Socket path to listen on
+ (defaults to standard input)
+ can be HOST:PORT, :PORT or a
+ filesystem path
+ -n -nproc specify number of processes to keep
+ to serve requests (defaults to 1,
+ requires -listen)
+ -p -pidfile specify filename for pid file
+ (requires -listen)
+ -d -daemon daemonize (requires -listen)
+ -M -manager specify alternate process manager
+ (FCGI::ProcManager sub-class)
+ or empty string to disable
+ -e -keeperr send error messages to STDOUT, not
+ to the webserver
+
+=head1 DESCRIPTION
+
+Run a Catalyst application as fastcgi.
+
+=head1 AUTHOR
+
+Sebastian Riedel, C<sri@oook.de>
+Maintained by the Catalyst Core Team.
+
+=head1 COPYRIGHT
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
92 script/clon_lighty.pl
@@ -0,0 +1,92 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+use FindBin;
+use File::Spec;
+use lib File::Spec->catfile( $FindBin::Bin, '..', 'lib' );
+
+use File::Temp;
+use Path::Class qw/file dir/;
+use Template;
+
+use Getopt::Long;
+
+GetOptions(
+ \my %opt,
+ qw/help debug lighttpd=s port=i/,
+);
+$opt{port} ||= 3000;
+$opt{lighttpd} ||= '/usr/sbin/lighttpd';
+
+$ENV{CATALYST_DEBUG} = 1 if $opt{debug};
+
+my $child;
+if ( !($child = fork) ) {
+ my $fastcgi = file($FindBin::Bin)->parent->subdir('script')->file('clon_fastcgi.pl');
+ my $socket = file($FindBin::Bin)->parent->subdir('tmp')->file('socket');
+
+ system "$fastcgi", '-l', "$socket", '-e';
+}
+else {
+
+ my $fh = File::Temp->new;
+
+ my $mime_types = do {
+ my $res = "mimetype.assign = (\n";
+ my %known_extensions;
+ for my $line ( file('/etc/mime.types')->slurp ) {
+ $line =~ s/\#.*//;
+
+ if ( my ( $type, $exts )
+ = $line =~ /^([a-z0-9\/+-.]+)\s+((?:[a-z0-9.+-]+[ ]?)+)$/ )
+ {
+ for my $ext ( split / /, $exts ) {
+ next if $known_extensions{$ext};
+ $known_extensions{$ext} = 1;
+ $res .= qq{".$ext" => "$type",\n};
+ }
+ }
+ }
+ $res .= ")\n";
+ $res;
+ };
+
+ my $template = <<'__CONF__';
+server.modules = (
+ "mod_fastcgi",
+)
+
+server.document-root = "[% home.subdir('root') %]"
+server.port = [% opt.port %]
+
+[% mime_types %]
+
+$HTTP["url"] =~ "^/(?!js/|css/|images?/|swf/|static/|tmp/|favicon\.ico$|crossdomain\.xml$)" {
+ fastcgi.server = (
+ "" => (
+ (
+ "socket" => "[% home.subdir('tmp').file('socket') %]",
+ "check-local" => "disable",
+ )
+ ),
+ )
+}
+
+__CONF__
+
+ my $tt = Template->new;
+ $tt->process(
+ \$template,
+ { home => dir($FindBin::Bin)->parent,
+ opt => \%opt,
+ mime_types => $mime_types,
+ },
+ \my $conf
+ );
+
+ print $fh $conf;
+
+ system( $opt{lighttpd}, '-f', $fh->filename, '-D' );
+}
111 script/clon_server.pl
@@ -0,0 +1,111 @@
+#!/usr/bin/perl -w
+
+BEGIN {
+ $ENV{CATALYST_ENGINE} ||= 'HTTP';
+ $ENV{CATALYST_SCRIPT_GEN} = 30;
+ require Catalyst::Engine::HTTP;
+}
+
+use strict;
+use warnings;
+use Getopt::Long;
+use Pod::Usage;
+use FindBin;
+use lib "$FindBin::Bin/../lib";
+
+my $debug = 0;
+my $fork = 0;
+my $help = 0;
+my $host = undef;
+my $port = $ENV{CLON_PORT} || $ENV{CATALYST_PORT} || 3000;
+my $keepalive = 0;
+my $restart = $ENV{CLON_RELOAD} || $ENV{CATALYST_RELOAD} || 0;
+my $restart_delay = 1;
+my $restart_regex = '\.yml$|\.yaml$|\.pm$';
+my $restart_directory = undef;
+
+my @argv = @ARGV;
+
+GetOptions(
+ 'debug|d' => \$debug,
+ 'fork' => \$fork,
+ 'help|?' => \$help,
+ 'host=s' => \$host,
+ 'port=s' => \$port,
+ 'keepalive|k' => \$keepalive,
+ 'restart|r' => \$restart,
+ 'restartdelay|rd=s' => \$restart_delay,
+ 'restartregex|rr=s' => \$restart_regex,
+ 'restartdirectory=s' => \$restart_directory,
+);
+
+pod2usage(1) if $help;
+
+if ( $restart && $ENV{CATALYST_ENGINE} eq 'HTTP' ) {
+ $ENV{CATALYST_ENGINE} = 'HTTP::Restarter';
+}
+if ( $debug ) {
+ $ENV{CATALYST_DEBUG} = 1;
+}
+
+# This is require instead of use so that the above environment
+# variables can be set at runtime.
+require CLON;
+
+CLON->run( $port, $host, {
+ argv => \@argv,
+ 'fork' => $fork,
+ keepalive => $keepalive,
+ restart => $restart,
+ restart_delay => $restart_delay,
+ restart_regex => qr/$restart_regex/,
+ restart_directory => $restart_directory,
+} );
+
+1;
+
+=head1 NAME
+
+clon_server.pl - Catalyst Testserver
+
+=head1 SYNOPSIS
+
+clon_server.pl [options]
+
+ Options:
+ -d -debug force debug mode
+ -f -fork handle each request in a new process
+ (defaults to false)
+ -? -help display this help and exits
+ -host host (defaults to all)
+ -p -port port (defaults to 3000)
+ -k -keepalive enable keep-alive connections
+ -r -restart restart when files get modified
+ (defaults to false)
+ -rd -restartdelay delay between file checks
+ -rr -restartregex regex match files that trigger
+ a restart when modified
+ (defaults to '\.yml$|\.yaml$|\.pm$')
+ -restartdirectory the directory to search for
+ modified files
+ (defaults to '../')
+
+ See also:
+ perldoc Catalyst::Manual
+ perldoc Catalyst::Manual::Intro
+
+=head1 DESCRIPTION
+
+Run a Catalyst Testserver for this application.
+
+=head1 AUTHOR
+
+Sebastian Riedel, C<sri@oook.de>
+Maintained by the Catalyst Core Team.
+
+=head1 COPYRIGHT
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
54 script/clon_test.pl
@@ -0,0 +1,54 @@
+#!/usr/bin/perl -w
+
+use strict;
+use warnings;
+use Getopt::Long;
+use Pod::Usage;
+use FindBin;
+use lib "$FindBin::Bin/../lib";
+use Catalyst::Test 'CLON';
+
+my $help = 0;
+
+GetOptions( 'help|?' => \$help );
+
+pod2usage(1) if ( $help || !$ARGV[0] );
+
+print request($ARGV[0])->content . "\n";
+
+1;
+
+=head1 NAME
+
+clon_test.pl - Catalyst Test
+
+=head1 SYNOPSIS
+
+clon_test.pl [options] uri
+
+ Options:
+ -help display this help and exits
+
+ Examples:
+ clon_test.pl http://localhost/some_action
+ clon_test.pl /some_action
+
+ See also:
+ perldoc Catalyst::Manual
+ perldoc Catalyst::Manual::Intro
+
+=head1 DESCRIPTION
+
+Run a Catalyst action from the command line.
+
+=head1 AUTHOR
+
+Sebastian Riedel, C<sri@oook.de>
+Maintained by the Catalyst Core Team.
+
+=head1 COPYRIGHT
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
7 t/01app.t
@@ -0,0 +1,7 @@
+use strict;
+use warnings;
+use Test::More tests => 2;
+
+BEGIN { use_ok 'Catalyst::Test', 'CLON' }
+
+ok( request('/')->is_success, 'Request should succeed' );
9 t/02pod.t
@@ -0,0 +1,9 @@
+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();
9 t/03podcoverage.t
@@ -0,0 +1,9 @@
+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();
6 t/view_TT.t
@@ -0,0 +1,6 @@
+use strict;
+use warnings;
+use Test::More tests => 1;
+
+BEGIN { use_ok 'CLON::View::TT' }
+
Please sign in to comment.
Something went wrong with that request. Please try again.