diff -Nru libcgi-application-perl-4.31/Build.PL libcgi-application-perl-4.50/Build.PL --- libcgi-application-perl-4.31/Build.PL 2009-07-30 01:41:00.000000000 +0000 +++ libcgi-application-perl-4.50/Build.PL 2011-06-16 17:05:14.000000000 +0000 @@ -1,17 +1,18 @@ -# $Id: Build.PL,v 1.2 2004/02/14 02:09:17 mark Exp $ use Module::Build; my $build = Module::Build->new ( module_name => 'CGI::Application', license => 'perl', requires => { - # For Moved vs Found change 'CGI' => 0, 'HTML::Template' => 0, 'Test::More' => 0.47, 'Carp' => 0, 'Class::ISA' => 0, }, + recommends => { + CGI::PSGI => 0.09, # If you want to use run_as_psgi() + }, 'dist_author' => [ 'Jesse Erlbaum ', 'Mark Stosberg ', diff -Nru libcgi-application-perl-4.31/Changes libcgi-application-perl-4.50/Changes --- libcgi-application-perl-4.31/Changes 2009-07-30 01:41:00.000000000 +0000 +++ libcgi-application-perl-4.50/Changes 2011-06-16 17:05:14.000000000 +0000 @@ -1,5 +1,26 @@ Revision history for CGI::Application. +4.50 Thu Jun 16, 2011 + + [FEATURES] + Better PSGI support in the core + - run_as_psgi() works like run, but directly returns the expected PSGI response structure + - psgi_app() wraps up all the PSGI bits to call and run the application and return a PSGI + code ref: + + $psgi_coderef = WebApp->psgi_app({ ... args to new() ... }); + + [DOCUMENTATION] + - docs for header_props() were improved + + [INTERNAL] + - source control management was moved from darcs to git. Those who prefer + darcs are are more familiar with it are advised to try the darcs-git.py + wrapper for git. + + - The test file psgi_app.t is missing from this release and will be added later. + + 4.31 Wed Jul 29, 2009 [FEATURES] diff -Nru libcgi-application-perl-4.31/debian/changelog libcgi-application-perl-4.50/debian/changelog --- libcgi-application-perl-4.31/debian/changelog 2011-06-27 08:38:38.000000000 +0000 +++ libcgi-application-perl-4.50/debian/changelog 2011-06-25 14:44:29.000000000 +0000 @@ -1,3 +1,27 @@ +libcgi-application-perl (4.50-1) unstable; urgency=low + + [ Nicholas Bamber ] + * Added myself to Uploaders + * New upstream release + * Raised standards version to 3.9.2 + * Added debian/source/format + * Added ErrorPage, Redirect and Standard::Config plugins as components + * Updated dependencies + - Removed versioning where not required + - Added Breaks and Replaces clauses + - Added dependencies on libcgi-psgi-perl + * Added patches for spelling errors + * Email change: Shell Hung -> shell@debian.org + * Email change: Ansgar Burchardt -> ansgar@debian.org + * Email change: Rene Mayorga -> rmayorga@debian.org + * Raised compat/debhelper to 8 + * Fixed permissions of example script + + [ gregor herrmann ] + * Add build dependencies to enable POD tests. + + -- Nicholas Bamber Fri, 24 Jun 2011 02:20:31 +0100 + libcgi-application-perl (4.31-2) unstable; urgency=low [ gregor herrmann ] diff -Nru libcgi-application-perl-4.31/debian/compat libcgi-application-perl-4.50/debian/compat --- libcgi-application-perl-4.31/debian/compat 2011-06-27 08:38:38.000000000 +0000 +++ libcgi-application-perl-4.50/debian/compat 2011-06-18 11:50:44.000000000 +0000 @@ -1 +1 @@ -7 +8 diff -Nru libcgi-application-perl-4.31/debian/components/ep/watch libcgi-application-perl-4.50/debian/components/ep/watch --- libcgi-application-perl-4.31/debian/components/ep/watch 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/debian/components/ep/watch 2011-06-18 11:50:44.000000000 +0000 @@ -0,0 +1,2 @@ +version=3 +http://search.cpan.org/dist/CGI-Application-Plugin-ErrorPage/ .*/CGI-Application-Plugin-ErrorPage-v?(\d[\d.]+)\.(?:tar(?:\.gz|\.bz2)?|tgz|zip) diff -Nru libcgi-application-perl-4.31/debian/components/r/watch libcgi-application-perl-4.50/debian/components/r/watch --- libcgi-application-perl-4.31/debian/components/r/watch 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/debian/components/r/watch 2011-06-18 11:50:44.000000000 +0000 @@ -0,0 +1,2 @@ +version=3 +http://search.cpan.org/dist/CGI-Application-Plugin-Redirect/ .*/CGI-Application-Plugin-Redirect-v?(\d[\d.]+)\.(?:tar(?:\.gz|\.bz2)?|tgz|zip) diff -Nru libcgi-application-perl-4.31/debian/components/sc/watch libcgi-application-perl-4.50/debian/components/sc/watch --- libcgi-application-perl-4.31/debian/components/sc/watch 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/debian/components/sc/watch 2011-06-23 12:03:41.000000000 +0000 @@ -0,0 +1,2 @@ +version=3 +http://search.cpan.org/dist/CGI-Application-Standard-Config/ .*/CGI-Application-Standard-Config-v?(\d[\d.]+)\.(?:tar(?:\.gz|\.bz2)?|tgz|zip) diff -Nru libcgi-application-perl-4.31/debian/control libcgi-application-perl-4.50/debian/control --- libcgi-application-perl-4.31/debian/control 2011-06-27 08:38:38.000000000 +0000 +++ libcgi-application-perl-4.50/debian/control 2011-06-25 14:38:10.000000000 +0000 @@ -3,23 +3,43 @@ Priority: optional Maintainer: Debian Perl Group Uploaders: Jaldhar H. Vyas , Niko Tyni , - Damyan Ivanov , Rene Mayorga , - Ansgar Burchardt , Dominic Hargreaves -Build-Depends: debhelper (>= 7) -Build-Depends-Indep: perl (>= 5.8.0-7), libhtml-template-perl, - libclass-isa-perl | perl (<< 5.10.1-13) -Standards-Version: 3.9.1 + Damyan Ivanov , Rene Mayorga , + Ansgar Burchardt , Dominic Hargreaves , + Nicholas Bamber +Build-Depends: debhelper (>= 8) +Build-Depends-Indep: perl, libhtml-template-perl, + libclass-isa-perl | perl (<< 5.10.1-13), pkg-components (>= 0.2), + libparams-validate-perl, libcgi-psgi-perl, + libtest-pod-perl, libtest-pod-coverage-perl +Standards-Version: 3.9.2 Homepage: http://search.cpan.org/dist/CGI-Application/ Vcs-Svn: svn://svn.debian.org/pkg-perl/trunk/libcgi-application-perl/ Vcs-Browser: http://svn.debian.org/viewsvn/pkg-perl/trunk/libcgi-application-perl/ Package: libcgi-application-perl Architecture: all -Depends: ${perl:Depends}, ${misc:Depends}, +Depends: ${perl:Depends}, ${misc:Depends}, libparams-validate-perl, libclass-isa-perl | perl (<< 5.10.1-13) -Suggests: libhtml-template-perl +Suggests: libhtml-template-perl, libcgi-psgi-perl +Breaks: libcgi-application-basic-plugin-bundle-perl (<< 0.6), + libcgi-application-plugins-perl (<< 0.11) +Replaces: libcgi-application-basic-plugin-bundle-perl (<< 0.6), + libcgi-application-plugins-perl (<< 0.11) +Provides: + libcgi-application-plugin-redirect-perl, + libcgi-application-standard-config-perl, + libcgi-application-plugin-errorpage-perl Description: framework for building reusable web-applications CGI::Application is intended to make it easier to create sophisticated, reusable web-based applications. This module implements a methodology which, if followed, will make your web software easier to design, easier to document, easier to write, and easier to evolve. + . + This package comes bundled with three extra modules providing useful glue + run modes: + . + CGI::Application::Plugin::ErrorPage - automatic handling of errors + . + CGI::Application::Plugin::Redirect - external header based redirects + . + CGI::Application::Standard::Config - defines a standard interface for config diff -Nru libcgi-application-perl-4.31/debian/copyright libcgi-application-perl-4.50/debian/copyright --- libcgi-application-perl-4.31/debian/copyright 2011-06-27 08:38:38.000000000 +0000 +++ libcgi-application-perl-4.50/debian/copyright 2011-06-25 14:29:16.000000000 +0000 @@ -1,36 +1,48 @@ -Format-Specification: - http://wiki.debian.org/Proposals/CopyrightFormat?action=recall&rev=196 -Upstream-Maintainer: Mark Stosberg -Upstream-Source: http://search.cpan.org/dist/CGI-Application/ -Upstream-Name: CGI-Application +Format-Specification: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?op=file&rev=135 +Maintainer: Mark Stosberg +Source: http://search.cpan.org/dist/CGI-Application/ +Name: CGI-Application Files: * -Copyright: © 2000-2003 Jesse Erlbaum -License: GPL-1+ | Artistic +Copyright: 2000-2003, Jesse Erlbaum +License: Artistic or GPL-1+ + +Files: r/* +Copyright: 2005, Cees Hek +License: Artistic or GPL-1+ + +Files: ep/* +Copyright: 2004, Mark Stosberg +License: Artistic or GPL-1+ + +Files: sc/* +Copyright: 2008, Mark Stosberg +License: Artistic or GPL-1+ Files: debian/* Copyright: - © 2001-2004, Shell Hung - © 2004-2008, Jaldhar H. Vyas - © 2006, Niko Tyni - © 2008, Damyan Ivanov - © 2008, Frank Lichtenheld - © 2008, gregor herrmann - © 2008, Rene Mayorga - © 2009, Ansgar Burchardt -License: GPL-1+ | Artistic - -License: GPL-1+ - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 1, or (at your option) - any later version. - On Debian GNU/Linux systems, the complete text of the GNU General - Public License can be found in `/usr/share/common-licenses/GPL' + 2001-2004, Shell Hung + 2004-2006, 2008, Jaldhar H. Vyas + 2006, Niko Tyni + 2008, Damyan Ivanov + 2008, Rene Mayorga + 2009, Ansgar Burchardt + 2011, Dominic Hargreaves + 2011, Nicholas Bamber +License: Artistic or GPL-1+ License: Artistic - This program is free software; you can redistribute it and/or modify - it under the terms of the Artistic License, which comes with Perl. - On Debian GNU/Linux systems, the complete text of the Artistic License - can be found in `/usr/share/common-licenses/Artistic' + This program is free software; you can redistribute it and/or modify + it under the terms of the Artistic License, which comes with Perl. + . + On Debian systems, the complete text of the Artistic License can be + found in `/usr/share/common-licenses/Artistic'. +License: GPL-1+ + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + . + On Debian systems, the complete text of version 1 of the GNU General + Public License can be found in `/usr/share/common-licenses/GPL-1'. diff -Nru libcgi-application-perl-4.31/debian/patches/rspelling.patch libcgi-application-perl-4.50/debian/patches/rspelling.patch --- libcgi-application-perl-4.31/debian/patches/rspelling.patch 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/debian/patches/rspelling.patch 2011-06-18 11:50:44.000000000 +0000 @@ -0,0 +1,15 @@ +Author: Nicholas Bamber +Subject: spelling +Forwarded: no +Last-Updated: 2011-06-17 +--- a/r/lib/CGI/Application/Plugin/Redirect.pm ++++ b/r/lib/CGI/Application/Plugin/Redirect.pm +@@ -85,7 +85,7 @@ + will not execute. As soon as all prerun method have finished, + the redirect will happen without the runmode being executed. + +-The $status paramater is optional as the CGI module will default to something ++The $status parameter is optional as the CGI module will default to something + suitable. + + return $self->redirect('http://www.example.com/'); diff -Nru libcgi-application-perl-4.31/debian/patches/series libcgi-application-perl-4.50/debian/patches/series --- libcgi-application-perl-4.31/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/debian/patches/series 2011-06-18 11:50:44.000000000 +0000 @@ -0,0 +1,2 @@ +spelling.patch +rspelling.patch diff -Nru libcgi-application-perl-4.31/debian/patches/spelling.patch libcgi-application-perl-4.50/debian/patches/spelling.patch --- libcgi-application-perl-4.31/debian/patches/spelling.patch 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/debian/patches/spelling.patch 2011-06-18 11:50:44.000000000 +0000 @@ -0,0 +1,15 @@ +Author: Nicholas Bamber +Subject: Spelling +Forwarded: no +Last-Update: 2011-06-17 +--- a/lib/CGI/Application.pm ++++ b/lib/CGI/Application.pm +@@ -2057,7 +2057,7 @@ + that contain JavaScript. + + Direct testing is also easy. CGI::Application will normally print the output of it's +-run modes directly to STDOUT. This can be suppressed with an enviroment variable, ++run modes directly to STDOUT. This can be suppressed with an environment variable, + CGI_APP_RETURN_ONLY. For example: + + $ENV{CGI_APP_RETURN_ONLY} = 1; diff -Nru libcgi-application-perl-4.31/debian/README.source libcgi-application-perl-4.50/debian/README.source --- libcgi-application-perl-4.31/debian/README.source 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/debian/README.source 2011-06-18 11:50:44.000000000 +0000 @@ -0,0 +1,25 @@ +For most purposes this package is a standard Debian Perl Group package. +The aspect in which it is special is that some related modules are bundled +together with the package. So long as you have the appropriate tar balls +in the correct place you can build using dpkg-buildpackage or +svn-buildpackage as you would normally. + +If you have a fresh checkout from the svn repository and you wish +to download all the tarballs to build under svn-buildpackage, then from the +package root directory run: + + ./debian/update.sh update + +To check for new updates drop the "update" argument. If you are building +under dpkg-buildpackage you need to tell the script about the +alternative build directory so run + + DESTDIR=.. ./debian/update.sh update + +There are a couple of important caveats about the update.sh script. +First of all when used in update mode it will DELETE the existing tarballs. +Secondly when you do update one of the components, the update.sh script +will need to be updated. These limitations arise because it is +a temporary work around until pkg-components (or even uscan) provides +something more substantial. + diff -Nru libcgi-application-perl-4.31/debian/rules libcgi-application-perl-4.50/debian/rules --- libcgi-application-perl-4.31/debian/rules 2011-06-27 08:38:38.000000000 +0000 +++ libcgi-application-perl-4.50/debian/rules 2011-06-24 12:23:18.000000000 +0000 @@ -1,3 +1,12 @@ #!/usr/bin/make -f + +PKG:=$(shell dh_listpackages) +TMP:=$(CURDIR)/debian/$(PKG) + %: - dh $@ + dh $@ --with components + +override_dh_installexamples: + dh_installexamples + chmod a+x $(TMP)/usr/share/doc/$(PKG)/examples/Mailform/*.cgi + diff -Nru libcgi-application-perl-4.31/debian/source/format libcgi-application-perl-4.50/debian/source/format --- libcgi-application-perl-4.31/debian/source/format 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/debian/source/format 2011-06-27 08:38:38.000000000 +0000 @@ -0,0 +1 @@ +3.0 (quilt) diff -Nru libcgi-application-perl-4.31/debian/update.sh libcgi-application-perl-4.50/debian/update.sh --- libcgi-application-perl-4.31/debian/update.sh 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/debian/update.sh 2011-06-25 14:32:51.000000000 +0000 @@ -0,0 +1,42 @@ +#!/bin/sh + +set -e + +DESTDIR=${DESTDIR:-../tarballs} +MODULE=CGI-Application +PACKAGE=libcgi-application-perl +VERSION=4.50 +REDIRECT_VERS=1.00 +STDCFG_VERS=1.01 +ERROR_VERS=1.21 +FD=--force-download +NS=--no-symlink +RE=--rename +DD="--destdir ${DESTDIR}" +RS=--report-status +DC=-"-watch debian/components" +US=--upstream-version + +if [ $1 ] +then + echo update; + rm -f ${DESTDIR}/${MODULE}*.tar.gz + uscan ${FD} ${RE} ${DD} && true; + uscan ${DC}/ep/watch ${FD} ${NS} ${DD} ${US} ${ERROR_VERS} && true; + uscan ${DC}/r/watch ${FD} ${NS} ${DD} ${US} ${REDIRECT_VERS} && true; + uscan ${DC}/sc/watch ${FD} ${NS} ${DD} ${US} ${STDCFG_VERS} && true; + cd ${DESTDIR} + REDIRECT=`ls CGI-Application-Plugin-Redirect*.tar.gz` + mv ${REDIRECT} ${PACKAGE}_${VERSION}.orig-r.tar.gz + STDCFG=`ls CGI-Application-Standard-Config*.tar.gz` + mv ${STDCFG} ${PACKAGE}_${VERSION}.orig-sc.tar.gz + ERROR=`ls CGI-Application-Plugin-ErrorPage*.tar.gz` + mv ${ERROR} ${PACKAGE}_${VERSION}.orig-ep.tar.gz + cd - +else + echo report; + uscan ${RS} && true; + uscan ${DC}/ep/watch ${RS} ${DD} ${US} ${ERROR_VERS} && true; + uscan ${DC}/sc/watch ${RS} ${DD} ${US} ${STDCFG_VERS} && true; + uscan ${DC}/r/watch ${RS} ${DD} ${US} ${REDIRECT_VERS} && true; +fi diff -Nru libcgi-application-perl-4.31/ep/Build.PL libcgi-application-perl-4.50/ep/Build.PL --- libcgi-application-perl-4.31/ep/Build.PL 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/ep/Build.PL 2009-06-27 01:46:37.000000000 +0000 @@ -0,0 +1,12 @@ +use Module::Build; +# See perldoc Module::Build for details of how this works + +Module::Build->new + ( module_name => 'CGI::Application::Plugin::ErrorPage', + license => 'perl', + requires => { + 'Test::More' => 0, + 'CGI::Application' => 0, + 'Params::Validate' => 0, + }, + )->create_build_script; diff -Nru libcgi-application-perl-4.31/ep/Changes libcgi-application-perl-4.50/ep/Changes --- libcgi-application-perl-4.31/ep/Changes 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/ep/Changes 2009-06-27 01:46:37.000000000 +0000 @@ -0,0 +1,29 @@ +Revision history for Perl module CGI::Application::Plugin::ErrorPage + +1.21 Fri Jun 26 20:48:56 EDT 2009 + No code changes. + - Clarify docs on why we ignore tmpl_path() and what you can do about it. + (Thanks to Jaldhar Vyas for feedback on this). + +1.20 Fri Nov 21 20:46:59 EST 2008 + - Bug fix: AUTOLOADed error page no longer creates a circular reference. + (RT#41130, Thanks to Bradley Bailey). + +1.12 Sun Jul 15 08:39:43 EDT 2007 + No code changes. + - explain the difference with error_mode() + +1.11 Sat Jul 14 07:39:46 EDT 2007 + No code changes. + - Include proper importing example in POD + - fix a warning in t/basic.t. + +1.10 Tue Jun 26 00:10:20 EDT 2007 + + - install a default error page into AUTOLOAD if no AUTOLOAD page is already defined. + - Add escape=HTML to template example + +1.00 Sat Jun 23 13:44:01 2007 + - original version; created by ExtUtils::ModuleMaker 0.47 + + diff -Nru libcgi-application-perl-4.31/ep/lib/CGI/Application/Plugin/ErrorPage.pm libcgi-application-perl-4.50/ep/lib/CGI/Application/Plugin/ErrorPage.pm --- libcgi-application-perl-4.31/ep/lib/CGI/Application/Plugin/ErrorPage.pm 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/ep/lib/CGI/Application/Plugin/ErrorPage.pm 2009-06-27 01:46:37.000000000 +0000 @@ -0,0 +1,242 @@ +package CGI::Application::Plugin::ErrorPage; +use strict; +use warnings; + +BEGIN { + use base 'Exporter'; + our $VERSION = '1.21'; + our @EXPORT_OK = 'error'; +} + + +=head1 NAME + +CGI::Application::Plugin::ErrorPage - A simple error page plugin for CGI::Application + +=head1 SYNOPSIS + + use CGI::Application::Plugin::ErrorPage 'error'; + + sub my_run_mode { + my $self = shift; + + eval { .... }; + + if ($@) { + # Send the gory details to the log for the developers + warn "$@"; + + # Send a comprehensible message to the users + return $self->error( + title => "Technical Failure', + msg => "There was a techical failure during the operation.", + ); + } + + } + +=head1 DESCRIPTION + +This plugin provides a shortcut for the common need of returning a simple error +message to the user. + +You are encouraged to provide a template file so that the error messages can +be presented with a design consistent with the rest of your application. + +A simple design is provided below to get to you started. + +=head2 A better default error page. + +If you don't install an AUTOLOAD run mode in the normal way in C<< setup >>, this plugin +will automatically install a reasonable default at the C<< prerun >> stage, which returns an error page like this: + + return $c->error( + title => 'The requested page was not found.', + msg => "(The page tried was: ".$c->get_current_runmode.")" + ); + +=head2 Relation to error_mode() + +CGI::Application includes C to provide custom handling when the application dies. +This error() routine provides a shortcut for displaying error messages to the user. So, they both have a +place on their own, and it could make sense to use them together. In your 'error_mode' routine, you might +call error() to return a message to the user: + + $self->error( title => 'Technical Failure', msg => 'There was a technical failure' ); + +=head2 Suggested Uses + +Some common cases for returning error messages to the user include: + + * "Technical Failure" - The software failed unexpectedly + * "Insufficient Information" - some required query parameter was missing + * "Request Not Understood" - Some value we received in the query just didn't make sense. + +=head2 Silliness + + [22:36] Techno Failure. We were cruising along and rocking out while fulfilling your request, but then the music stopped and we sort of got distracted. + [22:36] Tek Failure. Too busy reading Shatner novels to respond to your request. + +=head1 METHODS + +=head2 error() + + return $self->error( + title => "Technical Failure', + msg => "There was a techical failure during the operation", + ); + + +Nothing fancy, just a shortcut to load a template meant to display errors. I've used +it for the past several years, and it's been very handy to always have around on +projects to quickly write error handling code. + +It tries to load a template file named 'error.html' to display the error page. + +If you want to use a different location, I recommend putting something like this in your base class, +so you only have to provide your error template location once. + + + # In this case, intentionally *don't* import 'error' to avoid a "redefined" warning. + use CGI::Application::Plugin::ErrorPage; + sub error { + my $c = shift; + return $c->CGI::Application::Plugin::ErrorPage::error( + tmpl => $self->cfg('ROOT_URI').'/path/to/my/alternate/error/file.html', + @_, + ); + } + +This module intentionally ignores any C set by application, since +this is usually an indication of where the intended file is located, not the +error template. This exceptional handling of the C is one of the +only value added bits of logic that this plugin adds. The rest of it is +primarily a simple recommendation for error page handling wrapped up as a +module. + +If you don't want this behavior, it's simple enough just to roll your own error() page method +and skip using this plugin. Here's the simple essential code: + + use Params::Validate ':all'; + sub error { + my $self = shift; + my %p = validate(@_, { title => SCALAR, msg => SCALAR }); + my $t = $self->load_tmpl; + $t->param( title => $p{title}, msg => $p{msg} ); + return $t->output; + } + + +=cut + +sub import { + my $caller = scalar(caller); + $caller->add_callback('prerun', \&add_page_not_found_rm); + goto &Exporter::import; +} + +sub add_page_not_found_rm { + my $c = shift; + + my %rms = $c->run_modes; + + unless( exists $rms{'AUTOLOAD'}) { + $c->run_modes( + AUTOLOAD => sub { + my $self = shift; + return $self->error( + title => 'The requested page was not found.', + msg => "(The page tried was: ".$self->get_current_runmode.")" + ) + }); + } +} + + + + + +use Params::Validate ':all'; +sub error { + my $c = shift; + my %p = validate(@_, { + title => SCALAR, + msg => SCALAR, + # tmpl can be various types + tmpl => { default => 'error.html' }, + }); + + # If a tmpl_path has been set, we want to ignore it, because it was most + # likely meant for the template itself, not for the error page. + + # We are careful to put the value back how we found it after we are done with it here! + + my @path_to_restore = $c->tmpl_path(); + $c->tmpl_path(''); + my $t = $c->load_tmpl($p{tmpl}); + $c->tmpl_path(@path_to_restore); + + $t->param( + title => $p{title}, + msg => $p{msg}, + ); + + return $t->output; +} + + + + +=head2 Example error.html + +Here's a very basic example of an C file to get you started. + + + + + <!-- tmpl_var title escape=HTML --> + + + +

+

+ + + +We manage site-wide designs with Dreamweaver and keep a basic 'error.html' that +uses a generic Dreamweaver 'page.dwt' template with standard EditableRegion +names. That way, we can copy this error.html into a new Dreamweaver-managed +project and have the new design applied to it easily through Dreamweaver. + +=head1 SUPPORT + +Ask for help on the L mailing list. Report bugs and wishes +through the rt.cpan.org bug tracker. + +=head1 AUTHOR + + Mark Stosberg + CPAN ID: MARKSTOS + mark@summersault.com + +=head1 COPYRIGHT + +This program is free software; you can redistribute +it and/or modify it under the same terms as Perl itself. + +The full text of the license can be found in the +LICENSE file included with this module. + + +=head1 SEE ALSO + +perl(1). + +=cut + + +1; +# The preceding line will help the module return a true value + diff -Nru libcgi-application-perl-4.31/ep/LICENSE libcgi-application-perl-4.50/ep/LICENSE --- libcgi-application-perl-4.31/ep/LICENSE 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/ep/LICENSE 2009-06-27 01:46:37.000000000 +0000 @@ -0,0 +1,383 @@ +Terms of Perl itself + +a) the GNU General Public License as published by the Free + Software Foundation; either version 1, or (at your option) any + later version, or +b) the "Artistic License" + +--------------------------------------------------------------------------- + +The General Public License (GPL) +Version 2, June 1991 + +Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, +Cambridge, MA 02139, USA. Everyone is permitted to copy and distribute +verbatim copies of this license document, but changing it is not allowed. + +Preamble + +The licenses for most software are designed to take away your freedom to share +and change it. By contrast, the GNU General Public License is intended to +guarantee your freedom to share and change free software--to make sure the +software is free for all its users. This General Public License applies to most of +the Free Software Foundation's software and to any other program whose +authors commit to using it. (Some other Free Software Foundation software is +covered by the GNU Library General Public License instead.) You can apply it to +your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our +General Public Licenses are designed to make sure that you have the freedom +to distribute copies of free software (and charge for this service if you wish), that +you receive source code or can get it if you want it, that you can change the +software or use pieces of it in new free programs; and that you know you can do +these things. + +To protect your rights, we need to make restrictions that forbid anyone to deny +you these rights or to ask you to surrender the rights. These restrictions +translate to certain responsibilities for you if you distribute copies of the +software, or if you modify it. + +For example, if you distribute copies of such a program, whether gratis or for a +fee, you must give the recipients all the rights that you have. You must make +sure that they, too, receive or can get the source code. And you must show +them these terms so they know their rights. + +We protect your rights with two steps: (1) copyright the software, and (2) offer +you this license which gives you legal permission to copy, distribute and/or +modify the software. + +Also, for each author's protection and ours, we want to make certain that +everyone understands that there is no warranty for this free software. If the +software is modified by someone else and passed on, we want its recipients to +know that what they have is not the original, so that any problems introduced by +others will not reflect on the original authors' reputations. + +Finally, any free program is threatened constantly by software patents. We wish +to avoid the danger that redistributors of a free program will individually obtain +patent licenses, in effect making the program proprietary. To prevent this, we +have made it clear that any patent must be licensed for everyone's free use or +not licensed at all. + +The precise terms and conditions for copying, distribution and modification +follow. + +GNU GENERAL PUBLIC LICENSE +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND +MODIFICATION + +0. This License applies to any program or other work which contains a notice +placed by the copyright holder saying it may be distributed under the terms of +this General Public License. The "Program", below, refers to any such program +or work, and a "work based on the Program" means either the Program or any +derivative work under copyright law: that is to say, a work containing the +Program or a portion of it, either verbatim or with modifications and/or translated +into another language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not covered by +this License; they are outside its scope. The act of running the Program is not +restricted, and the output from the Program is covered only if its contents +constitute a work based on the Program (independent of having been made by +running the Program). Whether that is true depends on what the Program does. + +1. You may copy and distribute verbatim copies of the Program's source code as +you receive it, in any medium, provided that you conspicuously and appropriately +publish on each copy an appropriate copyright notice and disclaimer of warranty; +keep intact all the notices that refer to this License and to the absence of any +warranty; and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and you may at +your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion of it, thus +forming a work based on the Program, and copy and distribute such +modifications or work under the terms of Section 1 above, provided that you also +meet all of these conditions: + +a) You must cause the modified files to carry prominent notices stating that you +changed the files and the date of any change. + +b) You must cause any work that you distribute or publish, that in whole or in +part contains or is derived from the Program or any part thereof, to be licensed +as a whole at no charge to all third parties under the terms of this License. + +c) If the modified program normally reads commands interactively when run, you +must cause it, when started running for such interactive use in the most ordinary +way, to print or display an announcement including an appropriate copyright +notice and a notice that there is no warranty (or else, saying that you provide a +warranty) and that users may redistribute the program under these conditions, +and telling the user how to view a copy of this License. (Exception: if the +Program itself is interactive but does not normally print such an announcement, +your work based on the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If identifiable +sections of that work are not derived from the Program, and can be reasonably +considered independent and separate works in themselves, then this License, +and its terms, do not apply to those sections when you distribute them as +separate works. But when you distribute the same sections as part of a whole +which is a work based on the Program, the distribution of the whole must be on +the terms of this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your rights to +work written entirely by you; rather, the intent is to exercise the right to control +the distribution of derivative or collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program with the +Program (or with a work based on the Program) on a volume of a storage or +distribution medium does not bring the other work under the scope of this +License. + +3. You may copy and distribute the Program (or a work based on it, under +Section 2) in object code or executable form under the terms of Sections 1 and 2 +above provided that you also do one of the following: + +a) Accompany it with the complete corresponding machine-readable source +code, which must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange; or, + +b) Accompany it with a written offer, valid for at least three years, to give any +third party, for a charge no more than your cost of physically performing source +distribution, a complete machine-readable copy of the corresponding source +code, to be distributed under the terms of Sections 1 and 2 above on a medium +customarily used for software interchange; or, + +c) Accompany it with the information you received as to the offer to distribute +corresponding source code. (This alternative is allowed only for noncommercial +distribution and only if you received the program in object code or executable +form with such an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for making +modifications to it. For an executable work, complete source code means all the +source code for all modules it contains, plus any associated interface definition +files, plus the scripts used to control compilation and installation of the +executable. However, as a special exception, the source code distributed need +not include anything that is normally distributed (in either source or binary form) +with the major components (compiler, kernel, and so on) of the operating system +on which the executable runs, unless that component itself accompanies the +executable. + +If distribution of executable or object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the source +code from the same place counts as distribution of the source code, even though +third parties are not compelled to copy the source along with the object code. + +4. You may not copy, modify, sublicense, or distribute the Program except as +expressly provided under this License. Any attempt otherwise to copy, modify, +sublicense or distribute the Program is void, and will automatically terminate +your rights under this License. However, parties who have received copies, or +rights, from you under this License will not have their licenses terminated so long +as such parties remain in full compliance. + +5. You are not required to accept this License, since you have not signed it. +However, nothing else grants you permission to modify or distribute the Program +or its derivative works. These actions are prohibited by law if you do not accept +this License. Therefore, by modifying or distributing the Program (or any work +based on the Program), you indicate your acceptance of this License to do so, +and all its terms and conditions for copying, distributing or modifying the +Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the Program), +the recipient automatically receives a license from the original licensor to copy, +distribute or modify the Program subject to these terms and conditions. You +may not impose any further restrictions on the recipients' exercise of the rights +granted herein. You are not responsible for enforcing compliance by third parties +to this License. + +7. If, as a consequence of a court judgment or allegation of patent infringement +or for any other reason (not limited to patent issues), conditions are imposed on +you (whether by court order, agreement or otherwise) that contradict the +conditions of this License, they do not excuse you from the conditions of this +License. If you cannot distribute so as to satisfy simultaneously your obligations +under this License and any other pertinent obligations, then as a consequence +you may not distribute the Program at all. For example, if a patent license would +not permit royalty-free redistribution of the Program by all those who receive +copies directly or indirectly through you, then the only way you could satisfy +both it and this License would be to refrain entirely from distribution of the +Program. + +If any portion of this section is held invalid or unenforceable under any particular +circumstance, the balance of the section is intended to apply and the section as +a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or other +property right claims or to contest validity of any such claims; this section has +the sole purpose of protecting the integrity of the free software distribution +system, which is implemented by public license practices. Many people have +made generous contributions to the wide range of software distributed through +that system in reliance on consistent application of that system; it is up to the +author/donor to decide if he or she is willing to distribute software through any +other system and a licensee cannot impose that choice. + +This section is intended to make thoroughly clear what is believed to be a +consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in certain countries +either by patents or by copyrighted interfaces, the original copyright holder who +places the Program under this License may add an explicit geographical +distribution limitation excluding those countries, so that distribution is permitted +only in or among countries not thus excluded. In such case, this License +incorporates the limitation as if written in the body of this License. + +9. The Free Software Foundation may publish revised and/or new versions of the +General Public License from time to time. Such new versions will be similar in +spirit to the present version, but may differ in detail to address new problems or +concerns. + +Each version is given a distinguishing version number. If the Program specifies a +version number of this License which applies to it and "any later version", you +have the option of following the terms and conditions either of that version or of +any later version published by the Free Software Foundation. If the Program does +not specify a version number of this License, you may choose any version ever +published by the Free Software Foundation. + +10. If you wish to incorporate parts of the Program into other free programs +whose distribution conditions are different, write to the author to ask for +permission. For software which is copyrighted by the Free Software Foundation, +write to the Free Software Foundation; we sometimes make exceptions for this. +Our decision will be guided by the two goals of preserving the free status of all +derivatives of our free software and of promoting the sharing and reuse of +software generally. + +NO WARRANTY + +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS +NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE +COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM +"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR +IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE +ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, +YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR +CORRECTION. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED +TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY +WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS +PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES +ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM +(INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY +OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +END OF TERMS AND CONDITIONS + + +--------------------------------------------------------------------------- + +The Artistic License + +Preamble + +The intent of this document is to state the conditions under which a Package +may be copied, such that the Copyright Holder maintains some semblance of +artistic control over the development of the package, while giving the users of the +package the right to use and distribute the Package in a more-or-less customary +fashion, plus the right to make reasonable modifications. + +Definitions: + +- "Package" refers to the collection of files distributed by the Copyright + Holder, and derivatives of that collection of files created through textual + modification. +- "Standard Version" refers to such a Package if it has not been modified, + or has been modified in accordance with the wishes of the Copyright + Holder. +- "Copyright Holder" is whoever is named in the copyright or copyrights for + the package. +- "You" is you, if you're thinking about copying or distributing this Package. +- "Reasonable copying fee" is whatever you can justify on the basis of + media cost, duplication charges, time of people involved, and so on. (You + will not be required to justify it to the Copyright Holder, but only to the + computing community at large as a market that must bear the fee.) +- "Freely Available" means that no fee is charged for the item itself, though + there may be fees involved in handling the item. It also means that + recipients of the item may redistribute it under the same conditions they + received it. + +1. You may make and give away verbatim copies of the source form of the +Standard Version of this Package without restriction, provided that you duplicate +all of the original copyright notices and associated disclaimers. + +2. You may apply bug fixes, portability fixes and other modifications derived from +the Public Domain or from the Copyright Holder. A Package modified in such a +way shall still be considered the Standard Version. + +3. You may otherwise modify your copy of this Package in any way, provided +that you insert a prominent notice in each changed file stating how and when +you changed that file, and provided that you do at least ONE of the following: + + a) place your modifications in the Public Domain or otherwise + make them Freely Available, such as by posting said modifications + to Usenet or an equivalent medium, or placing the modifications on + a major archive site such as ftp.uu.net, or by allowing the + Copyright Holder to include your modifications in the Standard + Version of the Package. + + b) use the modified Package only within your corporation or + organization. + + c) rename any non-standard executables so the names do not + conflict with standard executables, which must also be provided, + and provide a separate manual page for each non-standard + executable that clearly documents how it differs from the Standard + Version. + + d) make other distribution arrangements with the Copyright Holder. + +4. You may distribute the programs of this Package in object code or executable +form, provided that you do at least ONE of the following: + + a) distribute a Standard Version of the executables and library + files, together with instructions (in the manual page or equivalent) + on where to get the Standard Version. + + b) accompany the distribution with the machine-readable source of + the Package with your modifications. + + c) accompany any non-standard executables with their + corresponding Standard Version executables, giving the + non-standard executables non-standard names, and clearly + documenting the differences in manual pages (or equivalent), + together with instructions on where to get the Standard Version. + + d) make other distribution arrangements with the Copyright Holder. + +5. You may charge a reasonable copying fee for any distribution of this Package. +You may charge any fee you choose for support of this Package. You may not +charge a fee for this Package itself. However, you may distribute this Package in +aggregate with other (possibly commercial) programs as part of a larger +(possibly commercial) software distribution provided that you do not advertise +this Package as a product of your own. + +6. The scripts and library files supplied as input to or produced as output from +the programs of this Package do not automatically fall under the copyright of this +Package, but belong to whomever generated them, and may be sold +commercially, and may be aggregated with this Package. + +7. C or perl subroutines supplied by you and linked into this Package shall not +be considered part of this Package. + +8. Aggregation of this Package with a commercial distribution is always permitted +provided that the use of this Package is embedded; that is, when no overt attempt +is made to make this Package's interfaces visible to the end user of the +commercial distribution. Such use shall not be construed as a distribution of +this Package. + +9. The name of the Copyright Holder may not be used to endorse or promote +products derived from this software without specific prior written permission. + +10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED +WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR +PURPOSE. + +The End + + diff -Nru libcgi-application-perl-4.31/ep/Makefile.PL libcgi-application-perl-4.50/ep/Makefile.PL --- libcgi-application-perl-4.31/ep/Makefile.PL 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/ep/Makefile.PL 2009-06-27 01:46:37.000000000 +0000 @@ -0,0 +1,27 @@ +unless (eval "use Module::Build::Compat 0.02; 1" ) { + print "This module requires Module::Build to install itself.\n"; + + require ExtUtils::MakeMaker; + my $yn = ExtUtils::MakeMaker::prompt + (' Install Module::Build from CPAN?', 'y'); + + if ($yn =~ /^y/i) { + require Cwd; + require File::Spec; + require CPAN; + + # Save this 'cause CPAN will chdir all over the place. + my $cwd = Cwd::cwd(); + my $makefile = File::Spec->rel2abs($0); + + CPAN::Shell->install('Module::Build::Compat'); + + chdir $cwd or die "Cannot chdir() back to $cwd: $!"; + exec $^X, $makefile, @ARGV; # Redo now that we have Module::Build + } else { + warn " *** Cannot install without Module::Build. Exiting ...\n"; + exit 1; + } +} +Module::Build::Compat->run_build_pl(args => \@ARGV); +Module::Build::Compat->write_makefile(); diff -Nru libcgi-application-perl-4.31/ep/MANIFEST libcgi-application-perl-4.50/ep/MANIFEST --- libcgi-application-perl-4.31/ep/MANIFEST 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/ep/MANIFEST 2009-06-27 01:46:37.000000000 +0000 @@ -0,0 +1,10 @@ +MANIFEST +README +LICENSE +Changes +t/basic.t +t/pod.t +Build.PL +Makefile.PL +lib/CGI/Application/Plugin/ErrorPage.pm +META.yml diff -Nru libcgi-application-perl-4.31/ep/META.yml libcgi-application-perl-4.50/ep/META.yml --- libcgi-application-perl-4.31/ep/META.yml 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/ep/META.yml 2009-06-27 01:46:37.000000000 +0000 @@ -0,0 +1,20 @@ +--- +name: CGI-Application-Plugin-ErrorPage +version: 1.21 +author: +abstract: A simple error page plugin for CGI::Application +license: perl +requires: + CGI::Application: 0 + Params::Validate: 0 + Test::More: 0 +generated_by: Module::Build version 0.32 +meta-spec: + url: http://module-build.sourceforge.net/META-spec-v1.2.html + version: 1.2 +provides: + CGI::Application::Plugin::ErrorPage: + file: lib/CGI/Application/Plugin/ErrorPage.pm + version: 1.21 +resources: + license: ~ diff -Nru libcgi-application-perl-4.31/ep/README libcgi-application-perl-4.50/ep/README --- libcgi-application-perl-4.31/ep/README 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/ep/README 2009-06-27 01:46:37.000000000 +0000 @@ -0,0 +1,15 @@ +pod2text CGI::Application::Plugin::ErrorPage.pm > README + +If this is still here it means the programmer was too lazy to create the readme file. + +You can create it now by using the command shown above from this directory. + +At the very least you should be able to use this set of instructions +to install the module... + +perl Build.PL +./Build +./Build test +./Build install + +If you are on a windows box you should use 'nmake' rather than 'make'. diff -Nru libcgi-application-perl-4.31/ep/t/basic.t libcgi-application-perl-4.50/ep/t/basic.t --- libcgi-application-perl-4.31/ep/t/basic.t 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/ep/t/basic.t 2009-06-27 01:46:37.000000000 +0000 @@ -0,0 +1,36 @@ + +package foo; + +use base CGI::Application; +use CGI::Application::Plugin::ErrorPage 'error'; + +no warnings 'redefine'; +sub error { + my $c = shift; + return $c->CGI::Application::Plugin::ErrorPage::error( + tmpl => \'Surprise! ', + @_, + ); +} + + +package main; +use Test::More 'no_plan'; + +$ENV{CGI_APP_RETURN_ONLY} = 1; + +use CGI; +my $q = CGI->new; +$q->param('rm' => 'missing'); +my $foo = foo->new( QUERY => $q ); + +is( + $foo->error( title => 'Technical Failure', msg => 'BOOM!'), + 'Surprise! Technical Failure BOOM!', +); + +like( + $foo->run, + qr/\QSurprise! The requested page was not found. (The page tried was: missing)/, + "testing AUTOLOAD default functionality" +); diff -Nru libcgi-application-perl-4.31/ep/t/pod.t libcgi-application-perl-4.50/ep/t/pod.t --- libcgi-application-perl-4.31/ep/t/pod.t 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/ep/t/pod.t 2009-06-27 01:46:37.000000000 +0000 @@ -0,0 +1,6 @@ +#!perl -T + +use Test::More; +eval "use Test::Pod 1.14"; +plan skip_all => "Test::Pod 1.14 required for testing POD" if $@; +all_pod_files_ok(); diff -Nru libcgi-application-perl-4.31/lib/CGI/Application.pm libcgi-application-perl-4.50/lib/CGI/Application.pm --- libcgi-application-perl-4.31/lib/CGI/Application.pm 2009-07-30 01:41:00.000000000 +0000 +++ libcgi-application-perl-4.50/lib/CGI/Application.pm 2011-06-16 17:05:14.000000000 +0000 @@ -3,7 +3,7 @@ use strict; use Class::ISA; -$CGI::Application::VERSION = '4.31'; +$CGI::Application::VERSION = '4.50'; my %INSTALLED_CALLBACKS = ( # hook name package sub @@ -196,21 +196,50 @@ # Call cgiapp_postrun() hook $self->call_hook('postrun', \$body); - # Set up HTTP headers - my $headers = $self->_send_headers(); - - # Build up total output - my $output = $headers.$body; + my $return_value; + if ($self->{__IS_PSGI}) { + my ($status, $headers) = $self->_send_psgi_headers(); + $return_value = [ $status, $headers, [ $body ]]; + } + else { + # Set up HTTP headers non-PSGI responses + my $headers = $self->_send_headers(); - # Send output to browser (unless we're in serious debug mode!) - unless ($ENV{CGI_APP_RETURN_ONLY}) { - print $output; - } + # Build up total output + $return_value = $headers.$body; + print $return_value unless $ENV{CGI_APP_RETURN_ONLY}; + } # clean up operations $self->call_hook('teardown'); - return $output; + return $return_value; +} + + +sub psgi_app { + my $class = shift; + my $args_to_new = shift; + + return sub { + my $env = shift; + + if (not defined $args_to_new->{QUERY}) { + require CGI::PSGI; + $args_to_new->{QUERY} = CGI::PSGI->new($env); + } + + my $webapp = $class->new($args_to_new); + return $webapp->run_as_psgi; + } +} + +sub run_as_psgi { + my $self = shift; + $self->{__IS_PSGI} = 1; + + # Run doesn't officially support any args, but pass them through in case some sub-class uses them. + return $self->run(@_); } @@ -601,6 +630,7 @@ ########################### +# return headers as a string sub _send_headers { my $self = shift; my $q = $self->query; @@ -613,6 +643,20 @@ : croak "Invalid header_type '$type'" } +# return a 2 element array modeling the first PSGI redirect values: status code and arrayref of header pairs +sub _send_psgi_headers { + my $self = shift; + my $q = $self->query; + my $type = $self->header_type; + + return + $type eq 'redirect' ? $q->psgi_redirect( $self->header_props ) + : $type eq 'header' ? $q->psgi_header ( $self->header_props ) + : $type eq 'none' ? '' + : croak "Invalid header_type '$type'" + +} + # Make all hash keys CAPITAL # although this method is internal, some other extensions @@ -671,6 +715,10 @@ my $webapp = WebApp->new(); $webapp->run(); + ### Or, in a PSGI file, webapp.psgi + use WebApp; + WebApp->psgi_app(); + =head1 INTRODUCTION CGI::Application makes it easier to create sophisticated, high-performance, @@ -971,7 +1019,69 @@ the specified mode is not found in the run_modes() table, run() will croak(). -=head2 Methods to possibly override +=head2 PSGI support + +CGI::Application offers native L support. The default query object +for this is L, which simply wrappers CGI.pm to provide PSGI +support to it. + +=head3 psgi_app() + + $psgi_coderef = WebApp->psgi_app({ ... args to new() ... }); + +The simplest way to create and return a PSGI-compatible coderef. Pass in +arguments to a hashref just as would to new. This returns a PSGI-compatible +coderef, using L as the query object. To use a different query +object, construct your own object using C<< run_as_psgi() >>, as shown below. + +It's possible that we'll change from CGI::PSGI to a different-but-compatible +query object for PSGI support in the future, perhaps if CGI.pm adds native +PSGI support. + +=head3 run_as_psgi() + + my $psgi_aref = $webapp->run_as_psgi; + +Just like C<< run >>, but prints no output and returns the data structure +required by the L specification. Use this if you want to run the +application on top of a PSGI-compatible handler, such as L provides. + +If you are just getting started, just use C<< run() >>. It's easy to switch to using +C<< run_as_psgi >> later. + +Why use C<< run_as_psgi() >>? There are already solutions to run +CGI::Application-based projects on several web servers with dozens of plugins. +Running as a PSGI-compatible application provides the ability to run on +additional PSGI-compatible servers, as well as providing access to all of the +"Middleware" solutions available through the L project. + +The structure returned is an arrayref, containing the status code, an arrayref +of header key/values and an arrayref containing the body. + + [ 200, [ 'Content-Type' => 'text/html' ], [ $body ] ] + +By default the body is a single scalar, but plugins may modify this to return +other value PSGI values. See L for details about the +response format. + +Note that calling C<< run_as_psgi >> only handles the I portion of the +PSGI spec. to handle the input, you need to use a CGI.pm-like query object that +is PSGI-compliant, such as L. This query object must provide L +and L methods. + +The final result might look like this: + + use WebApp; + use CGI::PSGI; + + my $handler = sub { + my $env = shift; + my $webapp = WebApp->new({ QUERY => CGI::PSGI->new($env) }); + $webapp->run_as_psgi; + }; + + +=head2 Methods to possibly override CGI::Application implements some methods which are expected to be overridden by implementing them in your sub-class module. These methods are as follows: @@ -1596,17 +1706,24 @@ =head3 header_props() - $webapp->header_props(-type=>'image/gif',-expires=>'+3d'); + # Set a complete set of headers + %set_headers = $webapp->header_props(-type=>'image/gif',-expires=>'+3d'); + + # clobber / reset all headers + %set_headers = $webapp->header_props({}); + + # Just retrieve the headers + %set_headers = $webapp->header_props(); The C method expects a hash of CGI.pm-compatible HTTP header properties. These properties will be passed directly -to CGI.pm's C or C methods. Refer to L -for exact usage details. +to the C or C methods of the query() object. Refer +to the docs of your query object for details. (Be default, it's L.pm). -Calling header_props any arguments will clobber any existing headers that have +Calling header_props with an empty hashref clobber any existing headers that have previously set. -C return a hash of all the headers that have currently been +C returns a hash of all the headers that have currently been set. It can be called with no arguments just to get the hash current headers back. @@ -2349,10 +2466,9 @@ B -This project is managed using the darcs source control system ( -http://www.darcs.net/ ). The darcs archive is here: -http://mark.stosberg.com/darcs_hive/cgi-app +This project is managed using git and is available on Github: + https://github.com/markstos/CGI--Application =head1 SEE ALSO diff -Nru libcgi-application-perl-4.31/Makefile.PL libcgi-application-perl-4.50/Makefile.PL --- libcgi-application-perl-4.31/Makefile.PL 2009-07-30 01:41:00.000000000 +0000 +++ libcgi-application-perl-4.50/Makefile.PL 2011-06-16 17:05:14.000000000 +0000 @@ -1,7 +1,8 @@ -# Note: this file was auto-generated by Module::Build::Compat version 0.32 +# Note: this file was auto-generated by Module::Build::Compat version 0.3800 use ExtUtils::MakeMaker; WriteMakefile ( + 'PL_FILES' => {}, 'INSTALLDIRS' => 'site', 'NAME' => 'CGI::Application', 'EXE_FILES' => [], diff -Nru libcgi-application-perl-4.31/MANIFEST libcgi-application-perl-4.50/MANIFEST --- libcgi-application-perl-4.31/MANIFEST 2009-07-30 01:41:00.000000000 +0000 +++ libcgi-application-perl-4.50/MANIFEST 2011-06-16 17:05:14.000000000 +0000 @@ -28,6 +28,7 @@ t/mode_param_overwritten.t t/load_tmpl_hook.t t/query.t +t/run_as_psgi.t t/lib/TestApp.pm t/lib/TestApp2.pm t/lib/TestApp3.pm @@ -44,3 +45,4 @@ t/lib/TestApp14.pm t/lib/TestCGI.pm t/lib/templates/test.tmpl +META.json diff -Nru libcgi-application-perl-4.31/META.json libcgi-application-perl-4.50/META.json --- libcgi-application-perl-4.31/META.json 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/META.json 2011-06-16 17:05:14.000000000 +0000 @@ -0,0 +1,57 @@ +{ + "abstract" : "Framework for building reusable web-applications", + "author" : [ + "Jesse Erlbaum ", + "Mark Stosberg ", + "with the help of many others!" + ], + "dynamic_config" : 1, + "generated_by" : "Module::Build version 0.38, CPAN::Meta::Converter version 2.110930", + "license" : [ + "perl_5" + ], + "meta-spec" : { + "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", + "version" : "2" + }, + "name" : "CGI-Application", + "no_index" : { + "file" : [] + }, + "prereqs" : { + "configure" : { + "requires" : { + "Module::Build" : "0.38" + } + }, + "runtime" : { + "recommends" : { + "CGI::PSGI" : "0.09" + }, + "requires" : { + "CGI" : 0, + "Carp" : 0, + "Class::ISA" : 0, + "HTML::Template" : 0, + "Test::More" : "0.47" + } + } + }, + "provides" : { + "CGI::Application" : { + "file" : "lib/CGI/Application.pm", + "version" : "4.50" + }, + "CGI::Application::Mailform" : { + "file" : "lib/CGI/Application/Mailform.pm", + "version" : 0 + } + }, + "release_status" : "stable", + "resources" : { + "license" : [ + "http://dev.perl.org/licenses/" + ] + }, + "version" : "4.50" +} diff -Nru libcgi-application-perl-4.31/META.yml libcgi-application-perl-4.50/META.yml --- libcgi-application-perl-4.31/META.yml 2009-07-30 01:41:00.000000000 +0000 +++ libcgi-application-perl-4.50/META.yml 2011-06-16 17:05:14.000000000 +0000 @@ -1,29 +1,36 @@ --- -name: CGI-Application -version: 4.31 +abstract: 'Framework for building reusable web-applications' author: - 'Jesse Erlbaum ' - 'Mark Stosberg ' - - "with the help of many others!" -abstract: Framework for building reusable web-applications + - 'with the help of many others!' +build_requires: {} +configure_requires: + Module::Build: 0.38 +dynamic_config: 1 +generated_by: 'Module::Build version 0.38, CPAN::Meta::Converter version 2.110930' license: perl -requires: - CGI: 0 - Carp: 0 - Class::ISA: 0 - HTML::Template: 0 - Test::More: 0.47 -generated_by: Module::Build version 0.32 meta-spec: - url: http://module-build.sourceforge.net/META-spec-v1.2.html - version: 1.2 + url: http://module-build.sourceforge.net/META-spec-v1.4.html + version: 1.4 +name: CGI-Application no_index: - file: + file: [] provides: CGI::Application: file: lib/CGI/Application.pm - version: 4.31 + version: 4.50 CGI::Application::Mailform: file: lib/CGI/Application/Mailform.pm + version: 0 +recommends: + CGI::PSGI: 0.09 +requires: + CGI: 0 + Carp: 0 + Class::ISA: 0 + HTML::Template: 0 + Test::More: 0.47 resources: - license: ~ + license: http://dev.perl.org/licenses/ +version: 4.50 diff -Nru libcgi-application-perl-4.31/r/Build.PL libcgi-application-perl-4.50/r/Build.PL --- libcgi-application-perl-4.31/r/Build.PL 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/r/Build.PL 2008-03-02 13:08:19.000000000 +0000 @@ -0,0 +1,13 @@ +use Module::Build; + +Module::Build->new( + module_name => 'CGI::Application::Plugin::Redirect', + license => 'perl', + requires => { + 'CGI::Application' => 0, + }, + create_makefile_pl => 'traditional', + dist_author => 'Cees Hek ', + dist_abstract => 'Easy external redirects in CGI::Application', +)->create_build_script; + diff -Nru libcgi-application-perl-4.31/r/Changes libcgi-application-perl-4.50/r/Changes --- libcgi-application-perl-4.31/r/Changes 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/r/Changes 2008-03-02 13:08:19.000000000 +0000 @@ -0,0 +1,10 @@ +Revision history for Perl extension CGI::Application::Plugin::Redirect. + +1.00 Mon Mar 3 00:07:39 EST 2008 + + - allow a status option to be passed to 'redirect' + (viorels -at- gmail.com) + +0.10 Tue Sep 13 15:20:02 EDT 2005 + + - original version diff -Nru libcgi-application-perl-4.31/r/lib/CGI/Application/Plugin/Redirect.pm libcgi-application-perl-4.50/r/lib/CGI/Application/Plugin/Redirect.pm --- libcgi-application-perl-4.31/r/lib/CGI/Application/Plugin/Redirect.pm 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/r/lib/CGI/Application/Plugin/Redirect.pm 2008-03-02 13:08:19.000000000 +0000 @@ -0,0 +1,122 @@ +package CGI::Application::Plugin::Redirect; + +use strict; +use vars qw($VERSION @EXPORT); + +$VERSION = '1.00'; + +require Exporter; + +@EXPORT = qw( + redirect +); + +sub import { goto &Exporter::import } + +sub redirect { + my $self = shift; + my $location = shift; + my $status = shift; + + # The eval may fail, but we don't care + eval { + $self->run_modes( dummy_redirect => sub { } ); + $self->prerun_mode('dummy_redirect'); + }; + + if ($status) { + $self->header_add( -location => $location, -status => $status ); + } else { + $self->header_add( -location => $location ); + } + $self->header_type('redirect'); + return; +} + +1; +__END__ + +=head1 NAME + +CGI::Application::Plugin::Redirect - Easy external redirects in CGI::Application + + +=head1 SYNOPSIS + + package My::App; + + use CGI::Application::Plugin::Redirect; + + sub cgiapp_prerun { + my $self = shift; + + if ( << not logged in >> ) { + return $self->redirect('login.html'); + } + } + + sub byebye { + my $self = shift; + + return $self->redirect('http://www.example.com/', '301 Moved Permanently'); + } + + +=head1 DESCRIPTION + +This plugin provides an easy way to do external redirects in CGI::Application. +You don't have to worry about setting headers or worrying about return types, as +that is all handled for you. + +C does an external redirect, which means that the browser will receive +a command to load a new page, and a fresh request will come in. If you just want to +display the results of another runmode within the same module, then it is often +sufficient to use the C method in L instead. + + +=head1 METHODS + + +=head2 redirect($url, $status) + +Interupt the current request, and redirect to an external URL. If +you happen to be inside a prerun method when you call this, the +current runmode will automatically be short circuited so that it +will not execute. As soon as all prerun method have finished, +the redirect will happen without the runmode being executed. + +The $status paramater is optional as the CGI module will default to something +suitable. + + return $self->redirect('http://www.example.com/'); + + - or - + + return $self->redirect('http://www.example.com/', '301 Moved Permanently'); + + +=head1 SEE ALSO + +L, L, perl(1) + + +=head1 AUTHOR + +Cees Hek + + +=head1 LICENCE AND COPYRIGHT + +Copyright (c) 2005, Cees Hek. All rights reserved. + +This module is free software; you can redistribute it and/or modify +it under the same terms as Perl itself. + + +=head1 DISCLAIMER OF WARRANTY + +BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED ORIMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. + +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSESSUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +=cut diff -Nru libcgi-application-perl-4.31/r/Makefile.PL libcgi-application-perl-4.50/r/Makefile.PL --- libcgi-application-perl-4.31/r/Makefile.PL 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/r/Makefile.PL 2008-03-02 13:08:19.000000000 +0000 @@ -0,0 +1,13 @@ +# Note: this file was auto-generated by Module::Build::Compat version 0.03 +use ExtUtils::MakeMaker; +WriteMakefile +( + 'PL_FILES' => {}, + 'INSTALLDIRS' => 'site', + 'NAME' => 'CGI::Application::Plugin::Redirect', + 'VERSION_FROM' => 'lib/CGI/Application/Plugin/Redirect.pm', + 'PREREQ_PM' => { + 'CGI::Application' => 0 + } + ) +; diff -Nru libcgi-application-perl-4.31/r/MANIFEST libcgi-application-perl-4.50/r/MANIFEST --- libcgi-application-perl-4.31/r/MANIFEST 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/r/MANIFEST 2008-03-02 13:08:19.000000000 +0000 @@ -0,0 +1,10 @@ +Build.PL +Changes +lib/CGI/Application/Plugin/Redirect.pm +MANIFEST This list of files +META.yml +README +t/01_basic.t +t/98_pod.t +t/99_pod_coverage.t +Makefile.PL diff -Nru libcgi-application-perl-4.31/r/META.yml libcgi-application-perl-4.50/r/META.yml --- libcgi-application-perl-4.31/r/META.yml 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/r/META.yml 2008-03-02 13:08:19.000000000 +0000 @@ -0,0 +1,14 @@ +--- +name: CGI-Application-Plugin-Redirect +version: 1.00 +author: + - 'Cees Hek ' +abstract: Easy external redirects in CGI::Application +license: perl +requires: + CGI::Application: 0 +provides: + CGI::Application::Plugin::Redirect: + file: lib/CGI/Application/Plugin/Redirect.pm + version: 1.00 +generated_by: Module::Build version 0.26 diff -Nru libcgi-application-perl-4.31/r/README libcgi-application-perl-4.50/r/README --- libcgi-application-perl-4.31/r/README 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/r/README 2008-03-02 13:08:19.000000000 +0000 @@ -0,0 +1,31 @@ +CGI::Application::Plugin::Redirect + +Easy external redirects in CGI::Application + + +INSTALLATION + +To install this module, run the following commands: + + perl Build.PL + ./Build + ./Build test + ./Build install + + +Alternatively, if you do not have Module::Build but you do have 'make', +you can used the included Makefile.PL and run the following commands: + + perl Makefile.PL + make + make test + make install + + +COPYRIGHT AND LICENCE + +Copyright (c) 2005, Cees Hek. All rights reserved. + +This module is free software; you can redistribute it and/or modify +it under the same terms as Perl itself. + diff -Nru libcgi-application-perl-4.31/r/t/01_basic.t libcgi-application-perl-4.50/r/t/01_basic.t --- libcgi-application-perl-4.31/r/t/01_basic.t 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/r/t/01_basic.t 2008-03-02 13:08:19.000000000 +0000 @@ -0,0 +1,65 @@ +use Test::More tests => 8; +BEGIN { use_ok('CGI::Application::Plugin::Redirect') } + +use lib './t'; +use strict; + +$ENV{CGI_APP_RETURN_ONLY} = 1; + +{ + + package TestAppBasic; + + use CGI::Application; + @TestAppBasic::ISA = qw(CGI::Application); + use CGI::Application::Plugin::Redirect; + + sub setup { + my $self = shift; + $self->start_mode('test_mode'); + $self->run_modes( test_mode => 'test_mode' ); + } + + sub cgiapp_prerun { + my $self = shift; + + if ($self->param('PRERUN_TEST')) { + return $self->redirect('http://example.com/'); + } + } + + sub test_mode { + my $self = shift; + + if ($self->param('RUNMODE_TEST')) { + return $self->redirect('http://other.example.com/'); + } elsif ($self->param('RUNMODE_STATUS_TEST')) { + return $self->redirect('http://status.example.com/', '301 Moved Permanently'); + } + return "test_mode return value"; + } + +}; + +# Test redirect in prerun +my $t1_obj = TestAppBasic->new( PARAMS => { PRERUN_TEST => 1 } ); +my $t1_output = $t1_obj->run(); + +unlike( $t1_output, qr/test_mode return value/, 'test_mode return value' ); +like( $t1_output, qr{Location:\s+http://example\.com/}, 'Location set correctly' ); + +# test redirect in runmode +$t1_obj = TestAppBasic->new( PARAMS => { RUNMODE_TEST => 1 } ); +$t1_output = $t1_obj->run(); + +unlike( $t1_output, qr/test_mode return value/, 'test_mode return value' ); +like( $t1_output, qr{Location:\s+http://other\.example\.com/}, 'Location set correctly' ); + +# test redirect with a custom status value +$t1_obj = TestAppBasic->new( PARAMS => { RUNMODE_STATUS_TEST => 1 } ); +$t1_output = $t1_obj->run(); + +unlike( $t1_output, qr/test_mode return value/, 'test_mode return value' ); +like( $t1_output, qr{Location:\s+http://status\.example\.com/}, 'Location set correctly' ); +like( $t1_output, qr{Status:\s+301 Moved Permanently}, 'Status set correctly' ); + diff -Nru libcgi-application-perl-4.31/r/t/98_pod.t libcgi-application-perl-4.50/r/t/98_pod.t --- libcgi-application-perl-4.31/r/t/98_pod.t 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/r/t/98_pod.t 2008-03-02 13:08:19.000000000 +0000 @@ -0,0 +1,4 @@ +use Test::More; +eval "use Test::Pod 1.00"; +plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; +all_pod_files_ok(); diff -Nru libcgi-application-perl-4.31/r/t/99_pod_coverage.t libcgi-application-perl-4.50/r/t/99_pod_coverage.t --- libcgi-application-perl-4.31/r/t/99_pod_coverage.t 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/r/t/99_pod_coverage.t 2008-03-02 13:08:19.000000000 +0000 @@ -0,0 +1,4 @@ +use Test::More; +eval "use Test::Pod::Coverage 1.00"; +plan skip_all => "Test::Pod::Coverage 1.00 required for testing POD coverage" if $@; +all_pod_coverage_ok(); diff -Nru libcgi-application-perl-4.31/sc/Build.PL libcgi-application-perl-4.50/sc/Build.PL --- libcgi-application-perl-4.31/sc/Build.PL 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/sc/Build.PL 2008-09-04 10:14:33.000000000 +0000 @@ -0,0 +1,18 @@ +use strict; +use warnings; +use Module::Build; + +my $builder = Module::Build->new( + module_name => 'CGI::Application::Standard::Config', + license => 'perl', + dist_author => 'Mark Stosberg ', + dist_version_from => 'lib/CGI/Application/Standard/Config.pm', + create_makefile_pl => 'traditional', + create_readme => 1, + build_requires => { + 'Test::More' => 0, + }, + add_to_cleanup => [ 'CGI-Application-Standard-Config-*' ], +); + +$builder->create_build_script(); diff -Nru libcgi-application-perl-4.31/sc/Changes libcgi-application-perl-4.50/sc/Changes --- libcgi-application-perl-4.31/sc/Changes 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/sc/Changes 2008-09-04 10:14:33.000000000 +0000 @@ -0,0 +1,8 @@ +Revision history for CGI-Application-Standard-Config + +1.01 Thu Sep 4 06:13:36 EDT 2008 + * Add explicit copyright and license statement. + +1.00 Sat Feb 18 23:53:06 EST 2006 + First version, released on an unsuspecting world. + diff -Nru libcgi-application-perl-4.31/sc/lib/CGI/Application/Standard/Config.pm libcgi-application-perl-4.50/sc/lib/CGI/Application/Standard/Config.pm --- libcgi-application-perl-4.31/sc/lib/CGI/Application/Standard/Config.pm 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/sc/lib/CGI/Application/Standard/Config.pm 2008-09-04 10:14:33.000000000 +0000 @@ -0,0 +1,182 @@ +package CGI::Application::Standard::Config; +use base 'Exporter'; +use vars (qw/@EXPORT $VERSION/); + +$VERSION = '1.01'; + +# Note: We are loading the config plugin into our callers +# namespace, not our own! +sub import { + my $class = shift; + my $app = caller; + + # Export a stub config if there is not one defined already. + if (not _meet_config_standard($app) ) { + push @EXPORT, (qw/config std_config/); + } +} + +sub config { return undef }; +sub std_config { return 1 }; + +sub _meet_config_standard { + my $app = shift; + if ( $app->can('config') + # If they declared they meet the standard, we trust 'em. + and $app->can('std_config') ) { + return 1; + } + else { + return 0; + } +} + +=pod + +Last updated: Sat Feb 18 23:42:29 EST 2006 + +=head1 NAME + +CGI::Application::Standard::Config -- Define a standard configuration API for CGI::Application + +=head1 RATIONALE + +This module defines a minimum standard interface that configuration plugins for +CGI::Application should meet. Having such a standard allows other plugin +authors to rely on basic configuration functionality without coding exceptions +for several configuration modules, or giving up on such integration. + +=head1 SYNOPSIS + +=head2 For Average Users + +Simply load the config plugin before other modules that might use it: + + use CGI::Application::Plugin::ConfigAuto; + use CGI::Application::Plugin::Session; + +=head2 For Configuration plugin authors + +Configuration plugin authors only need to follow the standards documented below. + +=head2 For other plugin authors who wish to rely on the standard + +Plugin authors who want to possibly use this standard can do so by simply +using this module: + + package CGI::Application::Plugin::Session; + use CGI::Application::Standard::Config; + +If a standards complaint config module hasn't already been loaded a stub for +L will be added which will safely return C. + +=head3 Example use by another plugin + +Here code first tries to get configuration details first from a +config file, then from options passed to a plugin-specific config +method, and finally applies defaults if no configuration options are found. + + my $session_options = $self->config('Session_options') + || $self->session_config() + || $self->session_defaults; + +=head1 Standard Interface Definition + +The following defines a minimum standard for configuration plugins to meet. + +Config plugins are free to provide to additional functionality. + +Configuration plugins are also encourage to explicity document that +they are using C. + +If there are existing methods that follow the standard but have +different names, you can use this example to always export your method: + + sub import { + my $app = caller; + no strict 'refs'; + my $full_name = $app . '::config'; + # Change cfg to your config()-compliant method name + *$full_name = \&cfg; + CGI::Application::Plugin::YourNameHere->export_to_level(1,@_); + } + +=head2 $self->std_config + +This method should be exported by default to simply declare that you meet the +standard report which version of the standard you meet. This simple +implementation is recommended: + + sub std_config { return 1; } + +=head2 $self->config + +The intended use is to load to read-only configuration details once +from a config file at start up time. + +This service is provided by plugins (list below). They must support at +at least this syntax: + + my $value = $self->config('key'); + +By default, C simply returns undef, making it safe for other +plugins to directly to check if C<$self->config('key')> returns the +value it needs. + +config() must be exported by default. + +For applications that need little configuration, L is not +necessary-- using C in an instance script should suffice. + +Also, the C is the appropriate method to use to set a +configuration value at run time. + +Configuration plugins that provide at least this basic API include: + +=over 4 + +=item L. + +=back + +=cut + +=head3 Standard config variables + +Users are encouraged to use these standard config variable names, to +ease compatibility between plugins: + + ROOT_URI - A URI corresponding to the project root (http://foo.com/proj ) + ROOT_DIR - a file system path to the same location ( /home/joe/www/proj ) + +All-caps are used to denote that config variables are essentially global +constants. + +Why URI and not URL? The wikipedia explains: + + The contemporary point of view among the working group that oversees URIs is + that the terms URL and URN are context-dependent aspects of URI and rarely + need to be distinguished. Furthermore, the term URL is increasingly becoming + obsolete, as it is rarely necessary to differentiate between URLs and URIs, + in general. + +=head1 Standard Version + +This is 1.0 of the CGI::Application L standard. + +=head1 AUTHOR + +Written by Mark Stosberg with input from the +CGI::Application community. + +=head1 COPYRIGHT and LICENSE + +Copyright (C) 2008, Mark Stosberg. All rights reserved. + +This library is free software; you can redistribute it and/or modify it under +the same terms as Perl itself. + +=cut + +1; + diff -Nru libcgi-application-perl-4.31/sc/Makefile.PL libcgi-application-perl-4.50/sc/Makefile.PL --- libcgi-application-perl-4.31/sc/Makefile.PL 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/sc/Makefile.PL 2008-09-04 10:14:33.000000000 +0000 @@ -0,0 +1,13 @@ +# Note: this file was auto-generated by Module::Build::Compat version 0.03 +use ExtUtils::MakeMaker; +WriteMakefile +( + 'NAME' => 'CGI::Application::Standard::Config', + 'VERSION_FROM' => 'lib/CGI/Application/Standard/Config.pm', + 'PREREQ_PM' => { + 'Test::More' => '0' + }, + 'INSTALLDIRS' => 'site', + 'PL_FILES' => {} + ) +; diff -Nru libcgi-application-perl-4.31/sc/MANIFEST libcgi-application-perl-4.50/sc/MANIFEST --- libcgi-application-perl-4.31/sc/MANIFEST 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/sc/MANIFEST 2008-09-04 10:14:32.000000000 +0000 @@ -0,0 +1,11 @@ +Build.PL +Changes +MANIFEST +META.yml # Will be created by "make dist" +README +lib/CGI/Application/Standard/Config.pm +t/00-load.t +t/boilerplate.t +t/pod-coverage.t +t/pod.t +Makefile.PL diff -Nru libcgi-application-perl-4.31/sc/META.yml libcgi-application-perl-4.50/sc/META.yml --- libcgi-application-perl-4.31/sc/META.yml 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/sc/META.yml 2008-09-04 10:14:33.000000000 +0000 @@ -0,0 +1,14 @@ +--- #YAML:1.0 +name: CGI-Application-Standard-Config +version: 1.01 +author: + - Mark Stosberg +abstract: ~ +license: perl +build_requires: + Test::More: 0 +provides: + CGI::Application::Standard::Config: + file: lib/CGI/Application/Standard/Config.pm + version: 1.01 +generated_by: Module::Build version 0.2611 diff -Nru libcgi-application-perl-4.31/sc/README libcgi-application-perl-4.50/sc/README --- libcgi-application-perl-4.31/sc/README 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/sc/README 2008-09-04 10:14:33.000000000 +0000 @@ -0,0 +1,127 @@ + Last updated: Sat Feb 18 23:42:29 EST 2006 + +NAME + CGI::Application::Standard::Config -- Define a standard configuration + API for CGI::Application + +RATIONALE + This module defines a minimum standard interface that configuration + plugins for CGI::Application should meet. Having such a standard allows + other plugin authors to rely on basic configuration functionality + without coding exceptions for several configuration modules, or giving + up on such integration. + +SYNOPSIS + For Average Users + Simply load the config plugin before other modules that might use it: + + use CGI::Application::Plugin::ConfigAuto; + use CGI::Application::Plugin::Session; + + For Configuration plugin authors + Configuration plugin authors only need to follow the standards + documented below. + + For other plugin authors who wish to rely on the standard + Plugin authors who want to possibly use this standard can do so by + simply using this module: + + package CGI::Application::Plugin::Session; + use CGI::Application::Standard::Config; + + If a standards complaint config module hasn't already been loaded a stub + for config() will be added which will safely return "undef". + + Example use by another plugin + Here code first tries to get configuration details first from a config + file, then from options passed to a plugin-specific config method, and + finally applies defaults if no configuration options are found. + + my $session_options = $self->config('Session_options') + || $self->session_config() + || $self->session_defaults; + +Standard Interface Definition + The following defines a minimum standard for configuration plugins to + meet. + + Config plugins are free to provide to additional functionality. + + Configuration plugins are also encourage to explicity document that they + are using "CGI::Application::Standard::Config". + + If there are existing methods that follow the standard but have + different names, you can use this example to always export your method: + + sub import { + my $app = caller; + no strict 'refs'; + my $full_name = $app . '::config'; + # Change cfg to your config()-compliant method name + *$full_name = \&cfg; + CGI::Application::Plugin::YourNameHere->export_to_level(1,@_); + } + + $self->std_config + This method should be exported by default to simply declare that you + meet the standard report which version of the standard you meet. This + simple implementation is recommended: + + sub std_config { return 1; } + + $self->config + The intended use is to load to read-only configuration details once from + a config file at start up time. + + This service is provided by plugins (list below). They must support at + at least this syntax: + + my $value = $self->config('key'); + + By default, "config()" simply returns undef, making it safe for other + plugins to directly to check if "$self-"config('key')> returns the value + it needs. + + config() must be exported by default. + + For applications that need little configuration, config() is not + necessary-- using "PARAMS" in an instance script should suffice. + + Also, the "param()" is the appropriate method to use to set a + configuration value at run time. + + Configuration plugins that provide at least this basic API include: + + CGI::Application::Plugin::ConfigAuto. + + Standard config variables + Users are encouraged to use these standard config variable names, to + ease compatibility between plugins: + + ROOT_URI - A URI corresponding to the project root (http://foo.com/proj ) + ROOT_DIR - a file system path to the same location ( /home/joe/www/proj ) + + All-caps are used to denote that config variables are essentially global + constants. + + Why URI and not URL? The wikipedia explains: + + The contemporary point of view among the working group that oversees URIs is + that the terms URL and URN are context-dependent aspects of URI and rarely + need to be distinguished. Furthermore, the term URL is increasingly becoming + obsolete, as it is rarely necessary to differentiate between URLs and URIs, + in general. + +Standard Version + This is 1.0 of the CGI::Application config() standard. + +AUTHOR + Written by Mark Stosberg with input from the + CGI::Application community. + +COPYRIGHT and LICENSE + Copyright (C) 2008, Mark Stosberg. All rights reserved. + + This library is free software; you can redistribute it and/or modify it + under the same terms as Perl itself. + diff -Nru libcgi-application-perl-4.31/sc/t/00-load.t libcgi-application-perl-4.50/sc/t/00-load.t --- libcgi-application-perl-4.31/sc/t/00-load.t 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/sc/t/00-load.t 2008-09-04 10:14:33.000000000 +0000 @@ -0,0 +1,9 @@ +#!perl -T + +use Test::More tests => 1; + +BEGIN { + use_ok( 'CGI::Application::Standard::Config' ); +} + +diag( "Testing CGI::Application::Standard::Config $CGI::Application::Standard::Config::VERSION, Perl $], $^X" ); diff -Nru libcgi-application-perl-4.31/sc/t/boilerplate.t libcgi-application-perl-4.50/sc/t/boilerplate.t --- libcgi-application-perl-4.31/sc/t/boilerplate.t 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/sc/t/boilerplate.t 2008-09-04 10:14:32.000000000 +0000 @@ -0,0 +1,48 @@ +#!perl -T + +use strict; +use warnings; +use Test::More tests => 3; + +sub not_in_file_ok { + my ($filename, %regex) = @_; + open my $fh, "<", $filename + or die "couldn't open $filename for reading: $!"; + + my %violated; + + while (my $line = <$fh>) { + while (my ($desc, $regex) = each %regex) { + if ($line =~ $regex) { + push @{$violated{$desc}||=[]}, $.; + } + } + } + + if (%violated) { + fail("$filename contains boilerplate text"); + diag "$_ appears on lines @{$violated{$_}}" for keys %violated; + } else { + pass("$filename contains no boilerplate text"); + } +} + +not_in_file_ok(README => + "The README is used..." => qr/The README is used/, + "'version information here'" => qr/to provide version information/, +); + +not_in_file_ok(Changes => + "placeholder date/time" => qr(Date/time) +); + +sub module_boilerplate_ok { + my ($module) = @_; + not_in_file_ok($module => + 'the great new $MODULENAME' => qr/ - The great new /, + 'boilerplate description' => qr/Quick summary of what the module/, + 'stub function definition' => qr/function[12]/, + ); +} + +module_boilerplate_ok('lib/CGI/Application/Standard/Config.pm'); diff -Nru libcgi-application-perl-4.31/sc/t/pod-coverage.t libcgi-application-perl-4.50/sc/t/pod-coverage.t --- libcgi-application-perl-4.31/sc/t/pod-coverage.t 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/sc/t/pod-coverage.t 2008-09-04 10:14:33.000000000 +0000 @@ -0,0 +1,6 @@ +#!perl -T + +use Test::More; +eval "use Test::Pod::Coverage 1.04"; +plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@; +all_pod_coverage_ok(); diff -Nru libcgi-application-perl-4.31/sc/t/pod.t libcgi-application-perl-4.50/sc/t/pod.t --- libcgi-application-perl-4.31/sc/t/pod.t 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/sc/t/pod.t 2008-09-04 10:14:33.000000000 +0000 @@ -0,0 +1,6 @@ +#!perl -T + +use Test::More; +eval "use Test::Pod 1.14"; +plan skip_all => "Test::Pod 1.14 required for testing POD" if $@; +all_pod_files_ok(); diff -Nru libcgi-application-perl-4.31/t/header_props.t libcgi-application-perl-4.50/t/header_props.t --- libcgi-application-perl-4.31/t/header_props.t 2009-07-30 01:41:00.000000000 +0000 +++ libcgi-application-perl-4.50/t/header_props.t 2011-06-16 17:05:14.000000000 +0000 @@ -1,6 +1,6 @@ use strict; -use Test::More tests => 6; +use Test::More tests => 9; BEGIN{use_ok('CGI::Application');} @@ -63,3 +63,32 @@ ); } +{ + my $app = CGI::Application->new; + + $app->header_props({ -type => 'banana/ripe' }); + + like( + $app->run, + qr{Content-type: banana/ripe}i, + "headed added via hashref arg to header_props", + ); + + $app->header_props(); + + like( + $app->run, + qr{Content-type: banana/ripe}i, + "Calling with no args is safe", + ); + + $app->header_props({}); + + unlike( + $app->run, + qr{Content-type: banana/ripe}i, + "Calling with an empty hashref clobbers existing data", + ); + +} + diff -Nru libcgi-application-perl-4.31/t/run_as_psgi.t libcgi-application-perl-4.50/t/run_as_psgi.t --- libcgi-application-perl-4.31/t/run_as_psgi.t 1970-01-01 00:00:00.000000000 +0000 +++ libcgi-application-perl-4.50/t/run_as_psgi.t 2011-06-16 17:05:14.000000000 +0000 @@ -0,0 +1,48 @@ + +use Test::More; +use CGI::Application; + +eval { require CGI::PSGI; }; +# XXX, really, we need CGI::PSGI 0.09 or later. +if ($@) { + plan 'skip_all' => 'CGI::PSGI is not available'; +} +else { + plan 'no_plan'; +} + + +# Set up a CGI environment +my $env; +$env->{REQUEST_METHOD} = 'GET'; +$env->{QUERY_STRING} = 'game=chess&game=checkers&weather=dull'; +$env->{PATH_INFO} = '/somewhere/else'; +$env->{PATH_TRANSLATED} = '/usr/local/somewhere/else'; +$env->{SCRIPT_NAME} = '/cgi-bin/foo.cgi'; +$env->{SERVER_PROTOCOL} = 'HTTP/1.0'; +$env->{SERVER_PORT} = 8080; +$env->{SERVER_NAME} = 'the.good.ship.lollypop.com'; +$env->{REQUEST_URI} = "$env->{SCRIPT_NAME}$env->{PATH_INFO}?$env->{QUERY_STRING}"; +$env->{HTTP_LOVE} = 'true'; + +package TestApp; +use base 'CGI::Application'; +sub setup { + my $self = shift; + $self->run_modes( + start => sub { 'Hello World' }, + ); +} + +package main; + +my $app = TestApp->new( QUERY => CGI::PSGI->new($env) ); + +my $response = $app->run_as_psgi; + +is_deeply $response, [ + '200', + [ 'Content-Type' => 'text/html; charset=ISO-8859-1' ], + [ 'Hello World' ], +], +"run_as_psgi: reality check basic response";