[Catalyst-commits] r6938 - / trunk
trunk/Catalyst-Controller-reCAPTCHA
trunk/Catalyst-Controller-reCAPTCHA/lib
trunk/Catalyst-Controller-reCAPTCHA/lib/CatalystX
trunk/Catalyst-Controller-reCAPTCHA/lib/CatalystX/Controller
trunk/Catalyst-Controller-reCAPTCHA/t
trunk/Catalyst-Controller-reCAPTCHA/t/author
trunk/Catalyst-Controller-reCAPTCHA/t/lib
trunk/Catalyst-Controller-reCAPTCHA/t/lib/TestApp
trunk/Catalyst-Controller-reCAPTCHA/t/lib/TestApp/Controller
trunk/Catalyst-Controller-reCAPTCHA/t/lib/script
zarquon at dev.catalyst.perl.org
zarquon at dev.catalyst.perl.org
Mon Sep 24 23:55:36 GMT 2007
Author: zarquon
Date: 2007-09-24 23:55:36 +0100 (Mon, 24 Sep 2007)
New Revision: 6938
Added:
trunk/Catalyst-Controller-reCAPTCHA/
trunk/Catalyst-Controller-reCAPTCHA/Changes
trunk/Catalyst-Controller-reCAPTCHA/META.yml
trunk/Catalyst-Controller-reCAPTCHA/Makefile.PL
trunk/Catalyst-Controller-reCAPTCHA/README
trunk/Catalyst-Controller-reCAPTCHA/TODO
trunk/Catalyst-Controller-reCAPTCHA/lib/
trunk/Catalyst-Controller-reCAPTCHA/lib/CatalystX/
trunk/Catalyst-Controller-reCAPTCHA/lib/CatalystX/Controller/
trunk/Catalyst-Controller-reCAPTCHA/lib/CatalystX/Controller/reCAPTCHA.pm
trunk/Catalyst-Controller-reCAPTCHA/t/
trunk/Catalyst-Controller-reCAPTCHA/t/00-load.t
trunk/Catalyst-Controller-reCAPTCHA/t/author/
trunk/Catalyst-Controller-reCAPTCHA/t/author/pod-coverage.t
trunk/Catalyst-Controller-reCAPTCHA/t/author/pod.t
trunk/Catalyst-Controller-reCAPTCHA/t/lib/
trunk/Catalyst-Controller-reCAPTCHA/t/lib/Makefile.PL
trunk/Catalyst-Controller-reCAPTCHA/t/lib/TestApp.pm
trunk/Catalyst-Controller-reCAPTCHA/t/lib/TestApp/
trunk/Catalyst-Controller-reCAPTCHA/t/lib/TestApp/Controller/
trunk/Catalyst-Controller-reCAPTCHA/t/lib/TestApp/Controller/Root.pm
trunk/Catalyst-Controller-reCAPTCHA/t/lib/script/
trunk/Catalyst-Controller-reCAPTCHA/t/lib/script/testapp_server.pl
trunk/Catalyst-Controller-reCAPTCHA/t/lib/script/testapp_test.pl
trunk/Catalyst-Controller-reCAPTCHA/t/live-test.t
Modified:
/
Log:
r11768 at zaphod: kd | 2007-09-25 08:06:11 +1000
moving from CatalystX to Catalyst *sigh*
Property changes on:
___________________________________________________________________
Name: svk:merge
- 1b129c88-ebf4-0310-add9-f09427935aba:/local/catalyst:4278
1c72fc7c-9ce4-42af-bf25-3bfe470ff1e8:/local/Catalyst:11766
3b9770f9-e80c-0410-a7de-cd203d167417:/local/catalyst:3514
dd8ad9ea-0304-0410-a433-df5f223e7bc0:/local/Catalyst:6909
+ 1b129c88-ebf4-0310-add9-f09427935aba:/local/catalyst:4278
1c72fc7c-9ce4-42af-bf25-3bfe470ff1e8:/local/Catalyst:11768
3b9770f9-e80c-0410-a7de-cd203d167417:/local/catalyst:3514
dd8ad9ea-0304-0410-a433-df5f223e7bc0:/local/Catalyst:6909
Added: trunk/Catalyst-Controller-reCAPTCHA/Changes
===================================================================
--- trunk/Catalyst-Controller-reCAPTCHA/Changes (rev 0)
+++ trunk/Catalyst-Controller-reCAPTCHA/Changes 2007-09-24 22:55:36 UTC (rev 6938)
@@ -0,0 +1,4 @@
+# This file documents the revision history for the perl extension Catalyst::Controller::reCAPTCHA
+
+0.1
+ - Initial version that supplies two : Private methods in your controller to deal with the reCAPTCHA
\ No newline at end of file
Added: trunk/Catalyst-Controller-reCAPTCHA/META.yml
===================================================================
--- trunk/Catalyst-Controller-reCAPTCHA/META.yml (rev 0)
+++ trunk/Catalyst-Controller-reCAPTCHA/META.yml 2007-09-24 22:55:36 UTC (rev 6938)
@@ -0,0 +1,19 @@
+abstract: authenticate people and read books!
+author: and Copyright
+build_requires:
+ Catalyst::Runtime: 0
+ Test::More: 0
+ Test::WWW::Mechanize::Catalyst: 0
+ ok: 0
+distribution_type: module
+generated_by: Module::Install version 0.64
+license: perl
+name: Catalyst-Controller-reCAPTCHA
+no_index:
+ directory:
+ - inc
+ - t
+requires:
+ Captcha::reCAPTCHA: 0
+ perl: 5.8.1
+version: 0.1
Added: trunk/Catalyst-Controller-reCAPTCHA/Makefile.PL
===================================================================
--- trunk/Catalyst-Controller-reCAPTCHA/Makefile.PL (rev 0)
+++ trunk/Catalyst-Controller-reCAPTCHA/Makefile.PL 2007-09-24 22:55:36 UTC (rev 6938)
@@ -0,0 +1,19 @@
+use inc::Module::Install;
+
+my $module = 'Catalyst::Controller::reCAPTCHA';
+
+my $dist = $module;
+$dist =~ s/::/-/g;
+name($dist);
+
+my @path = split '::', $module;
+all_from('lib/'. (join '/', at path). '.pm');
+requires 'perl' => '5.8.1';
+build_requires 'Catalyst::Runtime';
+build_requires 'Test::WWW::Mechanize::Catalyst';
+build_requires 'Test::More';
+build_requires 'ok';
+
+requires 'Captcha::reCAPTCHA';
+
+WriteAll();
Added: trunk/Catalyst-Controller-reCAPTCHA/README
===================================================================
--- trunk/Catalyst-Controller-reCAPTCHA/README (rev 0)
+++ trunk/Catalyst-Controller-reCAPTCHA/README 2007-09-24 22:55:36 UTC (rev 6938)
@@ -0,0 +1,2 @@
+Catalyst base controller for dealing with reCAPTCHAs in order to deter
+scripts.
\ No newline at end of file
Added: trunk/Catalyst-Controller-reCAPTCHA/TODO
===================================================================
--- trunk/Catalyst-Controller-reCAPTCHA/TODO (rev 0)
+++ trunk/Catalyst-Controller-reCAPTCHA/TODO 2007-09-24 22:55:36 UTC (rev 6938)
@@ -0,0 +1,3 @@
+Also provide methods for Captcha::reCAPTCHA::Mailhide
+
+Maybe fix Test::WWW::Mechanize::Catalyst tests.
\ No newline at end of file
Added: trunk/Catalyst-Controller-reCAPTCHA/lib/CatalystX/Controller/reCAPTCHA.pm
===================================================================
--- trunk/Catalyst-Controller-reCAPTCHA/lib/CatalystX/Controller/reCAPTCHA.pm (rev 0)
+++ trunk/Catalyst-Controller-reCAPTCHA/lib/CatalystX/Controller/reCAPTCHA.pm 2007-09-24 22:55:36 UTC (rev 6938)
@@ -0,0 +1,92 @@
+package Catalyst::Controller::reCAPTCHA;
+use strict;
+use warnings;
+use base 'Catalyst::Controller';
+use Captcha::reCAPTCHA;
+our $VERSION = '0.1';
+
+
+sub captcha_get : Private {
+ my ($self, $c) = @_;
+ my $cap = Captcha::reCAPTCHA->new;
+ $c->stash->{recaptcha} = $cap->get_html($c->config->{recaptcha}->{pub_key});
+}
+
+sub captcha_check : Private {
+ my ($self, $c) = @_;
+ my $cap = Captcha::reCAPTCHA->new;
+ my $result = {};
+ if ( $c->req->param( 'recaptcha_response_field' ) ) {
+ $result = $cap->check_answer(
+ $c->config->{recaptcha}->{priv_key}, $ENV{'REMOTE_ADDR'},
+ $c->req->param('recaptcha_challenge_field'),
+ $c->req->param('recaptcha_response_field')
+ );
+ }
+ else {
+ $c->stash->{recaptcha_ok} = "User appears not to have submitted a recaptcha";
+ }
+
+ if ( $result->{is_valid} ) {
+ $c->stash->{recaptcha_ok} = 1;
+ }
+ else {
+ $c->stash->{recaptcha_ok} = $result->{error};
+ }
+}
+
+
+
+=head1 NAME
+
+Catalyst::Controller::reCAPTCHA - authenticate people and read books!
+
+=head1 SUMMARY
+
+Catalyst::Controller wrapper around L<Capatcha::reCAPTCHA>. Provides
+a number of C<Private> methods that deal with the recaptcha.
+
+=head2 CONFIGURATION
+
+In MyApp.pm (or equivalent in config file):
+
+ __PACKAGE__->config->{recaptcha}->{pub_key} = '6LcsbAAAAAAAAPDSlBaVGXjMo1kJHwUiHzO2TDze';
+ __PACKAGE__->config->{recaptcha}->{priv_key} = '6LcsbAAAAAAAANQQGqwsnkrTd7QTGRBKQQZwBH-L';
+
+(the two keys above work for http://localhost).
+
+=head2 METHOD
+
+captcha_get : Private
+
+Sets $c->stash->{recaptcha} to be the html form for the L<http://recaptcha.net/> reCAPTCHA service which can be included in your HTML form.
+
+=head2 METHOD
+
+captcha_check : Private
+
+Validates the reCaptcha using L<Captcha::reCAPTCHA>. sets
+$c->stash->{recaptcha_ok} which will be 1 on success or an error
+string provided by L<Captcha::reCAPTCHA> on failure.
+
+=head2 EXAMPLES
+
+See the t/lib/TestApp example in the
+L<Catalyst::Controller::reCAPTCHA> distribution.
+
+=head1 SEE ALSO
+
+L<Captcha::reCAPTCHA>, L<Catalyst::Controller>, L<Catalyst>.
+
+=head1 AUTHOR and Copyright
+
+Kieren Diment L<zarquon at cpan.org>.
+
+=head1 LICENCE
+
+This library is free software, you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
+=cut
+
+1;
Added: trunk/Catalyst-Controller-reCAPTCHA/t/00-load.t
===================================================================
--- trunk/Catalyst-Controller-reCAPTCHA/t/00-load.t (rev 0)
+++ trunk/Catalyst-Controller-reCAPTCHA/t/00-load.t 2007-09-24 22:55:36 UTC (rev 6938)
@@ -0,0 +1,6 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use Test::More tests => 1;
+use ok 'Catalyst::Controller::reCAPTCHA';
Property changes on: trunk/Catalyst-Controller-reCAPTCHA/t/00-load.t
___________________________________________________________________
Name: svn:mime-type
+ text/script
Added: trunk/Catalyst-Controller-reCAPTCHA/t/author/pod-coverage.t
===================================================================
--- trunk/Catalyst-Controller-reCAPTCHA/t/author/pod-coverage.t (rev 0)
+++ trunk/Catalyst-Controller-reCAPTCHA/t/author/pod-coverage.t 2007-09-24 22:55:36 UTC (rev 6938)
@@ -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();
Added: trunk/Catalyst-Controller-reCAPTCHA/t/author/pod.t
===================================================================
--- trunk/Catalyst-Controller-reCAPTCHA/t/author/pod.t (rev 0)
+++ trunk/Catalyst-Controller-reCAPTCHA/t/author/pod.t 2007-09-24 22:55:36 UTC (rev 6938)
@@ -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();
Added: trunk/Catalyst-Controller-reCAPTCHA/t/lib/Makefile.PL
===================================================================
Added: trunk/Catalyst-Controller-reCAPTCHA/t/lib/TestApp/Controller/Root.pm
===================================================================
--- trunk/Catalyst-Controller-reCAPTCHA/t/lib/TestApp/Controller/Root.pm (rev 0)
+++ trunk/Catalyst-Controller-reCAPTCHA/t/lib/TestApp/Controller/Root.pm 2007-09-24 22:55:36 UTC (rev 6938)
@@ -0,0 +1,22 @@
+package TestApp::Controller::Root;
+use strict;
+use warnings;
+
+__PACKAGE__->config(namespace => q{});
+
+use base 'Catalyst::Controller::reCAPTCHA';
+
+sub index :Private {
+ my ($self, $c) = @_;
+ $c->forward('captcha_get');
+ my $body ='<html> <body> <p> recaptcha error: '. $c->stash->{recaptcha_ok} . '</p><form name="recaptcha" action="'. $c->uri_for('/check') . '" method="post">'. $c->stash->{recaptcha}.' <br/> <input type="submit" value="submit" /> </form>';
+ $c->res->body($body);
+}
+
+sub check : Local {
+ my ($self, $c) = @_;
+ $c->forward('captcha_check');
+ $c->detach('index');
+}
+
+1;
Added: trunk/Catalyst-Controller-reCAPTCHA/t/lib/TestApp.pm
===================================================================
--- trunk/Catalyst-Controller-reCAPTCHA/t/lib/TestApp.pm (rev 0)
+++ trunk/Catalyst-Controller-reCAPTCHA/t/lib/TestApp.pm 2007-09-24 22:55:36 UTC (rev 6938)
@@ -0,0 +1,13 @@
+package TestApp;
+use strict;
+use warnings;
+
+use Catalyst;
+
+__PACKAGE__->config->{recaptcha}->{pub_key} = '6LcsbAAAAAAAAPDSlBaVGXjMo1kJHwUiHzO2TDze';
+__PACKAGE__->config->{recaptcha}->{priv_key} = '6LcsbAAAAAAAANQQGqwsnkrTd7QTGRBKQQZwBH-L';
+
+
+__PACKAGE__->setup;
+
+1;
Added: trunk/Catalyst-Controller-reCAPTCHA/t/lib/script/testapp_server.pl
===================================================================
--- trunk/Catalyst-Controller-reCAPTCHA/t/lib/script/testapp_server.pl (rev 0)
+++ trunk/Catalyst-Controller-reCAPTCHA/t/lib/script/testapp_server.pl 2007-09-24 22:55:36 UTC (rev 6938)
@@ -0,0 +1,121 @@
+#!/usr/bin/env perl
+
+BEGIN {
+ $ENV{CATALYST_ENGINE} ||= 'HTTP';
+ $ENV{CATALYST_SCRIPT_GEN} = 31;
+ require Catalyst::Engine::HTTP;
+}
+
+use strict;
+use warnings;
+use Getopt::Long;
+use Pod::Usage;
+use FindBin;
+use lib "$FindBin::Bin/..";
+
+my $debug = 0;
+my $fork = 0;
+my $help = 0;
+my $host = undef;
+my $port = 3000;
+my $keepalive = 0;
+my $restart = 0;
+my $restart_delay = 1;
+my $restart_regex = '\.yml$|\.yaml$|\.pm$';
+my $restart_directory = undef;
+my $background = 0;
+my $pidfile = "/tmp/testapp.pid";
+
+my @argv = @ARGV;
+
+GetOptions(
+ 'debug|d' => \$debug,
+ 'fork' => \$fork,
+ 'help|?' => \$help,
+ 'host=s' => \$host,
+ 'port=s' => \$port,
+ 'keepalive|k' => \$keepalive,
+ 'restart|r' => \$restart,
+ 'restartdelay|rd=s' => \$restart_delay,
+ 'restartregex|rr=s' => \$restart_regex,
+ 'restartdirectory=s' => \$restart_directory,
+ 'daemon' => \$background,
+ 'pidfile=s' => \$pidfile,
+);
+
+pod2usage(1) if $help;
+
+if ( $restart ) {
+ $ENV{CATALYST_ENGINE} = 'HTTP::Restarter';
+}
+if ( $debug ) {
+ $ENV{CATALYST_DEBUG} = 1;
+}
+
+# This is require instead of use so that the above environment
+# variables can be set at runtime.
+require TestApp;
+
+TestApp->run( $port, $host, {
+ argv => \@argv,
+ 'fork' => $fork,
+ keepalive => $keepalive,
+ restart => $restart,
+ restart_delay => $restart_delay,
+ restart_regex => qr/$restart_regex/,
+ restart_directory => $restart_directory,
+ background => $background,
+ pidfile => $pidfile,
+} );
+
+1;
+
+=head1 NAME
+
+testapp_server.pl - Catalyst Testserver
+
+=head1 SYNOPSIS
+
+testapp_server.pl [options]
+
+ Options:
+ -d -debug force debug mode
+ -f -fork handle each request in a new process
+ (defaults to false)
+ -? -help display this help and exits
+ -host host (defaults to all)
+ -p -port port (defaults to 3000)
+ -k -keepalive enable keep-alive connections
+ -r -restart restart when files get modified
+ (defaults to false)
+ -rd -restartdelay delay between file checks
+ -rr -restartregex regex match files that trigger
+ a restart when modified
+ (defaults to '\.yml$|\.yaml$|\.pm$')
+ -restartdirectory the directory to search for
+ modified files
+ (defaults to '../')
+
+ -daemon background the server
+ -pidfile=filename store the pid if the server in filename, if
+ daemonizing
+
+ See also:
+ perldoc Catalyst::Manual
+ perldoc Catalyst::Manual::Intro
+
+=head1 DESCRIPTION
+
+Run a Catalyst Testserver for this application.
+
+=head1 AUTHOR
+
+Sebastian Riedel, C<sri at 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
Property changes on: trunk/Catalyst-Controller-reCAPTCHA/t/lib/script/testapp_server.pl
___________________________________________________________________
Name: svn:mime-type
+ text/script
Added: trunk/Catalyst-Controller-reCAPTCHA/t/lib/script/testapp_test.pl
===================================================================
--- trunk/Catalyst-Controller-reCAPTCHA/t/lib/script/testapp_test.pl (rev 0)
+++ trunk/Catalyst-Controller-reCAPTCHA/t/lib/script/testapp_test.pl 2007-09-24 22:55:36 UTC (rev 6938)
@@ -0,0 +1,12 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/..";
+use Catalyst::Test 'TestApp';
+
+print request($ARGV[0])->content . "\n";
+
+1;
Property changes on: trunk/Catalyst-Controller-reCAPTCHA/t/lib/script/testapp_test.pl
___________________________________________________________________
Name: svn:mime-type
+ text/script
Added: trunk/Catalyst-Controller-reCAPTCHA/t/live-test.t
===================================================================
--- trunk/Catalyst-Controller-reCAPTCHA/t/live-test.t (rev 0)
+++ trunk/Catalyst-Controller-reCAPTCHA/t/live-test.t 2007-09-24 22:55:36 UTC (rev 6938)
@@ -0,0 +1,31 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use Test::More qw/no_plan/;
+
+# setup library path
+use FindBin qw($Bin);
+use lib "$Bin/lib";
+
+# make sure testapp works
+use ok 'TestApp';
+
+# a live test against TestApp, the test application - can't get the
+# form submission working right now :-/ and doing this too much gets
+# your local machine blacklisted from the recaptcha server for a bit
+# anyway :-/
+
+use Test::WWW::Mechanize::Catalyst 'TestApp';
+my $mech = Test::WWW::Mechanize::Catalyst->new;
+$mech->get_ok('http://localhost/', 'get main page');
+# $mech->submit_form(
+# form_name => 'recaptcha',
+# fields => { recaptcha_response_field => 'wrong',
+# });
+# $mech->content_lacks('recaptcha error: 1'); # obviously we can't test success automatically :/
+
+
+
+
+
Property changes on: trunk/Catalyst-Controller-reCAPTCHA/t/live-test.t
___________________________________________________________________
Name: svn:mime-type
+ text/script
More information about the Catalyst-commits
mailing list