Permalink
Browse files

initial import

  • Loading branch information...
0 parents commit 4847b6352ab786b39799ad8dd2be12165c81c82a @typester committed Apr 28, 2008
Showing with 577 additions and 0 deletions.
  1. +4 −0 Changes
  2. +16 −0 Makefile.PL
  3. +1 −0 README
  4. +7 −0 clon.yml
  5. +16 −0 lib/CLON.pm
  6. +22 −0 lib/CLON/Controller/Root.pm
  7. +31 −0 lib/CLON/View/TT.pm
  8. +37 −0 script/clon_cgi.pl
  9. +75 −0 script/clon_create.pl
  10. +80 −0 script/clon_fastcgi.pl
  11. +92 −0 script/clon_lighty.pl
  12. +111 −0 script/clon_server.pl
  13. +54 −0 script/clon_test.pl
  14. +7 −0 t/01app.t
  15. +9 −0 t/02pod.t
  16. +9 −0 t/03podcoverage.t
  17. +6 −0 t/view_TT.t
@@ -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
@@ -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.
@@ -0,0 +1,7 @@
+---
+name: CLON
+
+default_view: TT
+View::TT:
+ INCLUDE_PATH: __path_to(templates)__
+# WRAPPER: common/wrapper.tt
@@ -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;
@@ -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;
@@ -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;
@@ -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
@@ -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
@@ -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
@@ -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' );
+}
Oops, something went wrong.

0 comments on commit 4847b63

Please sign in to comment.