[Jifty-commit] r1418 - in jifty: . trunk/plugins/LetMe trunk/plugins/LetMe/doc trunk/plugins/LetMe/lib trunk/plugins/LetMe/lib/Jifty trunk/plugins/LetMe/lib/Jifty/Plugin trunk/plugins/LetMe/lib/Jifty/Plugin/LetMe/Action trunk/plugins/LetMe/lib/Jifty/Plugin/LetMe/Model trunk/plugins/LetMe/share trunk/plugins/LetMe/share/po trunk/plugins/LetMe/share/web trunk/plugins/LetMe/share/web/static trunk/plugins/LetMe/share/web/templates trunk/plugins/LetMe/t

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Sat Jul 1 16:13:16 EDT 2006


Author: nelhage
Date: Sat Jul  1 16:13:15 2006
New Revision: 1418

Added:
   jifty/trunk/plugins/LetMe/
   jifty/trunk/plugins/LetMe/Makefile.PL
   jifty/trunk/plugins/LetMe/doc/
   jifty/trunk/plugins/LetMe/lib/
   jifty/trunk/plugins/LetMe/lib/Jifty/
   jifty/trunk/plugins/LetMe/lib/Jifty/Plugin/
   jifty/trunk/plugins/LetMe/lib/Jifty/Plugin/LetMe/
   jifty/trunk/plugins/LetMe/lib/Jifty/Plugin/LetMe.pm
   jifty/trunk/plugins/LetMe/lib/Jifty/Plugin/LetMe/Action/
   jifty/trunk/plugins/LetMe/lib/Jifty/Plugin/LetMe/Dispatcher.pm
   jifty/trunk/plugins/LetMe/lib/Jifty/Plugin/LetMe/Model/
   jifty/trunk/plugins/LetMe/share/
   jifty/trunk/plugins/LetMe/share/po/
   jifty/trunk/plugins/LetMe/share/web/
   jifty/trunk/plugins/LetMe/share/web/static/
   jifty/trunk/plugins/LetMe/share/web/templates/
   jifty/trunk/plugins/LetMe/t/
Modified:
   jifty/   (props changed)

Log:
 r13503 at phanatique:  nelhage | 2006-06-30 13:37:19 +0200
 Adding a LetMe plugin to handle the stock /let/ dispatcher rules we've been using. Not adding this to Wifty because it's somehow generating perl segfaults.


Added: jifty/trunk/plugins/LetMe/Makefile.PL
==============================================================================
--- (empty file)
+++ jifty/trunk/plugins/LetMe/Makefile.PL	Sat Jul  1 16:13:15 2006
@@ -0,0 +1,8 @@
+use inc::Module::Install;
+name('Jifty-Plugin-LetMe');
+version('0.01');
+requires('Jifty' => '0.60615');
+
+install_share;
+
+WriteAll;

Added: jifty/trunk/plugins/LetMe/lib/Jifty/Plugin/LetMe.pm
==============================================================================
--- (empty file)
+++ jifty/trunk/plugins/LetMe/lib/Jifty/Plugin/LetMe.pm	Sat Jul  1 16:13:15 2006
@@ -0,0 +1,48 @@
+use strict;
+use warnings;
+
+=head1 NAME
+
+Jifty::Plugin::LetMe
+
+=cut
+
+package Jifty::Plugin::LetMe;
+use base qw/Jifty::Plugin/;
+
+=head1 DESCRIPTION
+
+C<Jifty::Plugin::LetMe> provides a simple way to enable URLs generated
+by L<Jifty::LetMe/as_url>.
+
+When a user follows a URL created by
+L<Jifty::LetMe::as_url|Jifty::LetMe/as_url>, C<Jifty::Plugin::LetMe>
+will check if the URL is valid, and, if so, set request arguments for
+each of C<$letme->args>, as well as setting the request argument
+C<let_me> to the decoded LetMe itself. It will then show the Mason
+component C<< '/let/' . $letme->path >>.
+
+By default, we disable all application actions
+(C<I<AppName>::Action::*>) on LetMe URLs. To disable this behavior,
+pass the argument C<DisableActions: 0> to the plugin in your
+C<config.yml>. It's probably a better idea, however, to only enable
+specific actions in your own dispatcher, e.g.:
+
+    after plugin 'Jifty::Plugin::LetMe' =>
+    before qr'^/let' => run {
+        my $let_me = get 'let_me';
+        Jifty->api->allow('ConfirmEmail') if $let_me->path eq 'confirm';
+    };
+
+=cut
+
+our $DISABLE_ACTIONS = 1;
+
+sub init {
+    my $self = shift;
+    my %args = (DisableActions => 1,
+                @_);
+    $DISABLE_ACTIONS = $args{DisableActions};
+}
+
+1;

Added: jifty/trunk/plugins/LetMe/lib/Jifty/Plugin/LetMe/Dispatcher.pm
==============================================================================
--- (empty file)
+++ jifty/trunk/plugins/LetMe/lib/Jifty/Plugin/LetMe/Dispatcher.pm	Sat Jul  1 16:13:15 2006
@@ -0,0 +1,30 @@
+use strict;
+use warnings;
+
+package Jifty::Plugin::LetMe::Dispatcher;
+use Jifty::Dispatcher -base;
+
+my $base_path = Jifty::LetMe->base_path;
+my $letme_path = qr/^\Q$base_path\E/;
+
+before qr{$letme_path(.*)$} => run {
+    my $app = Jifty->config->framework('ApplicationClass');
+    Jifty->api->deny(qr/^\Q$app\E::Action/) if $Jifty::Plugin::LetMe::DISABLE_ACTIONS;
+
+    my $let_me = Jifty::LetMe->new();
+    $let_me->from_token($1);
+    redirect '/error/let_me/invalid_token' unless $let_me->validate;
+
+    Jifty->web->temporary_current_user($let_me->validated_current_user);
+
+    my %args = %{$let_me->args};
+    set $_ => $args{$_} for keys %args;
+    set let_me => $let_me;
+};
+
+on $letme_path => run {
+    my $let_me = get 'let_me';
+    show '/let/' . $let_me->path;
+};
+
+1;


More information about the Jifty-commit mailing list