[Jifty-commit] r1465 - in jifty/branches/plugin_rewrite: .
doc/talks inc/Module inc/Module/Install lib lib/Jifty
lib/Jifty/Action lib/Jifty/Mason lib/Jifty/Model
lib/Jifty/Plugin lib/Jifty/Test/WWW lib/Jifty/Web
lib/Jifty/Web/Form plugins/EditInPlace
plugins/EditInPlace/lib/Jifty/Plugin
plugins/EditInPlace/lib/Jifty/Plugin/EditInPlace
plugins/EditInPlace/lib/Jifty/Plugin/EditInPlace/Action
plugins/EditInPlace/share/web/templates/__jifty plugins/LetMe
plugins/LetMe/doc plugins/LetMe/lib plugins/LetMe/lib/Jifty
plugins/LetMe/lib/Jifty/Plugin plugins/LetMe/lib/Jifty/Plugin/LetMe
plugins/LetMe/lib/Jifty/Plugin/LetMe/Action
plugins/LetMe/lib/Jifty/Plugin/LetMe/Model
plugins/LetMe/share plugins/LetMe/share/po
plugins/LetMe/share/web plugins/LetMe/share/web/static
plugins/LetMe/share/web/templates plugins/LetMe/t
plugins/Nothing plugins/Nothing/doc plugins/Nothing/lib
plugins/Nothing/lib/Jifty plugins/Nothing/lib/Jifty/Plugin
plugins/Nothing/lib/Jifty/Plugin/Nothing
plugins/Nothing/lib/Jifty/Plugin/Nothing/Action
plugins/Nothing/lib/Jifty/Plugin/Nothing/Model
plugins/Nothing/share plugins/Nothing/share/po
plugins/Nothing/share/web plugins/Nothing/share/web/static
plugins/Nothing/share/web/templates share/web/static/css
share/web/static/css/yui/calendar share/web/static/images/css
share/web/static/images/silk share/web/static/js
share/web/templates/__jifty t t/Continuations/lib/Continuations
t/Continuations/share/web/templates t/Continuations/t
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Mon Jul 3 20:58:05 EDT 2006
Author: jpeacock
Date: Mon Jul 3 20:57:21 2006
New Revision: 1465
Added:
jifty/branches/plugin_rewrite/lib/Jifty/Manual/Cookbook.pod
jifty/branches/plugin_rewrite/lib/Jifty/Model/SessionCollection.pm
jifty/branches/plugin_rewrite/plugins/EditInPlace/share/web/templates/__jifty/create_file_inline
jifty/branches/plugin_rewrite/plugins/EditInPlace/share/web/templates/__jifty/edit_file_inline
jifty/branches/plugin_rewrite/plugins/LetMe/
jifty/branches/plugin_rewrite/plugins/LetMe/Makefile.PL
jifty/branches/plugin_rewrite/plugins/LetMe/doc/
jifty/branches/plugin_rewrite/plugins/LetMe/lib/
jifty/branches/plugin_rewrite/plugins/LetMe/lib/Jifty/
jifty/branches/plugin_rewrite/plugins/LetMe/lib/Jifty/Plugin/
jifty/branches/plugin_rewrite/plugins/LetMe/lib/Jifty/Plugin/LetMe/
jifty/branches/plugin_rewrite/plugins/LetMe/lib/Jifty/Plugin/LetMe.pm
jifty/branches/plugin_rewrite/plugins/LetMe/lib/Jifty/Plugin/LetMe/Action/
jifty/branches/plugin_rewrite/plugins/LetMe/lib/Jifty/Plugin/LetMe/Dispatcher.pm
jifty/branches/plugin_rewrite/plugins/LetMe/lib/Jifty/Plugin/LetMe/Model/
jifty/branches/plugin_rewrite/plugins/LetMe/share/
jifty/branches/plugin_rewrite/plugins/LetMe/share/po/
jifty/branches/plugin_rewrite/plugins/LetMe/share/web/
jifty/branches/plugin_rewrite/plugins/LetMe/share/web/static/
jifty/branches/plugin_rewrite/plugins/LetMe/share/web/templates/
jifty/branches/plugin_rewrite/plugins/LetMe/t/
jifty/branches/plugin_rewrite/plugins/Nothing/
jifty/branches/plugin_rewrite/plugins/Nothing/Makefile.PL
jifty/branches/plugin_rewrite/plugins/Nothing/doc/
jifty/branches/plugin_rewrite/plugins/Nothing/lib/
jifty/branches/plugin_rewrite/plugins/Nothing/lib/Jifty/
jifty/branches/plugin_rewrite/plugins/Nothing/lib/Jifty/Plugin/
jifty/branches/plugin_rewrite/plugins/Nothing/lib/Jifty/Plugin/Nothing/
jifty/branches/plugin_rewrite/plugins/Nothing/lib/Jifty/Plugin/Nothing.pm
jifty/branches/plugin_rewrite/plugins/Nothing/lib/Jifty/Plugin/Nothing/Action/
jifty/branches/plugin_rewrite/plugins/Nothing/lib/Jifty/Plugin/Nothing/Dispatcher.pm
jifty/branches/plugin_rewrite/plugins/Nothing/lib/Jifty/Plugin/Nothing/Model/
jifty/branches/plugin_rewrite/plugins/Nothing/share/
jifty/branches/plugin_rewrite/plugins/Nothing/share/po/
jifty/branches/plugin_rewrite/plugins/Nothing/share/web/
jifty/branches/plugin_rewrite/plugins/Nothing/share/web/static/
jifty/branches/plugin_rewrite/plugins/Nothing/share/web/templates/
jifty/branches/plugin_rewrite/share/web/static/css/notices.css
jifty/branches/plugin_rewrite/share/web/static/images/css/fieldbg-autocomplete.gif (contents, props changed)
jifty/branches/plugin_rewrite/share/web/static/images/silk/pencil.png (contents, props changed)
jifty/branches/plugin_rewrite/share/web/static/images/silk/pencil_add.png (contents, props changed)
jifty/branches/plugin_rewrite/share/web/static/js/jifty_smoothscroll.js
Removed:
jifty/branches/plugin_rewrite/lib/Jifty/Plugin/
Modified:
jifty/branches/plugin_rewrite/ (props changed)
jifty/branches/plugin_rewrite/META.yml
jifty/branches/plugin_rewrite/Makefile.PL
jifty/branches/plugin_rewrite/doc/talks/yapc.na.2006.xul
jifty/branches/plugin_rewrite/inc/Module/AutoInstall.pm
jifty/branches/plugin_rewrite/inc/Module/Install.pm
jifty/branches/plugin_rewrite/inc/Module/Install/AutoInstall.pm
jifty/branches/plugin_rewrite/inc/Module/Install/Base.pm
jifty/branches/plugin_rewrite/inc/Module/Install/Can.pm
jifty/branches/plugin_rewrite/inc/Module/Install/Fetch.pm
jifty/branches/plugin_rewrite/inc/Module/Install/Include.pm
jifty/branches/plugin_rewrite/inc/Module/Install/Makefile.pm
jifty/branches/plugin_rewrite/inc/Module/Install/Metadata.pm
jifty/branches/plugin_rewrite/inc/Module/Install/Scripts.pm
jifty/branches/plugin_rewrite/inc/Module/Install/Share.pm
jifty/branches/plugin_rewrite/inc/Module/Install/Win32.pm
jifty/branches/plugin_rewrite/inc/Module/Install/WriteAll.pm
jifty/branches/plugin_rewrite/lib/Jifty.pm
jifty/branches/plugin_rewrite/lib/Jifty/Action.pm
jifty/branches/plugin_rewrite/lib/Jifty/Action/Record.pm
jifty/branches/plugin_rewrite/lib/Jifty/ClassLoader.pm
jifty/branches/plugin_rewrite/lib/Jifty/Continuation.pm
jifty/branches/plugin_rewrite/lib/Jifty/Everything.pm
jifty/branches/plugin_rewrite/lib/Jifty/Handler.pm
jifty/branches/plugin_rewrite/lib/Jifty/LetMe.pm
jifty/branches/plugin_rewrite/lib/Jifty/Manual/Actions.pod
jifty/branches/plugin_rewrite/lib/Jifty/Manual/Glossary.pod
jifty/branches/plugin_rewrite/lib/Jifty/Mason/Halo.pm
jifty/branches/plugin_rewrite/lib/Jifty/Notification.pm
jifty/branches/plugin_rewrite/lib/Jifty/Plugin.pm
jifty/branches/plugin_rewrite/lib/Jifty/Request.pm
jifty/branches/plugin_rewrite/lib/Jifty/Test.pm
jifty/branches/plugin_rewrite/lib/Jifty/Test/WWW/Mechanize.pm
jifty/branches/plugin_rewrite/lib/Jifty/Util.pm
jifty/branches/plugin_rewrite/lib/Jifty/Web.pm
jifty/branches/plugin_rewrite/lib/Jifty/Web/Form/Clickable.pm
jifty/branches/plugin_rewrite/lib/Jifty/Web/Form/Field.pm
jifty/branches/plugin_rewrite/lib/Jifty/Web/PageRegion.pm
jifty/branches/plugin_rewrite/lib/Jifty/Web/Session.pm
jifty/branches/plugin_rewrite/plugins/EditInPlace/META.yml
jifty/branches/plugin_rewrite/plugins/EditInPlace/lib/Jifty/Plugin/EditInPlace.pm
jifty/branches/plugin_rewrite/plugins/EditInPlace/lib/Jifty/Plugin/EditInPlace/Action/FileEditor.pm
jifty/branches/plugin_rewrite/plugins/EditInPlace/lib/Jifty/Plugin/EditInPlace/Dispatcher.pm
jifty/branches/plugin_rewrite/share/web/static/css/forms.css
jifty/branches/plugin_rewrite/share/web/static/css/halos.css
jifty/branches/plugin_rewrite/share/web/static/css/keybindings.css
jifty/branches/plugin_rewrite/share/web/static/css/main.css
jifty/branches/plugin_rewrite/share/web/static/css/yui/calendar/calendar.css
jifty/branches/plugin_rewrite/share/web/static/js/context_menu.js
jifty/branches/plugin_rewrite/share/web/static/js/jifty.js
jifty/branches/plugin_rewrite/share/web/static/js/jifty_utils.js
jifty/branches/plugin_rewrite/share/web/static/js/key_bindings.js
jifty/branches/plugin_rewrite/share/web/templates/__jifty/halo
jifty/branches/plugin_rewrite/t/03-form-protocol.t
jifty/branches/plugin_rewrite/t/Continuations/lib/Continuations/Dispatcher.pm
jifty/branches/plugin_rewrite/t/Continuations/share/web/templates/index.html
jifty/branches/plugin_rewrite/t/Continuations/t/04-before-blocks.t
Log:
smerge from Jifty trunk
Modified: jifty/branches/plugin_rewrite/META.yml
==============================================================================
--- jifty/branches/plugin_rewrite/META.yml (original)
+++ jifty/branches/plugin_rewrite/META.yml Mon Jul 3 20:57:21 2006
@@ -1,7 +1,7 @@
build_requires:
ExtUtils::MakeMaker: 6.11
distribution_type: module
-generated_by: Module::Install version 0.620
+generated_by: Module::Install version 0.630
license: Perl
name: Jifty
no_index:
@@ -18,6 +18,7 @@
Cache::Cache: 0
Calendar::Simple: 0
Class::Accessor: 0
+ Class::Accessor::Named: 0
Class::Container: 0
Class::Data::Inheritable: 0
Compress::Zlib: 0
Modified: jifty/branches/plugin_rewrite/Makefile.PL
==============================================================================
--- jifty/branches/plugin_rewrite/Makefile.PL (original)
+++ jifty/branches/plugin_rewrite/Makefile.PL Mon Jul 3 20:57:21 2006
@@ -29,7 +29,7 @@
requires('HTML::Mason::Plugin');
requires('HTTP::Cookies');
requires('HTTP::Date');
-requires('HTTP::Server::Simple' => '0.10'); # HTTP::Server::Simple::CGI
+requires('HTTP::Server::Simple' => '0.20'); # HTTP::Server::Simple::CGI
requires('HTTP::Server::Simple::Recorder');
requires('Hash::Merge');
requires('Hook::LexWrap');
Modified: jifty/branches/plugin_rewrite/doc/talks/yapc.na.2006.xul
==============================================================================
Binary files. No diff available.
Modified: jifty/branches/plugin_rewrite/inc/Module/AutoInstall.pm
==============================================================================
--- jifty/branches/plugin_rewrite/inc/Module/AutoInstall.pm (original)
+++ jifty/branches/plugin_rewrite/inc/Module/AutoInstall.pm Mon Jul 3 20:57:21 2006
@@ -639,7 +639,9 @@
# check for version numbers that are not in decimal format
if ( ref($cur) or ref($min) or $cur =~ /v|\..*\./ or $min =~ /v|\..*\./ ) {
- if ( $version::VERSION or defined( _load('version') ) ) {
+ if ( ( $version::VERSION or defined( _load('version') )) and
+ version->can('new')
+ ) {
# use version.pm if it is installed.
return (
@@ -750,4 +752,4 @@
__END__
-#line 988
+#line 990
Modified: jifty/branches/plugin_rewrite/inc/Module/Install.pm
==============================================================================
--- jifty/branches/plugin_rewrite/inc/Module/Install.pm (original)
+++ jifty/branches/plugin_rewrite/inc/Module/Install.pm Mon Jul 3 20:57:21 2006
@@ -28,7 +28,7 @@
# This is not enforced yet, but will be some time in the next few
# releases once we can make sure it won't clash with custom
# Module::Install extensions.
- $VERSION = '0.62';
+ $VERSION = '0.63';
}
# Whether or not inc::Module::Install is actually loaded, the
@@ -51,6 +51,22 @@
END_DIE
}
+# If the script that is loading Module::Install is from the future,
+# then make will detect this and cause it to re-run over and over
+# again. This is bad. Rather than taking action to touch it (which
+# is unreliable on some platforms and requires write permissions)
+# for now we should catch this and refuse to run.
+if ( -f $0 and (stat($0))[9] > time ) {
+ die << "END_DIE";
+Your installer $0 has a modification time in the future.
+
+This is known to create infinite loops in make.
+
+Please correct this, then run $0 again.
+
+END_DIE
+}
+
use Cwd ();
use File::Find ();
use File::Path ();
Modified: jifty/branches/plugin_rewrite/inc/Module/Install/AutoInstall.pm
==============================================================================
--- jifty/branches/plugin_rewrite/inc/Module/Install/AutoInstall.pm (original)
+++ jifty/branches/plugin_rewrite/inc/Module/Install/AutoInstall.pm Mon Jul 3 20:57:21 2006
@@ -6,7 +6,7 @@
use vars qw{$VERSION $ISCORE @ISA};
BEGIN {
- $VERSION = '0.62';
+ $VERSION = '0.63';
$ISCORE = 1;
@ISA = qw{Module::Install::Base};
}
Modified: jifty/branches/plugin_rewrite/inc/Module/Install/Base.pm
==============================================================================
--- jifty/branches/plugin_rewrite/inc/Module/Install/Base.pm (original)
+++ jifty/branches/plugin_rewrite/inc/Module/Install/Base.pm Mon Jul 3 20:57:21 2006
@@ -1,7 +1,7 @@
#line 1
package Module::Install::Base;
-$VERSION = '0.62';
+$VERSION = '0.63';
# Suspend handler for "redefined" warnings
BEGIN {
Modified: jifty/branches/plugin_rewrite/inc/Module/Install/Can.pm
==============================================================================
--- jifty/branches/plugin_rewrite/inc/Module/Install/Can.pm (original)
+++ jifty/branches/plugin_rewrite/inc/Module/Install/Can.pm Mon Jul 3 20:57:21 2006
@@ -11,7 +11,7 @@
use vars qw{$VERSION $ISCORE @ISA};
BEGIN {
- $VERSION = '0.62';
+ $VERSION = '0.63';
$ISCORE = 1;
@ISA = qw{Module::Install::Base};
}
Modified: jifty/branches/plugin_rewrite/inc/Module/Install/Fetch.pm
==============================================================================
--- jifty/branches/plugin_rewrite/inc/Module/Install/Fetch.pm (original)
+++ jifty/branches/plugin_rewrite/inc/Module/Install/Fetch.pm Mon Jul 3 20:57:21 2006
@@ -6,7 +6,7 @@
use vars qw{$VERSION $ISCORE @ISA};
BEGIN {
- $VERSION = '0.62';
+ $VERSION = '0.63';
$ISCORE = 1;
@ISA = qw{Module::Install::Base};
}
Modified: jifty/branches/plugin_rewrite/inc/Module/Install/Include.pm
==============================================================================
--- jifty/branches/plugin_rewrite/inc/Module/Install/Include.pm (original)
+++ jifty/branches/plugin_rewrite/inc/Module/Install/Include.pm Mon Jul 3 20:57:21 2006
@@ -6,7 +6,7 @@
use vars qw{$VERSION $ISCORE @ISA};
BEGIN {
- $VERSION = '0.62';
+ $VERSION = '0.63';
$ISCORE = 1;
@ISA = qw{Module::Install::Base};
}
Modified: jifty/branches/plugin_rewrite/inc/Module/Install/Makefile.pm
==============================================================================
--- jifty/branches/plugin_rewrite/inc/Module/Install/Makefile.pm (original)
+++ jifty/branches/plugin_rewrite/inc/Module/Install/Makefile.pm Mon Jul 3 20:57:21 2006
@@ -7,7 +7,7 @@
use vars qw{$VERSION $ISCORE @ISA};
BEGIN {
- $VERSION = '0.62';
+ $VERSION = '0.63';
$ISCORE = 1;
@ISA = qw{Module::Install::Base};
}
Modified: jifty/branches/plugin_rewrite/inc/Module/Install/Metadata.pm
==============================================================================
--- jifty/branches/plugin_rewrite/inc/Module/Install/Metadata.pm (original)
+++ jifty/branches/plugin_rewrite/inc/Module/Install/Metadata.pm Mon Jul 3 20:57:21 2006
@@ -6,7 +6,7 @@
use vars qw{$VERSION $ISCORE @ISA};
BEGIN {
- $VERSION = '0.62';
+ $VERSION = '0.63';
$ISCORE = 1;
@ISA = qw{Module::Install::Base};
}
@@ -123,9 +123,9 @@
require Module::Build;
my $build = Module::Build->new(
- dist_name => $self->{name},
- dist_version => $self->{version},
- license => $self->{license},
+ dist_name => $self->name,
+ dist_version => $self->version,
+ license => $self->license,
);
$self->provides(%{ $build->find_dist_packages || {} });
}
Modified: jifty/branches/plugin_rewrite/inc/Module/Install/Scripts.pm
==============================================================================
--- jifty/branches/plugin_rewrite/inc/Module/Install/Scripts.pm (original)
+++ jifty/branches/plugin_rewrite/inc/Module/Install/Scripts.pm Mon Jul 3 20:57:21 2006
@@ -7,7 +7,7 @@
use vars qw{$VERSION $ISCORE @ISA};
BEGIN {
- $VERSION = '0.62';
+ $VERSION = '0.63';
$ISCORE = 1;
@ISA = qw{Module::Install::Base};
}
Modified: jifty/branches/plugin_rewrite/inc/Module/Install/Share.pm
==============================================================================
--- jifty/branches/plugin_rewrite/inc/Module/Install/Share.pm (original)
+++ jifty/branches/plugin_rewrite/inc/Module/Install/Share.pm Mon Jul 3 20:57:21 2006
@@ -6,7 +6,7 @@
use vars qw{$VERSION $ISCORE @ISA};
BEGIN {
- $VERSION = '0.62';
+ $VERSION = '0.63';
$ISCORE = 1;
@ISA = qw{Module::Install::Base};
}
Modified: jifty/branches/plugin_rewrite/inc/Module/Install/Win32.pm
==============================================================================
--- jifty/branches/plugin_rewrite/inc/Module/Install/Win32.pm (original)
+++ jifty/branches/plugin_rewrite/inc/Module/Install/Win32.pm Mon Jul 3 20:57:21 2006
@@ -6,7 +6,7 @@
use vars qw{$VERSION $ISCORE @ISA};
BEGIN {
- $VERSION = '0.62';
+ $VERSION = '0.63';
$ISCORE = 1;
@ISA = qw{Module::Install::Base};
}
Modified: jifty/branches/plugin_rewrite/inc/Module/Install/WriteAll.pm
==============================================================================
--- jifty/branches/plugin_rewrite/inc/Module/Install/WriteAll.pm (original)
+++ jifty/branches/plugin_rewrite/inc/Module/Install/WriteAll.pm Mon Jul 3 20:57:21 2006
@@ -6,7 +6,7 @@
use vars qw{$VERSION $ISCORE @ISA};
BEGIN {
- $VERSION = '0.62';
+ $VERSION = '0.63';
$ISCORE = 1;
@ISA = qw{Module::Install::Base};
}
Modified: jifty/branches/plugin_rewrite/lib/Jifty.pm
==============================================================================
--- jifty/branches/plugin_rewrite/lib/Jifty.pm (original)
+++ jifty/branches/plugin_rewrite/lib/Jifty.pm Mon Jul 3 20:57:21 2006
@@ -119,8 +119,8 @@
push @Jifty::Record::ISA, Jifty->config->framework('Database')->{'RecordBaseClass'};
__PACKAGE__->logger( Jifty::Logger->new( $args{'logger_component'} ) );
-
- my $base = Jifty->config->framework('ApplicationClass');
+ # Get a classloader set up
+ Jifty::ClassLoader->new(base => Jifty->config->framework('ApplicationClass'))->require;
# Set up plugins
my @plugins;
@@ -128,13 +128,8 @@
my $class = "Jifty::Plugin::".(keys %{$plugin})[0];
my %options = %{ $plugin->{(keys %{$plugin})[0]} };
Jifty::Util->require($class);
- Jifty::ClassLoader->new(base => $class);
- push @plugins, $class->new(base => $base, %options);
+ push @plugins, $class->new(%options);
}
-
- # Get a classloader set up
- Jifty::ClassLoader->new(base => $base)->require;
-
__PACKAGE__->plugins(@plugins);
__PACKAGE__->handler(Jifty::Handler->new());
__PACKAGE__->api(Jifty::API->new());
Modified: jifty/branches/plugin_rewrite/lib/Jifty/Action.pm
==============================================================================
--- jifty/branches/plugin_rewrite/lib/Jifty/Action.pm (original)
+++ jifty/branches/plugin_rewrite/lib/Jifty/Action.pm Mon Jul 3 20:57:21 2006
@@ -433,11 +433,11 @@
sub register {
my $self = shift;
- Jifty->web->out( qq!<div><input type="hidden"! .
+ Jifty->web->out( qq!<input type="hidden"! .
qq! name="@{[$self->register_name]}"! .
qq! id="@{[$self->register_name]}"! .
qq! value="@{[ref($self)]}"! .
- qq! /></div>\n! );
+ qq! />\n! );
@@ -445,7 +445,6 @@
while ( my ( $name, $info ) = each %args ) {
next unless $info->{'constructor'};
- Jifty->web->out( qq!<div>! );
Jifty::Web::Form::Field->new(
%$info,
action => $self,
@@ -454,7 +453,6 @@
default_value => ($self->argument_value($name) || $info->{'default_value'}),
render_as => 'Hidden'
)->render();
- Jifty->web->out( qq!</div>! );
}
return '';
}
@@ -739,7 +737,7 @@
my $val = shift;
return undef unless defined $val and $val =~ /\S/;
return undef unless my $obj = Jifty::DateTime->new_from_string($val);
- return $obj->ymd;
+ return $obj->ymd eq $val ? undef : $obj->ymd;
}
=head2 _validate_arguments
Modified: jifty/branches/plugin_rewrite/lib/Jifty/Action/Record.pm
==============================================================================
--- jifty/branches/plugin_rewrite/lib/Jifty/Action/Record.pm (original)
+++ jifty/branches/plugin_rewrite/lib/Jifty/Action/Record.pm Mon Jul 3 20:57:21 2006
@@ -102,6 +102,18 @@
that are defined "validate" or "autocomplete". These methods can
be overridden in any Action which inherits from this class.
+Additionally, if our model class defines canonicalize_, validate_, or
+autocomplete_ FIELD, generate appropriate an appropriate
+canonicalizer, validator, or autocompleter that will call that method
+with the value to be validated, canonicalized, or autocompleted.
+
+C<validate_FIELD> should return a (success boolean, message) list.
+
+C<autocomplete_FIELD> should return a the same kind of list as
+L<Jifty::Action::_autocomplete_argument/Jifty::Action/_autocomplete_argument>
+
+C<canonicalized_FIELD> should return the canonicalized value.
+
=cut
sub arguments {
Modified: jifty/branches/plugin_rewrite/lib/Jifty/ClassLoader.pm
==============================================================================
--- jifty/branches/plugin_rewrite/lib/Jifty/ClassLoader.pm (original)
+++ jifty/branches/plugin_rewrite/lib/Jifty/ClassLoader.pm Mon Jul 3 20:57:21 2006
@@ -27,113 +27,15 @@
automatically loaded.
=cut
-our @_CLASSES;
-our $_already_pushed;
sub new {
my $class = shift;
my $self = bless {@_}, $class;
- $self->load_defaults() if $self->{base};
-
- # finally, put this object into @INC for later
- unless ( $_already_pushed ) {
- push(@INC, $self);
- $_already_pushed = 1;
- }
+ push @INC, $self;
return $self;
}
-
-sub register ($&) {
- my ($self, $regex, $code) = @_;
- push @_CLASSES, [$regex, $code];
-}
-
-sub preregister ($&) {
- my ($self, $regex, $code) = @_;
- unshift @_CLASSES, [$regex, $code];
-}
-
-sub load_defaults {
- my ($self) = @_;
- my $base = $self->{base};
-
- $self->register(
- qr/^(?:$base)$/,
- sub {
- my ($module) = @_;
- return $self->return_class(
- "use warnings; use strict;\n"
- . " package " . $self->{base} . ";\n"
- . "sub _autogenerated { 1 };\n"
- . " 1;"
- );
- }
- );
-
- $self->register(
- qr/^(?:$base)::(Record|Collection|Notification|Dispatcher|Bootstrap|Upgrade)$/,
- sub {
- my ($module) = @_;
- return $self->return_class(
- "use warnings; use strict; package $module;\n"
- . "use base qw/Jifty::$1/;\n"
- . "sub _autogenerated { 1 };\n"
- . "1;"
- );
- }
- );
-
- $self->register(
- qr/^(?:$base)::CurrentUser$/,
- sub {
- my ($module) = @_;
- return $self->return_class(
- "use warnings; use strict; package $module;\n"
- . "use base qw/Jifty::CurrentUser/;\n"
- . "sub _autogenerated { 1 };\n"
- . "1;"
- );
- }
- );
-
- $self->register(
- qr/^(?:$base)::Model::(\w+)Collection$/,
- sub {
- my ($module) = @_;
- my $base = $self->{base}; # for clarity purposes
- return $self->return_class(
- "use warnings; use strict; package $module;\n"
- . "use base qw/${base}::Collection/;\n"
- . "sub record_class { '${base}::Model::$1' }\n"
- . "sub _autogenerated { 1 };\n"
- . "1;"
- );
- }
- );
-
- $self->register(
- qr/^(?:$base)::Action::(Create|Update|Delete)([^\.]+)$/,
- sub {
- my ($module) = @_;
- my $modelclass = $self->{base} . "::Model::" . $2;
- Jifty::Util->require($modelclass);
-
- return undef unless eval { $modelclass->table };
-
- return $self->return_class(
- "use warnings; use strict; package $module;\n"
- . "use base qw/Jifty::Action::Record::$1/;\n"
- . "sub record_class { '$modelclass' };\n"
- . "sub autogenerated { 1 };\n"
- . "1;"
- );
- }
- );
-
-}
-
=head2 INC
The hook that is called when a module has been C<require>'d that
@@ -203,12 +105,47 @@
$module =~ s/.pm$//;
$module =~ s{/}{::}g;
- foreach my $class ( @_CLASSES ) {
- my ($regex, $code) = @{$class};
- if ( $module =~ /$regex/ ) {
- my $return = &$code($module);
- return $return if defined $return;
- }
+ # The quick check
+ return undef unless $module =~ m!^$base!;
+
+ if ( $module =~ m!^(?:$base)$! ) {
+ return $self->return_class(
+ "use warnings; use strict; package " . $base . ";\n" . " 1;" );
+ }
+# elsif ( $module =~ m!^(?:$base)::Action$! ) {
+# return $self->return_class(
+# "use warnings; use strict; package $module;\n"
+# . "use base qw/Jifty::Action/; sub _autogenerated { 1 };\n"
+# . "1;" );
+# }
+ elsif ( $module =~ m!^(?:$base)::(Record|Collection|Notification|Dispatcher|Bootstrap|Upgrade)$! ) {
+ return $self->return_class(
+ "use warnings; use strict; package $module;\n"
+ . "use base qw/Jifty::$1/; sub _autogenerated { 1 };\n"
+ . "1;" );
+ } elsif ( $module =~ m!^(?:$base)::CurrentUser$! ) {
+ return $self->return_class(
+ "use warnings; use strict; package $module;\n"
+ . "use base qw/Jifty::CurrentUser/; sub _autogenerated { 1 };\n"
+ . "1;" );
+ } elsif ( $module =~ m!^(?:$base)::Model::(\w+)Collection$! ) {
+ return $self->return_class(
+ "use warnings; use strict; package $module;\n"
+ . "use base qw/@{[$base]}::Collection/;\n"
+ . "sub record_class { '@{[$base]}::Model::$1' }\n"
+ . "1;" );
+ } elsif ( $module =~ m!^(?:$base)::Action::(Create|Update|Delete)([^\.]+)$! ) {
+ my $modelclass = $base . "::Model::" . $2;
+ Jifty::Util->require($modelclass);
+
+ return undef unless eval { $modelclass->table };
+
+ return $self->return_class(
+ "use warnings; use strict; package $module;\n"
+ . "use base qw/Jifty::Action::Record::$1/;\n"
+ . "sub record_class { '$modelclass' };\n"
+ . "sub autogenerated { 1 };\n"
+ . "1;" );
}
return undef;
}
@@ -239,8 +176,8 @@
sub require {
my $self = shift;
+
my $base = $self->{base};
-
# if we don't even have an application class, this trick will not work
return unless ($base);
Jifty::Util->require($base);
Modified: jifty/branches/plugin_rewrite/lib/Jifty/Continuation.pm
==============================================================================
--- jifty/branches/plugin_rewrite/lib/Jifty/Continuation.pm (original)
+++ jifty/branches/plugin_rewrite/lib/Jifty/Continuation.pm Mon Jul 3 20:57:21 2006
@@ -79,13 +79,6 @@
An optional subroutine reference to evaluate when the continuation is
called.
-=item clone
-
-There is a interface to support continuation "cloning," a process
-which is useful to creating multi-page wizards and the like. However,
-this feature is still very much in flux; the documentation is waiting
-for the interface to settle down a bit before being written.
-
=back
=cut
@@ -99,7 +92,6 @@
request => Jifty::Request->new(),
response => Jifty::Response->new(),
code => undef,
- clone => undef,
@_
);
@@ -107,19 +99,9 @@
$args{parent} = $args{parent}->id
if $args{parent} and ref $args{parent};
- # We're cloning most of our attributes from a previous continuation
- if ($args{clone} and Jifty->web->session->get_continuation($args{clone})) {
- $self = dclone(Jifty->web->session->get_continuation($args{clone}));
- for (grep {/^J:A/} keys %{$args{request}->arguments}) {
- $self->request->argument($_ => $args{request}->arguments->{$_});
- }
- $self->response($args{response});
- } else {
- delete $args{clone};
- # We're getting most of our properties from the arguments
- for (keys %args) {
- $self->$_($args{$_}) if $self->can($_);
- }
+ # We're getting most of our properties from the arguments
+ for (keys %args) {
+ $self->$_($args{$_}) if $self->can($_);
}
# Generate a hopefully unique ID
@@ -133,21 +115,15 @@
return $self;
}
-=head2 call
+=head2 return_path_matches
-Call the continuation; this is generally done during request
-processing, after an actions have been run.
-L<Jifty::Request::Mapper>-controlled values are filled into the stored
-request based on the current request and response. If an values
-needed to be filled in, then *another* continuation is created, with
-the filled-in values included, and the browser is redirected there.
-This is to ensure that we end up at the correct request path, while
-keeping continuations immutable and maintaining all of the request
-state that we need.
+Returns true if the continuation matches the current request's path,
+and it would return to its caller in this context. This can be used
+to ask "are we about to call a continuation?"
=cut
-sub call {
+sub return_path_matches {
my $self = shift;
my $called_uri = $ENV{'REQUEST_URI'};
my $request_path = $self->request->path;
@@ -159,65 +135,89 @@
$request_path =~ s{/+}{/}g;
$request_path = $escape while $request_path ne ($escape = URI::Escape::uri_unescape($request_path));
- if (defined $request_path and
- ($called_uri !~ /^\Q$request_path\E[?&;]J:CALL=@{[$self->id]}/)) {
- # If we needed to fix up the path (it contains invalid
- # characters) then warn, because this may cause infinite
- # redirects
- Jifty->log->warn("Redirect to '@{[$self->request->path]}' contains unsafe characters")
- if $self->request->path =~ m{[^A-Za-z0-9\-_.!~*'()/?&;+]};
-
- # Clone our request
- my $request = dclone($self->request);
-
- # Fill in return value(s) into correct part of $request
- $request->do_mapping;
-
- my $response = $self->response;
- # If the current response has results, we need to pull them
- # in. For safety, monikers from the saved continuation
- # override those from the request prior to the call
- if (Jifty->web->response->results) {
- $response = dclone(Jifty->web->response);
- my %results = $self->response->results;
- $response->result($_ => $results{$_}) for keys %results;
- }
-
- # Make a new continuation with that request
- my $next = Jifty::Continuation->new(parent => $self->parent,
- request => $request,
- response => $response,
- code => $self->code,
- );
- $next->request->continuation(Jifty->web->session->get_continuation($next->parent))
- if defined $next->parent;
-
- # Redirect to right page if we're not there already
- Jifty->web->_redirect($next->request->path . "?J:CALL=" . $next->id);
- } else {
- # Pull state information out of the continuation and set it
- # up; we use clone so that the continuation itself is
- # immutable. It is vaguely possible that there are results in
- # the response already (set up by the dispatcher) so we place
- # results from the continuation's response into the existing
- # response only if it wouldn't clobber something.
+ return $called_uri =~ /^\Q$request_path\E[?&;]J:RETURN=@{[$self->id]}$/;
+}
+
+=head2 call
+
+Call the continuation; this is generally done during request
+processing, after an actions have been run.
+L<Jifty::Request::Mapper>-controlled values are filled into the stored
+request based on the current request and response. During the
+process, another continuation is created, with the filled-in results
+of the current actions included, and the browser is redirected to the
+proper path, with that continuation.
+
+=cut
+
+sub call {
+ my $self = shift;
+
+ # If we needed to fix up the path (it contains invalid
+ # characters) then warn, because this may cause infinite
+ # redirects
+ Jifty->log->warn("Redirect to '@{[$self->request->path]}' contains unsafe characters")
+ if $self->request->path =~ m{[^A-Za-z0-9\-_.!~*'()/?&;+]};
+
+ # Clone our request
+ my $request = $self->request->clone;
+
+ # Fill in return value(s) into correct part of $request
+ $request->do_mapping;
+
+ my $response = $self->response;
+ # If the current response has results, we need to pull them
+ # in. For safety, monikers from the saved continuation
+ # override those from the request prior to the call
+ if (Jifty->web->response->results) {
+ $response = dclone(Jifty->web->response);
my %results = $self->response->results;
- for (keys %results) {
- next if Jifty->web->response->result($_);
- Jifty->web->response->result($_,dclone($results{$_}));
- }
-
- # Run any code in the continuation
- $self->code->(Jifty->web->request)
- if $self->code;
-
- # Enter the request in the continuation, and handle it. This
- # will possibly cause 'before' blocks to run more than once,
- # but is slightly preferrable to them never running.
- Jifty->web->request(dclone($self->request));
- Jifty->handler->dispatcher->handle_request;
- Jifty::Dispatcher::_abort;
+ $response->result($_ => $results{$_}) for keys %results;
+ }
+
+ # Make a new continuation with that request
+ my $next = Jifty::Continuation->new(parent => $self->parent,
+ request => $request,
+ response => $response,
+ code => $self->code,
+ );
+ $next->request->continuation(Jifty->web->session->get_continuation($next->parent))
+ if defined $next->parent;
+
+ # Redirect to right page if we're not there already
+ Jifty->web->_redirect($next->request->path . "?J:RETURN=" . $next->id);
+}
+
+=head2 return
+
+Returns from the continuation by pulling out the stored request, and
+setting that to be the active request. This shouldn't need to be
+called by hand -- use L<Jifty::Request/return_from_continuation>,
+which ensures that all requirements are ment before it calls this.
+
+=cut
+
+sub return {
+ my $self = shift;
+
+ # Pull state information out of the continuation and set it
+ # up; we use clone so that the continuation itself is
+ # immutable. It is vaguely possible that there are results in
+ # the response already (set up by the dispatcher) so we place
+ # results from the continuation's response into the existing
+ # response only if it wouldn't clobber something.
+ my %results = $self->response->results;
+ for (keys %results) {
+ next if Jifty->web->response->result($_);
+ Jifty->web->response->result($_,dclone($results{$_}));
}
+
+ # Run any code in the continuation
+ $self->code->(Jifty->web->request)
+ if $self->code;
+
+ # Set the current request to the one in the continuation
+ return Jifty->web->request($self->request->clone);
}
=head2 delete
Modified: jifty/branches/plugin_rewrite/lib/Jifty/Everything.pm
==============================================================================
--- jifty/branches/plugin_rewrite/lib/Jifty/Everything.pm (original)
+++ jifty/branches/plugin_rewrite/lib/Jifty/Everything.pm Mon Jul 3 20:57:21 2006
@@ -49,6 +49,7 @@
use Jifty::Model::Metadata ();
use Jifty::Model::Session ();
+use Jifty::Model::SessionCollection ();
use Jifty::Request ();
Modified: jifty/branches/plugin_rewrite/lib/Jifty/Handler.pm
==============================================================================
--- jifty/branches/plugin_rewrite/lib/Jifty/Handler.pm (original)
+++ jifty/branches/plugin_rewrite/lib/Jifty/Handler.pm Mon Jul 3 20:57:21 2006
@@ -31,12 +31,17 @@
# Creating a new CGI object breaks FastCGI in all sorts of painful
# ways. So wrap the call and preempt it if we already have one
use CGI ();
- *CGI::__jifty_real_new = \&CGI::new;
-
- no warnings qw(redefine);
- *CGI::new = sub {
- return Jifty->handler->cgi if Jifty->handler->cgi;
- CGI::__jifty_real_new(@_);
+
+ # If this file gets reloaded using Module::Refresh, don't do this
+ # magic again, or we'll get infinite recursion
+ unless (CGI->can('__jifty_real_new')) {
+ *CGI::__jifty_real_new = \&CGI::new;
+
+ no warnings qw(redefine);
+ *CGI::new = sub {
+ return Jifty->handler->cgi if Jifty->handler->cgi;
+ CGI::__jifty_real_new(@_);
+ }
}
};
@@ -180,10 +185,10 @@
# Build a new stash for the life of this request
$self->stash({});
local $HTML::Mason::Commands::JiftyWeb = Jifty::Web->new();
- Jifty->web->request( Jifty::Request->new()->fill( $self->cgi ) );
- Jifty->web->response( Jifty::Response->new );
Jifty->web->setup_session;
+ Jifty->web->request( Jifty::Request->new()->fill( $self->cgi ) );
+ Jifty->web->response( Jifty::Response->new );
Jifty->web->session->set_cookie;
Jifty->api->reset;
$_->new_request for Jifty->plugins;
@@ -195,6 +200,9 @@
= $self->static_handler->handle_request( Jifty->web->request->path )
if ( Jifty->config->framework('Web')->{'ServeStaticFiles'} );
+ # Return from the continuation if need be
+ Jifty->web->request->return_from_continuation;
+
$self->dispatcher->handle_request() unless ($sent_response);
$self->cleanup_request();
Modified: jifty/branches/plugin_rewrite/lib/Jifty/LetMe.pm
==============================================================================
--- jifty/branches/plugin_rewrite/lib/Jifty/LetMe.pm (original)
+++ jifty/branches/plugin_rewrite/lib/Jifty/LetMe.pm Mon Jul 3 20:57:21 2006
@@ -19,8 +19,11 @@
Create a new "LetMe" authentication object; it takes no parameters.
It calls L</_init> to do any initialization.
-A LetMe is a way to provide a one-time-use URL to confirm someone's
-identity. For example, you can put a LetMe URL in an email to a new user,
+A LetMe is a way to provide a one-time-use URL for a particular purpose.
+All LetMe objects give you a way to validate someone's identity and to
+allow them a very small set of possible actions or page-access permissions.
+
+For example, you can put a LetMe URL in an email to a new user,
so that when they click on the URL you know that their email address
is valid.
@@ -213,7 +216,7 @@
By default, all "LetMe" actions live at URLs under '/let' inside your
application. Override this subroutine to change that.
-By default, it returns '/let'
+By default, it returns '/let/'
=cut
Modified: jifty/branches/plugin_rewrite/lib/Jifty/Manual/Actions.pod
==============================================================================
--- jifty/branches/plugin_rewrite/lib/Jifty/Manual/Actions.pod (original)
+++ jifty/branches/plugin_rewrite/lib/Jifty/Manual/Actions.pod Mon Jul 3 20:57:21 2006
@@ -268,7 +268,7 @@
=head3 monikers
-You probably noticed the C<<moniker => 'post_blog'>>. Every action you
+You probably noticed the C<< moniker => 'post_blog' >>. Every action you
create in Jifty has an associated
L<moniker|Jifty::Manual::Glossary>. A C<moniker> is simply a unique
identifier for the action (unique per request, which in practice
Added: jifty/branches/plugin_rewrite/lib/Jifty/Manual/Cookbook.pod
==============================================================================
--- (empty file)
+++ jifty/branches/plugin_rewrite/lib/Jifty/Manual/Cookbook.pod Mon Jul 3 20:57:21 2006
@@ -0,0 +1,70 @@
+=head1 NAME
+
+Jifty::Manual::Cookbook
+
+=head1 DESCRIPTION
+
+This document aims to provide solutions to common questions of "How do
+I do I<x> with Jifty?" While the solutions here certainly aren't the
+only way to do things, they're generally the solutions the developers
+of Jifty use, and ones that work pretty well.
+
+=head1 HOW DO I ...
+
+=head2 Limit access to pages to logged-in users
+
+The best place to do this is probably in your application's
+L<Dispatcher|Jifty::Dispatcher>. If, for example, you wanted to limit
+access to C</secret> to logged-in users, you could write:
+
+ before qr'^/secret' => run {
+ unless(Jifty->web->current_user->id) {
+ Jifty->web->tangent('/login');
+ }
+ };
+
+Then, in your login form component, you would write something like:
+
+ <% Jifty->web->return(to => '/', submit => $login_action) $>
+
+The combination of the C<tangent> and C<return> will cause the user to
+be returned to wherever they came from. See L<Jifty::Continuation> for
+more information.
+
+If you want model-level access control, Jifty provides a ready-built
+ACL system for its models; See L<Jifty::Manual::AccessControl> for
+details.
+
+Finally, you can also allow or deny specific actions in the
+dispatcher, to limit who is able to perform what actions -- see
+L<Jifty::API>.
+
+=head2 Take actions based on data in URLs
+
+You can add actions to the request based on data in URLs, or anything
+else, using
+L<Jifty::Request::add_action|Jifty::Request/add_action>. For example,
+suppose you wanted to make the path C</logout> log the user out, and
+redirect them to the home page. You could write:
+
+ before '/logout' => {
+ Jifty->web->request->add_action( class => 'Logout' );
+ Jifty->web->request->add_action(class => 'Redirect',
+ arguments => { url => '/' });
+ };
+
+=head2 Pass HTML form input directly to components
+
+Sometimes, you don't want to take an action based on input from HTML
+forms, but just want to change how the page is displayed, or do
+something similarly transient.
+
+C<Jifty::Action> is great, but it doesn't have to be the answer to
+everything. For cases like this, it's fine to use typical HTML C<<
+<input>s >>. Their values will be accessible as request arguments, so
+you can fetch them with C<get> in the dispatcher, and they will be
+passed as arguments to top-level Mason components that list them in
+C<< <%args> >>. And don't worry about namespace conflicts with Jifty's
+auto-generated argument fields -- Jifty prefixes all its C<name>s with
+C<J:> so there won't be a problem.
+
Modified: jifty/branches/plugin_rewrite/lib/Jifty/Manual/Glossary.pod
==============================================================================
--- jifty/branches/plugin_rewrite/lib/Jifty/Manual/Glossary.pod (original)
+++ jifty/branches/plugin_rewrite/lib/Jifty/Manual/Glossary.pod Mon Jul 3 20:57:21 2006
@@ -13,7 +13,7 @@
An B<action> is a specifically designed RPC call that can do something to the
system. An action takes any number of L</argument>s, which it
L</canonicalize>s, L</validate>s, and then uses to do something useful. Each
-action has a L</result>. See L<Jifty::Action>.
+action has a L</result>. See L<Jifty::Action> and L<Jifty::Manual::Actions>.
=item active
@@ -67,10 +67,20 @@
=item fragment
-A section of HTML contained in a L</region>. Fragments are a kind of
-standalone Mason component which the browser can request individually. Because
-of this, they can only take strings and scalars as arguments, not references or
-objects!
+A section of HTML (at present, a Mason component) contained in a L</region>.
+Fragments are a kind of standalone Mason component which the browser can request
+individually. Because of this, they can only take strings and scalars as
+arguments, not references or objects!
+
+=item element
+
+A Mason component used by one or more other pages, which is not a whole page of
+itself. As opposed to L<fragments|/fragment> C<elements> are strictly internal,
+and never visible to the outside world by themselves. Elements typically live
+under a path beginning with or containing '/_elements'. This, and the whole idea
+of an element is strictly convention, but Jifty contains elements for things
+like page headers, menus, and showing keybindings out of the box to make your
+life easier.
=item mandatory
Modified: jifty/branches/plugin_rewrite/lib/Jifty/Mason/Halo.pm
==============================================================================
--- jifty/branches/plugin_rewrite/lib/Jifty/Mason/Halo.pm (original)
+++ jifty/branches/plugin_rewrite/lib/Jifty/Mason/Halo.pm Mon Jul 3 20:57:21 2006
@@ -28,7 +28,7 @@
my $self = shift;
my $context = shift;
- return if $context->comp->path eq "/__jifty/halo";
+ return if ($context->comp->path && $context->comp->path eq "/__jifty/halo");
Jifty->handler->stash->{ '_halo_index_stack' } ||= [];
@@ -49,9 +49,9 @@
id => $halo_base,
args => [map { eval { defined $_ and fileno( $_ ) } ? "*GLOB*" : $_} @{$context->args}],
start_time => Time::HiRes::time(),
- path => $context->comp->path,
+ path => $context->comp->path || '',
subcomponent => ( $context->comp->is_subcomp() ? 1:0),
- name => $context->comp->name,
+ name => $context->comp->name || '(Unamed component)',
proscribed => ($self->_unrendered_component($context) ? 1 :0 ),
depth => $DEPTH
};
@@ -74,7 +74,7 @@
my $self = shift;
my $context = shift;
- return if $context->comp->path =~ "^/__jifty/halo";
+ return if ($context->comp->path && $context->comp->path =~ "^/__jifty/halo");
my $STACK = Jifty->handler->stash->{'_halo_stack'};
my $INDEX_STACK = Jifty->handler->stash->{'_halo_index_stack'};
@@ -96,7 +96,23 @@
# print out the div with our halo magic actions.
# if we didn't render a beginning of the span, don't render an end
- $context->request->out('</div>') unless ($frame->{'proscribed'});
+ unless ( $frame->{'proscribed'} ) {
+ my $comp_name = $frame->{'path'};
+ $context->request->out('</div>');
+ $context->request->out(
+ Jifty->web->link(
+ label => _( 'Edit %1', $comp_name ),
+ class => 'inline_edit',
+ onclick => [
+ { element => "#halo-" . $frame->{id},
+ replace_with =>
+ '/__jifty/edit_inline/mason_component/'.$comp_name
+ }
+ ]
+ )
+ )
+ if 0 and ( $frame->{'path'} and $frame->{'path'} !~ /^\/?__jifty/ );
+ }
}
Added: jifty/branches/plugin_rewrite/lib/Jifty/Model/SessionCollection.pm
==============================================================================
--- (empty file)
+++ jifty/branches/plugin_rewrite/lib/Jifty/Model/SessionCollection.pm Mon Jul 3 20:57:21 2006
@@ -0,0 +1,28 @@
+use warnings;
+use strict;
+
+package Jifty::Model::SessionCollection;
+
+use base qw/Jifty::Collection/;
+
+=head2 record_class
+
+This deals with collections of L<Jifty::Model::Session>s.
+
+=cut
+
+sub record_class { 'Jifty::Model::Session' }
+
+
+=head2 current_user
+
+Everyone is treated as the superuser when dealing with session
+objects. This avoids infinite recursion, as otherwise it would try to
+look up the current user in the session object to find out who we
+are...
+
+=cut
+
+sub current_user { return Jifty::CurrentUser->superuser }
+
+1;
Modified: jifty/branches/plugin_rewrite/lib/Jifty/Notification.pm
==============================================================================
--- jifty/branches/plugin_rewrite/lib/Jifty/Notification.pm (original)
+++ jifty/branches/plugin_rewrite/lib/Jifty/Notification.pm Mon Jul 3 20:57:21 2006
@@ -77,6 +77,9 @@
if mail was actually sent. Note errors are not the only cause of mail
not being sent -- for example, the recipients list could be empty.
+ Be aware that if you haven't set C<recipients>, this will fail silently
+and return without doing anything useful.
+
=cut
sub send_one_message {
Modified: jifty/branches/plugin_rewrite/lib/Jifty/Plugin.pm
==============================================================================
--- jifty/branches/plugin_rewrite/lib/Jifty/Plugin.pm (original)
+++ jifty/branches/plugin_rewrite/lib/Jifty/Plugin.pm Mon Jul 3 20:57:21 2006
@@ -49,17 +49,15 @@
sub new {
my $class = shift;
- push @_, plugin => $class;
- # Need to initialize a dispatcher
+ # Get a classloader set up
+ Jifty::ClassLoader->new(base => $class)->require;
Jifty::Util->require($class->dispatcher);
# XXX TODO: Add .po path
- my $self = bless {@_} => $class;
+ my $self = bless {} => $class;
$self->init(@_);
- $self->plugin_defaults();
-
return $self;
}
@@ -76,46 +74,6 @@
1;
}
-sub plugin_defaults {
- my $self = shift;
- my $base = $self->{base};
- my $plugin = $self->{plugin};
-
- # Create the plugin classloader elements on behalf of the application
- require Jifty::ClassLoader;
- my $classloader = Jifty::ClassLoader->new();
-
- $classloader->preregister(
- qr/^(?:$base)::(Notification|CurrentUser)$/o,
- sub {
- my $module = shift;
- my $plugin = $self->{plugin};
- my $toplevel = "${plugin}::$1";
- return $self->return_class(
- "use warnings; use strict; package $module;\n"
- . "use base qw/$toplevel/;\n"
- . "sub _autogenerated { 1 };\n"
- . "1;"
- );
- },
- );
-
- $classloader->preregister(
- qr/^(?:$base)::Action::([^\.]+)$/o,
- sub {
- my $module = shift;
- my $plugin = $self->{plugin};
- my $action = "${plugin}::Action::$1";
- return $self->return_class(
- "use warnings; use strict; package $module;\n"
- . "use base qw/$action/;\n"
- . "sub autogenerated { 1 };\n"
- . "1;"
- );
- }
- );
-}
-
=head2 new_request
Called right before every request. By default, this adds the plugin's
@@ -175,11 +133,4 @@
return $class."::Dispatcher";
}
-sub return_class {
- my $self = shift;
- my $content = shift;
- open my $fh, '<', \$content;
- return $fh;
-}
-
1;
Modified: jifty/branches/plugin_rewrite/lib/Jifty/Request.pm
==============================================================================
--- jifty/branches/plugin_rewrite/lib/Jifty/Request.pm (original)
+++ jifty/branches/plugin_rewrite/lib/Jifty/Request.pm Mon Jul 3 20:57:21 2006
@@ -4,10 +4,11 @@
package Jifty::Request;
use base qw/Jifty::Object Class::Accessor::Fast/;
-__PACKAGE__->mk_accessors(qw(_top_request arguments just_validating path _continuation));
+__PACKAGE__->mk_accessors(qw(_top_request arguments just_validating path continuation_id continuation_type continuation_path));
use Jifty::JSON;
use Jifty::YAML;
+use Storable 'dclone';
=head1 NAME
@@ -32,11 +33,11 @@
A request may contain one or more actions; these are represented as
L<Jifty::Request::Action> objects. Each action request has a
L<moniker|Jifty::Manual::Glossary/moniker>, a set of submitted
-L<arguments|Jifty::Manual::Glossary/arguments>, and an implementation class.
-By default, all actions that are submitted are run; it is possible to
-only mark a subset of the submitted actions as "active", and only the
-active actions will be run. These will eventually become full-fledge
-L<Jifty::Action> objects.
+L<arguments|Jifty::Manual::Glossary/arguments>, and an implementation
+class. By default, all actions that are submitted are run; it is
+possible to only mark a subset of the submitted actions as "active",
+and only the active actions will be run. These will eventually become
+full-fledge L<Jifty::Action> objects.
=item state variables
@@ -53,11 +54,11 @@
=item (optional) fragments
-L<Fragments|Jifty::Manual::Glossary/fragments> are standalone bits of reusable
-code. They are most commonly used in the context of AJAX, where
-fragments are the building blocks that can be updated independently.
-A request is either for a full page, or for multiple independent
-fragments. See L<Jifty::Web::PageRegion>.
+L<Fragments|Jifty::Manual::Glossary/fragments> are standalone bits of
+reusable code. They are most commonly used in the context of AJAX,
+where fragments are the building blocks that can be updated
+independently. A request is either for a full page, or for multiple
+independent fragments. See L<Jifty::Web::PageRegion>.
=back
@@ -88,6 +89,22 @@
return $self;
}
+=head2 clone
+
+Return a copy of the request.
+
+=cut
+
+sub clone {
+ my $self = shift;
+
+ # "Semi-shallow" clone
+ return bless({map {
+ my $val = $self->{$_};
+ $_ => (ref($val) ? { %$val } : $val);
+ } keys %$self}, ref($self));
+}
+
=head2 fill
Attempt to fill in the request from any number of various methods --
@@ -130,12 +147,18 @@
my $self = shift;
my $data = shift;
- # TODO: continuations
-
$self->path($data->{path});
+ $self->just_validating($data->{validating}) if $data->{validating};
+
+ if (ref $data->{continuation} eq "HASH") {
+ $self->continuation_id($data->{continuation}{id});
+ $self->continuation_type($data->{continuation}{type} || "parent");
+ $self->continuation_path($data->{continuation}{create});
+ }
my %actions = %{$data->{actions} || {}};
for my $a (values %actions) {
+ next unless ref $a eq "HASH";
my %arguments;
for my $arg (keys %{$a->{fields} || {}}) {
if (ref $a->{fields}{$arg}) {
@@ -155,20 +178,21 @@
);
}
- my %variables = %{$data->{variables} || {}};
+ my %variables = ref $data->{variables} eq "HASH" ? %{$data->{variables}} : ();
for my $v (keys %variables) {
$self->add_state_variable(key => $v, value => $variables{$v});
}
- my %fragments = %{$data->{fragments} || {}};
+ my %fragments = ref $data->{fragments} eq "HASH" ? %{$data->{fragments}} : ();
for my $f (values %fragments) {
+ next unless ref $f eq "HASH";
my $current = $self->add_fragment(
name => $f->{name},
path => $f->{path},
arguments => $f->{args},
wrapper => $f->{wrapper} || 0,
);
- while ($f = $f->{parent}) {
+ while (ref $f->{parent} eq "HASH" and $f = $f->{parent}) {
$current = $current->parent(Jifty::Request::Fragment->new({
name => $f->{name},
path => $f->{path},
@@ -230,19 +254,12 @@
my %args = (@_);
- # We pull in the continuations first, because if we have a
- # J:CLONE, we want the cloned values to be fallbacks
- $self->_extract_continuations_from_webform(%args);
-
# Pull in all of the arguments
- # XXX ALEX: I think this breaks J:CLONE
$self->arguments(\%args);
# Extract actions and state variables
$self->from_data_structure($self->webform_to_data_structure(%args));
- $self->just_validating(1) if defined $args{'J:VALIDATE'} and length $args{'J:VALIDATE'};
-
return $self;
}
@@ -261,13 +278,37 @@
my $value = shift;
$self->arguments->{$key} = $value;
- if ($key =~ /^J:A-(?:(\d+)-)?(.+)/s) {
- $self->add_action(moniker => $2, class => $value, order => $1, arguments => {}, active => 1);
- } elsif ($key =~ /^J:A:F-(\w+)-(.+)/s and $self->action($2)) {
- $self->action($2)->argument($1 => $value);
- $self->action($2)->modified(1);
+ # Continuation type is ofetn undef, so give it a sane default
+ # so we can use eq without warnings
+ my $cont_type = $self->continuation_type || "";
+
+ if ($key eq "J:VALIDATE") {
+ $self->{validating} = $value;
+ } elsif ($key eq "J:C" and $cont_type ne "return" and $cont_type ne "call") {
+ # J:C Doesn't take preference over J:CALL or J:RETURN
+ $self->continuation_id($value);
+ $self->continuation_type("parent");
+ } elsif ($key eq "J:CALL" and $cont_type ne "return") {
+ # J:CALL doesn't take preference over J:RETURN
+ $self->continuation_id($value);
+ $self->continuation_type("call");
+ } elsif ($key eq "J:RETURN") {
+ # J:RETURN trumps all
+ $self->continuation_id($value);
+ $self->continuation_type("return");
+ } elsif ($key eq "J:PATH") {
+ $self->continuation_path($value);
} elsif ($key =~ /^J:V-(.*)/s) {
$self->add_state_variable(key => $1, value => $value);
+ } elsif ($key =~ /^J:A-(?:(\d+)-)?(.+)/s) {
+ $self->add_action(moniker => $2, class => $value, order => $1, arguments => {}, active => 1);
+ } else {
+ # It's possibly a form field
+ my ($t, $a, $m) = $self->parse_form_field_name($key);
+ if ($t and $t eq "J:A:F" and $self->action($m)) {
+ $self->action($m)->argument($a => $value);
+ $self->action($m)->modified(1);
+ }
}
}
@@ -366,6 +407,17 @@
# Pass path through
$data->{path} = $self->path;
+ $data->{validating} = $args{'J:VALIDATE'} if defined $args{'J:VALIDATE'} and length $args{'J:VALIDATE'};
+
+ # Continuations
+ if ($args{'J:C'} or $args{'J:CALL'} or $args{'J:RETURN'}) {
+ $data->{continuation}{id} = $args{'J:RETURN'} || $args{'J:CALL'} || $args{'J:C'};
+ $data->{continuation}{type} = "parent" if $args{'J:C'};
+ $data->{continuation}{type} = "call" if $args{'J:CALL'};
+ $data->{continuation}{type} = "return" if $args{'J:RETURN'};
+ }
+ $data->{continuation}{create} = $args{'J:PATH'} if $args{'J:CREATE'};
+
# Are we only setting some actions as active?
my $active_actions;
if (exists $args{'J:ACTIONS'}) {
@@ -380,7 +432,7 @@
# come before action arguments
for my $key (sort keys %args) {
my $value = $args{$key};
- if( $key =~ /^J:V-(.*)$/s ) {
+ if( $key =~ /^J:V-(.*)/s ) {
# It's a variable
$data->{variables}{$1} = $value;
} elsif ($key =~ /^J:A-(?:(\d+)-)?(.+)/s) {
@@ -402,34 +454,56 @@
return $data;
}
-sub _extract_continuations_from_webform {
- my $self = shift;
- my %args = (@_);
+=head2 continuation_id [CONTINUATION_ID]
- if ($args{'J:CLONE'} and Jifty->web->session->get_continuations($args{'J:CLONE'})) {
- my %params = %{Jifty->web->session->get_continuations($args{'J:CLONE'})->request->arguments};
- $self->argument($_ => $params{$_}) for keys %params;
- }
-}
+Gets or sets the ID of the continuation associated with the request.
+
+=cut
=head2 continuation [CONTINUATION]
-Gets or sets the continuation associated with the request.
+Returns the L<Jifty::Continuation> object associated with this
+request, if any.
=cut
sub continuation {
my $self = shift;
- $self->_continuation(@_) if @_;
- return $self->_continuation if $self->_continuation;
+ $self->continuation_id(ref $_[0] ? $_[0]->id : $_[0])
+ if @_;
- foreach my $continuation_id ($self->argument('J:C'), $self->argument('J:CALL') ) {
- next unless $continuation_id;
- return Jifty->web->session->get_continuation($continuation_id);
- }
+ return undef unless $self->continuation_id;
+ return Jifty->web->session->get_continuation($self->continuation_id);
+}
+
+=head3 save_continuation
+
+Saves the current request and response if we've been asked to. If we
+save the continuation, we redirect to the next page -- the call to
+C<save_continuation> never returns.
+
+=cut
+
+sub save_continuation {
+ my $self = shift;
+ my $path;
+ return unless $path = $self->continuation_path;
- return undef;
+ # Clear out the create path so we don't ave the "create a
+ # continuation" into the continuation!
+ $self->continuation_path(undef);
+
+ my $c = Jifty::Continuation->new(
+ request => $self,
+ response => Jifty->web->response,
+ parent => $self->continuation,
+ );
+
+ # Set us up with the new continuation
+ Jifty->web->_redirect( Jifty::Web->url . $path
+ . ( $path =~ /\?/ ? "&" : "?" ) . "J:C="
+ . $c->id );
}
=head2 call_continuation
@@ -443,14 +517,25 @@
sub call_continuation {
my $self = shift;
- my $cont = $self->arguments->{'J:CALL'};
- return unless $cont and Jifty->web->session->get_continuation($cont);
- $self->log->debug("Calling continuation $cont");
- $self->continuation(Jifty->web->session->get_continuation($cont));
+ return if $self->is_subrequest;
+ return unless $self->continuation_type and $self->continuation_type eq "call" and $self->continuation;
+ $self->log->debug("Calling continuation ".$self->continuation->id);
$self->continuation->call;
return 1;
}
+=head2 return_from_continuation
+
+=cut
+
+sub return_from_continuation {
+ my $self = shift;
+ return unless $self->continuation_type and $self->continuation_type eq "return" and $self->continuation;
+ return $self->continuation->call unless $self->continuation->return_path_matches;
+ $self->log->debug("Returning from continuation ".$self->continuation->id);
+ return $self->continuation->return;
+}
+
=head2 path
Returns the path that was requested
@@ -578,7 +663,7 @@
order => undef,
active => 1,
arguments => undef,
- has_run => undef,
+ has_run => 0,
@_
);
@@ -853,7 +938,7 @@
parameters. These are requests submitted using CGI GET or POST
requests to your Jifty application.
-=head2 argument munging
+=head3 argument munging
In addition to standard Mason argument munging, Jifty also takes
arguments with a B<name> of
@@ -864,9 +949,9 @@
separate arguments. The purpose is to allow submit buttons to act as
if they'd sent multiple values, without using JavaScript.
-=head2 actions
+=head3 actions
-=head3 registration
+=head4 registration
For each action, the client sends a query argument whose name is
C<J:A-I<moniker>> and whose value is the fully qualified class name of
@@ -874,7 +959,7 @@
The registration may also take the form C<J:A-I<order>-I<moniker>>,
which also sets the action's run order.
-=head3 arguments
+=head4 arguments
The action's arguments are specified with query arguments of the form
C<J:A:F-I<argumentname>-I<moniker>>. To cope with checkboxes and the
@@ -883,19 +968,19 @@
C<J:A:F:F-I<argumentname>-I<moniker>> and
C<J:A:F:F:F-I<argumentname>-I<moniker>>.
-=head2 state variables
+=head3 state variables
State variables are set via C<J:V-I<name>> being set to the value of
the state parameter.
-=head2 continuations
+=head4 continuations
The current continuation set by passing the parameter C<J:C>, which is
set to the id of the continuation. To create a new continuation, the
parameter C<J:CREATE> is passed. Calling a continuation is a ssimple
as passing C<J:CALL> with the id of the continuation to call.
-=head2 request options
+=head3 request options
The existence of C<J:VALIDATE> says that the request is only
validating arguments. C<J:ACTIONS> is set to a semicolon-separated
@@ -903,13 +988,12 @@
active, while all other actions are marked inactive. In the absence
of C<J:ACTIONS>, all actions are active.
-=head1 YAML POST Request Protocol
+=head2 YAML POST Request Protocol
+
-To be spec'd later
+=head2 JSON POST Request Protocol
-=head1 JSON POST Request Protocol
-To be spec'd later
=cut
Modified: jifty/branches/plugin_rewrite/lib/Jifty/Test.pm
==============================================================================
--- jifty/branches/plugin_rewrite/lib/Jifty/Test.pm (original)
+++ jifty/branches/plugin_rewrite/lib/Jifty/Test.pm Mon Jul 3 20:57:21 2006
@@ -28,7 +28,8 @@
Merges the L</test_config> into the default configuration, resets the
database, and resets the fake "outgoing mail" folder. This is the
-method to override if you wish to do custom setup work.
+method to override if you wish to do custom setup work, such as insert
+test data into your database.
=cut
@@ -81,6 +82,18 @@
It is passed the current configuration.
+You can override this to provide application-specific test
+configuration, e.g:
+
+ sub test_config {
+ my $class = shift;
+ my ($config) = @_;
+ my $hash = $class->SUPER::test_config($config);
+ $hash->{framework}{LogConfig} = "etc/log-test.conf"
+
+ return $hash;
+ }
+
=cut
sub test_config {
Modified: jifty/branches/plugin_rewrite/lib/Jifty/Test/WWW/Mechanize.pm
==============================================================================
--- jifty/branches/plugin_rewrite/lib/Jifty/Test/WWW/Mechanize.pm (original)
+++ jifty/branches/plugin_rewrite/lib/Jifty/Test/WWW/Mechanize.pm Mon Jul 3 20:57:21 2006
@@ -132,6 +132,8 @@
my $i;
for my $form ($self->forms) {
+ no warnings 'uninitialized';
+
$i++;
next unless first { $_->name =~ /J:A-(?:\d+-)?$moniker/
&& $_->type eq "hidden" }
@@ -307,9 +309,11 @@
sub get_html_ok {
my $self = shift;
$self->get(@_);
- # TODO XXX FIXME play with $Test::Builder::Level to get errors reported from
- # right place?
- html_ok($self->content);
+ {
+ local $Test::Builder::Level = $Test::Builder::Level;
+ $Test::Builder::Level++;
+ html_ok($self->content);
+ }
}
=head2 submit_html_ok
@@ -322,9 +326,11 @@
sub submit_html_ok {
my $self = shift;
$self->submit(@_);
- # TODO XXX FIXME play with $Test::Builder::Level to get errors reported from
- # right place?
- html_ok($self->content);
+ {
+ local $Test::Builder::Level = $Test::Builder::Level;
+ $Test::Builder::Level++;
+ html_ok($self->content);
+ }
}
=head2 follow_link_ok
@@ -343,9 +349,11 @@
carp("Couldn't find link") unless
$self->follow_link(@_);
- # TODO XXX FIXME play with $Test::Builder::Level to get errors reported from
- # right place?
- html_ok($self->content);
+ {
+ local $Test::Builder::Level = $Test::Builder::Level;
+ $Test::Builder::Level++;
+ html_ok($self->content);
+ }
}
=head2 session
@@ -379,7 +387,7 @@
return undef unless $session;
my $id = shift;
- ($id) = $self->uri =~ /J:C(?:ALL)?=([^&;]+)/ unless $id;
+ ($id) = $self->uri =~ /J:(?:C|CALL|RETURN)=([^&;]+)/ unless $id;
return $session->get_continuation($id);
}
Modified: jifty/branches/plugin_rewrite/lib/Jifty/Util.pm
==============================================================================
--- jifty/branches/plugin_rewrite/lib/Jifty/Util.pm (original)
+++ jifty/branches/plugin_rewrite/lib/Jifty/Util.pm Mon Jul 3 20:57:21 2006
@@ -197,7 +197,7 @@
if ($UNIVERSAL::require::ERROR) {
my $error = $UNIVERSAL::require::ERROR;
$error =~ s/ at .*?\n$//;
- Jifty->log->warn(sprintf("$error at %s line %d\n", (caller)[1,2]));
+ Jifty->log->error(sprintf("$error at %s line %d\n", (caller)[1,2]));
return 0;
}
Modified: jifty/branches/plugin_rewrite/lib/Jifty/Web.pm
==============================================================================
--- jifty/branches/plugin_rewrite/lib/Jifty/Web.pm (original)
+++ jifty/branches/plugin_rewrite/lib/Jifty/Web.pm Mon Jul 3 20:57:21 2006
@@ -46,6 +46,7 @@
formatDate.js
jifty.js
jifty_utils.js
+ jifty_smoothscroll.js
calendar.js
dom-drag.js
halo.js
@@ -255,13 +256,13 @@
Before they are run, however, the request has a chance to be
interrupted and saved away into a continuation, to be resumed at some
-later point. This is handled by L</save_continuation>.
+later point. This is handled by L<Jifty::Request/save_continuation>.
If the continuation isn't being saved, then C<handle_request> goes on
to run all of the actions. If all of the actions are successful, it
looks to see if the request wished to call any continuations, possibly
jumping back and re-running a request that was interrupted in the
-past. This is handled by L</call_continuation>.
+past. This is handled by L<Jifty::Request/call_continuation>.
For more details about continuations, see L<Jifty::Continuation>.
@@ -297,7 +298,7 @@
push @valid_actions, $request_action;
}
- $self->save_continuation;
+ $self->request->save_continuation;
unless ( $self->request->just_validating ) {
for my $request_action (@valid_actions) {
@@ -341,7 +342,6 @@
$self->request->do_mapping;
}
}
- $self->session->set_cookie();
# If there's a continuation call, don't do the rest of this
return if $self->response->success and $self->request->call_continuation;
@@ -565,11 +565,14 @@
my @actions = Jifty->web->request->actions;
- if ( $self->response->results
+ # To submit a Jifty::Action::Redirect, we don't need to serialize a continuation,
+ # unlike any other kind of actions.
+ if ( (grep { not $_->action_class->isa('Jifty::Action::Redirect') }
+ values %{{ $self->response->results }})
or $self->request->state_variables
or $self->{'state_variables'}
or $self->request->continuation
- or @actions )
+ or grep { $_->active and not $_->class->isa('Jifty::Action::Redirect') } @actions )
{
my $request = Jifty::Request->new();
$request->add_state_variable( key => $_->key, value => $_->value )
@@ -600,7 +603,7 @@
response => $self->response,
parent => $self->request->continuation,
);
- $page = $page->url."?J:CALL=" . $cont->id;
+ $page = $page->url."?J:RETURN=" . $cont->id;
} else {
$page = $page->complete_url;
}
@@ -633,87 +636,6 @@
Jifty::Dispatcher::_abort;
}
-=head3 save_continuation
-
-Saves the current request and response if we've been asked to. If we
-save the continuation, we redirect to the next page -- the call to
-C<save_continuation> never returns.
-
-=cut
-
-sub save_continuation {
- my $self = shift;
-
- my %args = %{ $self->request->arguments };
- my $clone = delete $self->request->arguments->{'J:CLONE'};
- my $create = delete $self->request->arguments->{'J:CREATE'};
- if ( $clone or $create ) {
-
- # Saving a continuation
- my $c = Jifty::Continuation->new(
- request => $self->request,
- response => $self->response,
- parent => $self->request->continuation,
- clone => $clone,
- );
-
-# XXX Only if we're cloning should we do the following check, I think?? Cloning isn't a stack push, so it works out
- if ( $clone
- and $self->request->just_validating
- and $self->response->failure )
- {
-
-# We don't get to redirect to the new page; redirect to the same page, new cont
- $self->_redirect(
- $self->request->path . "?J:C=" . $c->id );
- } else {
-
- # Set us up with the new continuation
- $self->_redirect( Jifty::Web->url . $args{'J:PATH'}
- . ( $args{'J:PATH'} =~ /\?/ ? "&" : "?" ) . "J:C="
- . $c->id );
- }
-
- }
-}
-
-=head3 multipage START_URL, ARGUMENTS
-
-B<Note>: This API is very much not finalized. Don't use it yet!
-
-Create a multipage action. The first argument is the URL of the start
-of the multipage action -- the user will be redirected there if they
-try to enter the multipage action on any other page. The rest of the
-arguments are passed to L<Jifty::Request/add_action> to create the
-multipage action.
-
-=cut
-
-sub multipage {
- my $self = shift;
- my ( $start, %args ) = @_;
-
- my $request_action = Jifty->web->caller->action( $args{moniker} );
-
- unless ($request_action) {
- my $request = Jifty::Request->new();
- $request->argument(
- 'J:CALL' => Jifty->web->request->continuation->id )
- if Jifty->web->request->continuation;
- $request->path("/");
- $request->add_action(%args);
- my $cont = Jifty::Continuation->new( request => $request );
- Jifty->web->redirect( $start . "?J:C=" . $cont->id );
- }
-
- my $action = Jifty->web->new_action_from_request($request_action);
- $action->result(
- Jifty->web->request->continuation->response->result( $args{moniker} )
- )
- if Jifty->web->request->continuation->response;
- return $action;
-}
-
=head3 caller
Returns the L<Jifty::Request> of our enclosing continuation, or an
@@ -757,10 +679,11 @@
$clickable->state_variable( $_ => $self->{'state_variables'}{$_} )
for keys %{ $self->{'state_variables'} };
- my $request = Jifty::Request->new(path => Jifty->web->request->path)
- ->from_webform(%{Jifty->web->request->arguments}, $clickable->get_parameters);
+ my $request = Jifty->web->request->clone;
+ my %clickable = $clickable->get_parameters;
+ $request->argument($_ => $clickable{$_}) for keys %clickable;
local Jifty->web->{request} = $request;
- Jifty->web->handle_request();
+ Jifty->web->request->save_continuation;
}
}
@@ -840,6 +763,8 @@
my $plural = $type . "s";
$self->out(qq{<div id="$plural">});
+ $self->out(qq[<a id="dismiss_$plural" href="#"
+ onclick="Effect.DropOut(this.parentNode); return false;">Dismiss</a>]);
foreach my $moniker ( @monikers ) {
if ( $results{$moniker}->$type() ) {
$self->out( qq{<div class="$type $moniker">}
Modified: jifty/branches/plugin_rewrite/lib/Jifty/Web/Form/Clickable.pm
==============================================================================
--- jifty/branches/plugin_rewrite/lib/Jifty/Web/Form/Clickable.pm (original)
+++ jifty/branches/plugin_rewrite/lib/Jifty/Web/Form/Clickable.pm Mon Jul 3 20:57:21 2006
@@ -298,8 +298,11 @@
my $name = ref $region ? $region->qualified_name : $region;
my $defaults = Jifty->web->get_region($name);
+ my $default = $defaults ? $defaults->default_argument($argument) : undef;
- if ( $defaults and $value eq $defaults->default_argument($argument) ) {
+ if ( ( not defined $default and not defined $value )
+ or ( defined $default and defined $value and $default eq $value ) )
+ {
$self->state_variable( "region-$name.$argument" => undef, $value );
} else {
$self->state_variable( "region-$name.$argument" => $value );
Modified: jifty/branches/plugin_rewrite/lib/Jifty/Web/Form/Field.pm
==============================================================================
--- jifty/branches/plugin_rewrite/lib/Jifty/Web/Form/Field.pm (original)
+++ jifty/branches/plugin_rewrite/lib/Jifty/Web/Form/Field.pm Mon Jul 3 20:57:21 2006
@@ -100,8 +100,8 @@
=cut
-sub accessors { shift->SUPER::accessors(), qw(name label input_name type sticky sticky_value default_value action mandatory ajax_validates autocompleter preamble hints render_mode length _element_id); }
-__PACKAGE__->mk_accessors(qw(name _label _input_name type sticky sticky_value default_value _action mandatory ajax_validates autocompleter preamble hints render_mode length _element_id));
+sub accessors { shift->SUPER::accessors(), qw(name label input_name type sticky sticky_value default_value action mandatory ajax_validates ajax_canonicalizes autocompleter preamble hints render_mode length _element_id); }
+__PACKAGE__->mk_accessors(qw(name _label _input_name type sticky sticky_value default_value _action mandatory ajax_validates ajax_canonicalizes autocompleter preamble hints render_mode length _element_id));
=head2 name [VALUE]
@@ -139,8 +139,6 @@
A boolean indicating that the argument B<must> be present when the
user submits the form.
-=back
-
=head2 ajax_validates [VALUE]
A boolean value indicating if user input into an HTML form field for
@@ -150,13 +148,14 @@
validated before the action is run, whether or not they also
C<ajax_validate>.
-=back
-
-=head2
-
-=back
+=head2 ajax_canonicalizes [VALUE]
-=cut
+A boolean value indicating if user input into an HTML form field for
+this argument should be L<canonicalized|Jifty::Manual::Glossary/canonicalize>
+via L<AJAX|Jifty::Manual::Glassary/AJAX> as the user fills out the
+form, instead of waiting until submit. Arguments will B<always> be
+canonicalized before the action is run, whether or not they also
+C<ajax_canonicalize>
=head2 id
@@ -452,7 +451,12 @@
sub _widget_class {
my $self = shift;
- my @classes = ('widget', $self->classes, ($self->ajax_validates ? ' ajaxvalidation' : ''), at _);
+ my @classes = ( 'widget',
+ $self->classes,
+ ( $self->ajax_validates ? ' ajaxvalidation' : '' ),
+ ( $self->ajax_canonicalizes ? ' ajaxcanonicalization' : '' ),
+ ( $self->autocompleter ? ' ajaxautocompletes' : '' ),
+ @_ );
return qq! class="!. join(' ', at classes). qq!"!
Modified: jifty/branches/plugin_rewrite/lib/Jifty/Web/PageRegion.pm
==============================================================================
--- jifty/branches/plugin_rewrite/lib/Jifty/Web/PageRegion.pm (original)
+++ jifty/branches/plugin_rewrite/lib/Jifty/Web/PageRegion.pm Mon Jul 3 20:57:21 2006
@@ -258,14 +258,10 @@
. qq|<div id="region-| . $self->qualified_name . qq|">|;
}
- # Merge in defaults
- %arguments = ( %{ Jifty->web->request->arguments },
- region => $self,
- %arguments );
-
# Make a fake request and throw it at the dispatcher
- my $subrequest = Jifty::Request->new;
- $subrequest->from_webform(%arguments);
+ my $subrequest = Jifty->web->request->clone;
+ $subrequest->argument( region => $self );
+ $subrequest->argument( $_ => $arguments{$_}) for keys %arguments;
$subrequest->path( $self->path );
$subrequest->top_request( Jifty->web->request->top_request );
Modified: jifty/branches/plugin_rewrite/lib/Jifty/Web/Session.pm
==============================================================================
--- jifty/branches/plugin_rewrite/lib/Jifty/Web/Session.pm (original)
+++ jifty/branches/plugin_rewrite/lib/Jifty/Web/Session.pm Mon Jul 3 20:57:21 2006
@@ -62,6 +62,7 @@
$session->create( key_type => "session" ) unless $session->id;
$self->_session($session);
+ $self->{cache} = undef;
}
=head2 unload
@@ -109,20 +110,37 @@
return undef unless $self->loaded;
- my $setting = Jifty::Model::Session->new;
- $setting->load_by_cols(
- session_id => $self->id,
- key_type => $key_type,
- data_key => $key
- );
- return $setting->value;
+ if ($key_type eq "continuation" or $key_type eq "session") {
+ my $setting = Jifty::Model::Session->new;
+ $setting->load_by_cols(
+ session_id => $self->id,
+ key_type => $key_type,
+ data_key => $key
+ );
+ return $setting->value;
+ } else {
+ unless ($self->{cache}) {
+ my $settings = Jifty::Model::SessionCollection->new;
+ $settings->limit( column => 'session_id', value => $self->id );
+ $settings->limit( column => 'key_type', value => 'continuation', operator => '!=', entry_aggregator => 'and' );
+ $settings->limit( column => 'key_type', value => 'session', operator => '!=', entry_aggregator => 'and' );
+ while (my $row = $settings->next) {
+ $self->{cache}{$row->key_type}{$row->data_key} = $row->value;
+ }
+ }
+
+ return $self->{cache}{$key_type}{$key};
+ }
+
}
=head2 set KEY => VALUE, [TYPE]
Sets the value C<VALUE> for C<KEY> for the session. C<TYPE>, which
defaults to "key", allows values to be set in other namespaces,
-including "metadata" and "continuation".
+including "metadata" and "continuation". C<VALUE> can be an arbitrary
+perl data structue -- C<Jifty::Web::Session> will serialize it for
+you.
=cut
@@ -151,6 +169,10 @@
value => $value
);
}
+
+ $self->{cache}{$key_type}{$key} = $value
+ if $self->{cache};
+
}
=head2 remove KEY, [TYPE]
Modified: jifty/branches/plugin_rewrite/plugins/EditInPlace/META.yml
==============================================================================
--- jifty/branches/plugin_rewrite/plugins/EditInPlace/META.yml (original)
+++ jifty/branches/plugin_rewrite/plugins/EditInPlace/META.yml Mon Jul 3 20:57:21 2006
@@ -1,7 +1,7 @@
build_requires:
ExtUtils::MakeMaker: 6.11
distribution_type: module
-generated_by: Module::Install version 0.620
+generated_by: Module::Install version 0.630
license: unknown
name: Jifty-Plugin-EditInPlace
no_index:
Modified: jifty/branches/plugin_rewrite/plugins/EditInPlace/lib/Jifty/Plugin/EditInPlace.pm
==============================================================================
--- jifty/branches/plugin_rewrite/plugins/EditInPlace/lib/Jifty/Plugin/EditInPlace.pm (original)
+++ jifty/branches/plugin_rewrite/plugins/EditInPlace/lib/Jifty/Plugin/EditInPlace.pm Mon Jul 3 20:57:21 2006
@@ -5,5 +5,30 @@
use base qw/Jifty::Plugin/;
+package HTML::Mason::Request::Jifty;
+
+=head2 fetch_comp
+
+=cut
+
+sub fetch_comp {
+ my $self = shift;
+ my $comp = $self->SUPER::fetch_comp(@_);
+ if (not $comp and Jifty->config->framework('DevelMode') ) {
+ my $comp_name = shift;
+ $comp = $self->interp->make_component(
+ comp_source =>
+ "
+ <span id=\"create-component-$comp_name\">
+<% Jifty->web->link(class => 'inline_create', label => 'Create $comp_name', onclick => [ { element => \"#create-component-$comp_name\", replace_with => '/__jifty/edit_inline/mason_component/$comp_name' } ]) %>
+ </span>
+ ");
+
+
+ }
+ return $comp;
+}
+
+
1;
Modified: jifty/branches/plugin_rewrite/plugins/EditInPlace/lib/Jifty/Plugin/EditInPlace/Action/FileEditor.pm
==============================================================================
--- jifty/branches/plugin_rewrite/plugins/EditInPlace/lib/Jifty/Plugin/EditInPlace/Action/FileEditor.pm (original)
+++ jifty/branches/plugin_rewrite/plugins/EditInPlace/lib/Jifty/Plugin/EditInPlace/Action/FileEditor.pm Mon Jul 3 20:57:21 2006
@@ -74,14 +74,15 @@
my $self = shift;
{ file_type => {
+ label => 'File type',
default => 'mason_component',
render_as => 'Select',
- valid_values => [qw/mason_component library/],
+ valid_values => [{ value => 'mason_component', display => 'Template'} , {value => 'library', display => 'Library'}],
constructor => 1
},
- source_path => { type => 'text', constructor => 1 },
+ source_path => { type => 'text', constructor => 1, label => 'Path' },
destination_path => { type => 'text', ajax_validates=> 1, label => 'Save as' },
- content => { render_as => 'Textarea', cols => 80, rows => 25 },
+ content => { render_as => 'Textarea', cols => 80, rows => 25, label => 'Content' },
}
@@ -161,6 +162,7 @@
my $self = shift;
my $dest = $self->{'write_to'};
+
# discard filename. we only want to make the directory ;)
Jifty::Util->make_path( File::Basename::dirname( $dest ) );
my $writehandle = IO::File->new();
Modified: jifty/branches/plugin_rewrite/plugins/EditInPlace/lib/Jifty/Plugin/EditInPlace/Dispatcher.pm
==============================================================================
--- jifty/branches/plugin_rewrite/plugins/EditInPlace/lib/Jifty/Plugin/EditInPlace/Dispatcher.pm (original)
+++ jifty/branches/plugin_rewrite/plugins/EditInPlace/lib/Jifty/Plugin/EditInPlace/Dispatcher.pm Mon Jul 3 20:57:21 2006
@@ -4,23 +4,24 @@
package Jifty::Plugin::EditInPlace::Dispatcher;
use Jifty::Dispatcher -base;
-before qr'^/__jifty/edit/(.*?)/(.*)$', run {
+before qr'^/__jifty/(edit|create)(_inline/|)/(.*?)/(.*)$', run {
# Claim this as ours -- skip ACLs, etc
last_rule;
};
-on qr'^/__jifty/edit/(.*?)/(.*)$', run {
+on qr'^/__jifty/(edit|create)(_inline|)/(.*?)/(.*)$', run {
my $editor = Jifty->web->new_action(
class => 'Jifty::Plugin::EditInPlace::Action::FileEditor',
moniker => 'editpage',
arguments => {
- source_path => $2,
- file_type => $1,
+ source_path => $4,
+ file_type => $3,
}
);
- set editor => $editor;
- show '/__jifty/edit_file';
+ set editor => $editor;
+ set path => $4;
+ show "/__jifty/$1_file$2";
};
Added: jifty/branches/plugin_rewrite/plugins/EditInPlace/share/web/templates/__jifty/create_file_inline
==============================================================================
--- (empty file)
+++ jifty/branches/plugin_rewrite/plugins/EditInPlace/share/web/templates/__jifty/create_file_inline Mon Jul 3 20:57:21 2006
@@ -0,0 +1,12 @@
+<%attr>
+edit_inline => 0
+</%attr>
+<%args>
+$path => undef
+$line => undef
+</%args>
+<% Jifty->web->link(label => _("Create $path"),
+ onclick => {
+ replace_with => '/__jifty/edit_inline/mason_component/'.$path,
+ },
+ )%>
Added: jifty/branches/plugin_rewrite/plugins/EditInPlace/share/web/templates/__jifty/edit_file_inline
==============================================================================
--- (empty file)
+++ jifty/branches/plugin_rewrite/plugins/EditInPlace/share/web/templates/__jifty/edit_file_inline Mon Jul 3 20:57:21 2006
@@ -0,0 +1,14 @@
+<%args>
+$path => undef
+$editor => undef
+$line => undef
+</%args>
+<% Jifty->web->form->start %>
+<%$editor->form_field('destination_path', render_as => 'hidden')%>
+<%$editor->form_field('content')->render_widget%>
+<% Jifty->web->form->submit(label => 'Save', onclick => { submit => $editor,
+ replace_with => $path,
+ },
+
+ submit => $editor )%>
+<% Jifty->web->form->end %>
Added: jifty/branches/plugin_rewrite/plugins/LetMe/Makefile.PL
==============================================================================
--- (empty file)
+++ jifty/branches/plugin_rewrite/plugins/LetMe/Makefile.PL Mon Jul 3 20:57:21 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/branches/plugin_rewrite/plugins/LetMe/lib/Jifty/Plugin/LetMe.pm
==============================================================================
--- (empty file)
+++ jifty/branches/plugin_rewrite/plugins/LetMe/lib/Jifty/Plugin/LetMe.pm Mon Jul 3 20:57:21 2006
@@ -0,0 +1,51 @@
+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';
+ };
+
+If a user tried to access a path under C<Jifty::LetMe->base_path> with
+an invalid LetMe, we redirect them to '/error/let_me/invalid_token'.
+
+=cut
+
+our $DISABLE_ACTIONS = 1;
+
+sub init {
+ my $self = shift;
+ my %args = (DisableActions => 1,
+ @_);
+ $DISABLE_ACTIONS = $args{DisableActions};
+}
+
+1;
Added: jifty/branches/plugin_rewrite/plugins/LetMe/lib/Jifty/Plugin/LetMe/Dispatcher.pm
==============================================================================
--- (empty file)
+++ jifty/branches/plugin_rewrite/plugins/LetMe/lib/Jifty/Plugin/LetMe/Dispatcher.pm Mon Jul 3 20:57:21 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;
Added: jifty/branches/plugin_rewrite/plugins/Nothing/Makefile.PL
==============================================================================
--- (empty file)
+++ jifty/branches/plugin_rewrite/plugins/Nothing/Makefile.PL Mon Jul 3 20:57:21 2006
@@ -0,0 +1,8 @@
+use inc::Module::Install;
+name('Jifty-Plugin-Nothing');
+version('0.01');
+requires('Jifty' => '0.60615');
+
+install_share;
+
+WriteAll;
Added: jifty/branches/plugin_rewrite/plugins/Nothing/lib/Jifty/Plugin/Nothing.pm
==============================================================================
--- (empty file)
+++ jifty/branches/plugin_rewrite/plugins/Nothing/lib/Jifty/Plugin/Nothing.pm Mon Jul 3 20:57:21 2006
@@ -0,0 +1,10 @@
+use strict;
+use warnings;
+
+package Jifty::Plugin::Nothing;
+use base qw/Jifty::Plugin/;
+
+# Your plugin goes here. If takes any configuration or arguments, you
+# probably want to override L<Jifty::Plugin/init>.
+
+1;
Added: jifty/branches/plugin_rewrite/plugins/Nothing/lib/Jifty/Plugin/Nothing/Dispatcher.pm
==============================================================================
--- (empty file)
+++ jifty/branches/plugin_rewrite/plugins/Nothing/lib/Jifty/Plugin/Nothing/Dispatcher.pm Mon Jul 3 20:57:21 2006
@@ -0,0 +1,9 @@
+use strict;
+use warnings;
+
+package Jifty::Plugin::Nothing::Dispatcher;
+use Jifty::Dispatcher -base;
+
+# Put any plugin-specific dispatcher rules here.
+
+1;
Modified: jifty/branches/plugin_rewrite/share/web/static/css/forms.css
==============================================================================
--- jifty/branches/plugin_rewrite/share/web/static/css/forms.css (original)
+++ jifty/branches/plugin_rewrite/share/web/static/css/forms.css Mon Jul 3 20:57:21 2006
@@ -52,6 +52,11 @@
padding: 0.2em;
}
+form input.ajaxautocompletes {
+ background: #fff url(/static/images/css/fieldbg-autocomplete.gif) repeat-x top right;
+ padding-right: 18px;
+}
+
input.date {
width: 10em;
}
Modified: jifty/branches/plugin_rewrite/share/web/static/css/halos.css
==============================================================================
--- jifty/branches/plugin_rewrite/share/web/static/css/halos.css (original)
+++ jifty/branches/plugin_rewrite/share/web/static/css/halos.css Mon Jul 3 20:57:21 2006
@@ -99,3 +99,26 @@
right:0.5em;
bottom:0;
}
+
+a.inline_edit {
+
+ display: block;
+ width: 0;
+ padding-left: 22px;
+ min-height: 20px;
+
+ background: no-repeat left center;
+ background: url(/static/images/silk/pencil.png) no-repeat 0 0;
+}
+
+a.inline_create {
+
+ display: block;
+ width: 0;
+ padding-left: 22px;
+ min-height: 20px;
+
+ background: no-repeat left center;
+ background: url(/static/images/silk/pencil_add.png) no-repeat 0 0;
+}
+
Modified: jifty/branches/plugin_rewrite/share/web/static/css/keybindings.css
==============================================================================
--- jifty/branches/plugin_rewrite/share/web/static/css/keybindings.css (original)
+++ jifty/branches/plugin_rewrite/share/web/static/css/keybindings.css Mon Jul 3 20:57:21 2006
@@ -4,10 +4,6 @@
}
-div#keybindings:before {
- content: "Hotkeys:";
-}
-
dl.keybindings .keybinding {
display: inline;
}
Modified: jifty/branches/plugin_rewrite/share/web/static/css/main.css
==============================================================================
--- jifty/branches/plugin_rewrite/share/web/static/css/main.css (original)
+++ jifty/branches/plugin_rewrite/share/web/static/css/main.css Mon Jul 3 20:57:21 2006
@@ -10,3 +10,4 @@
@import "app.css";
@import "autocomplete.css";
@import "yui/calendar/calendar.css";
+ at import "notices.css";
Added: jifty/branches/plugin_rewrite/share/web/static/css/notices.css
==============================================================================
--- (empty file)
+++ jifty/branches/plugin_rewrite/share/web/static/css/notices.css Mon Jul 3 20:57:21 2006
@@ -0,0 +1,39 @@
+/* IE can't handle this nicely w/ AJAX validation */
+
+html>body .message {
+ background: url(/static/images/silk/information.png) no-repeat center left;
+ padding-left: 20px;
+}
+
+html>body .error {
+ background: url(/static/images/silk/error.png) no-repeat center left;
+ padding-left: 20px;
+}
+
+.error {
+ color: #a00000;
+}
+
+div#messages, div#errors {
+ background-color: rgb(240,234,183);
+ border: 1px solid rgb(230,224,173);
+ margin-top: 10px;
+ margin-bottom: 10px;
+ padding: 5px 20px 5px 5px;
+ font-size: 1.2em;
+ position: relative;
+}
+
+#dismiss_messages,
+#dismiss_errors
+{
+ padding-left: 16px;
+ background: url(/static/images/silk/cancel.png) no-repeat;
+ position: absolute;
+ top: 1px;
+ right: 1px;
+ width: 0;
+ display: block;
+ text-indent: -9999em;
+}
+
Modified: jifty/branches/plugin_rewrite/share/web/static/css/yui/calendar/calendar.css
==============================================================================
--- jifty/branches/plugin_rewrite/share/web/static/css/yui/calendar/calendar.css (original)
+++ jifty/branches/plugin_rewrite/share/web/static/css/yui/calendar/calendar.css Mon Jul 3 20:57:21 2006
@@ -109,7 +109,7 @@
/* Added to perform some correction for Opera 8.5
hover redraw bug */
-table:hover {
+.calendar table:hover {
background-color:#FFF;
}
Added: jifty/branches/plugin_rewrite/share/web/static/images/css/fieldbg-autocomplete.gif
==============================================================================
Binary file. No diff available.
Added: jifty/branches/plugin_rewrite/share/web/static/images/silk/pencil.png
==============================================================================
Binary file. No diff available.
Added: jifty/branches/plugin_rewrite/share/web/static/images/silk/pencil_add.png
==============================================================================
Binary file. No diff available.
Modified: jifty/branches/plugin_rewrite/share/web/static/js/context_menu.js
==============================================================================
--- jifty/branches/plugin_rewrite/share/web/static/js/context_menu.js (original)
+++ jifty/branches/plugin_rewrite/share/web/static/js/context_menu.js Mon Jul 3 20:57:21 2006
@@ -71,9 +71,10 @@
Element.removeClassName(li, "closed");
Element.addClassName(li, "open");
-
+
ul.style.display = "block";
Jifty.ContextMenu.currently_open = ul.id;
+ Jifty.ContextMenu.scrollToShow( ul.id );
},
hideOpenMenu: function(event) {
@@ -94,6 +95,17 @@
if (Jifty.ContextMenu.currently_open) {
Jifty.ContextMenu.hide(Jifty.ContextMenu.currently_open);
}
+ },
+
+ scrollToShow: function(id) {
+ var ul = $(id);
+ var y = Jifty.Utils.findPosY( ul ) + ul.offsetHeight + 10;
+ var scrollTop = Jifty.Utils.getScrollTop();
+ var screen = Jifty.Utils.findScreenHeight() + scrollTop;
+ var diff = y - screen;
+
+ if ( diff > 0 )
+ Jifty.SmoothScroll.scrollTo( scrollTop + diff );
}
};
Modified: jifty/branches/plugin_rewrite/share/web/static/js/jifty.js
==============================================================================
--- jifty/branches/plugin_rewrite/share/web/static/js/jifty.js (original)
+++ jifty/branches/plugin_rewrite/share/web/static/js/jifty.js Mon Jul 3 20:57:21 2006
@@ -368,7 +368,7 @@
// Form elements should AJAX validate if the CSS says so
Behaviour.register({
- 'input.ajaxvalidation, textarea.ajaxvalidation': function(elt) {
+ 'input.ajaxvalidation, textarea.ajaxvalidation, input.ajaxcanonicalization, textarea.ajaxcanonicalization': function(elt) {
elt.onblur = function () {
Form.Element.validate(this);
}
Added: jifty/branches/plugin_rewrite/share/web/static/js/jifty_smoothscroll.js
==============================================================================
--- (empty file)
+++ jifty/branches/plugin_rewrite/share/web/static/js/jifty_smoothscroll.js Mon Jul 3 20:57:21 2006
@@ -0,0 +1,36 @@
+
+if (typeof Jifty == "undefined") Jifty = { };
+
+Jifty.SmoothScroll = {
+ interval: '',
+ steps: 20,
+
+ scrollTo: function( y ) {
+ if ( Jifty.SmoothScroll.interval )
+ clearInterval( Jifty.SmoothScroll.interval );
+
+ var stepsize = parseInt( ( y - Jifty.Utils.getScrollTop() ) / Jifty.SmoothScroll.steps );
+
+ Jifty.SmoothScroll.interval
+ = setInterval('Jifty.SmoothScroll.scrollWindow('+stepsize+','+y+')',10);
+ },
+
+ scrollWindow: function( amount, y ) {
+ var curpos = Jifty.Utils.getScrollTop();
+ var isAbove = ( curpos < y );
+
+ window.scrollTo( 0, curpos + amount );
+
+ var newpos = Jifty.Utils.getScrollTop();
+ var newIsAbove = ( newpos < y );
+
+ if ( ( isAbove != newIsAbove ) || ( curpos == newpos ) ) {
+ /* We've just scrolled past the destination, or we haven't moved
+ from the last scroll (i.e., we're at the bottom of the page),
+ so scroll exactly to the position
+ */
+ window.scrollTo( 0, y );
+ clearInterval( Jifty.SmoothScroll.interval );
+ }
+ }
+};
Modified: jifty/branches/plugin_rewrite/share/web/static/js/jifty_utils.js
==============================================================================
--- jifty/branches/plugin_rewrite/share/web/static/js/jifty_utils.js (original)
+++ jifty/branches/plugin_rewrite/share/web/static/js/jifty_utils.js Mon Jul 3 20:57:21 2006
@@ -2,38 +2,66 @@
if (typeof Jifty == "undefined") Jifty = { };
Jifty.Utils = {
- /* From http://www.quirksmode.org/js/findpos.html */
- findPosX: function(obj) {
- var curleft = 0;
- if (obj.offsetParent)
- {
- while (obj.offsetParent)
- {
- curleft += obj.offsetLeft
- obj = obj.offsetParent;
- }
- }
- else if (obj.x)
- curleft += obj.x;
- return curleft;
+ /* From http://blog.firetree.net/2005/07/04/javascript-find-position/ */
+ findPosX: function(obj)
+ {
+ var curleft = 0;
+ if(obj.offsetParent)
+ while(1)
+ {
+ curleft += obj.offsetLeft;
+ if(!obj.offsetParent)
+ break;
+ obj = obj.offsetParent;
+ }
+ else if(obj.x)
+ curleft += obj.x;
+ return curleft;
+ },
+
+ findPosY: function(obj)
+ {
+ var curtop = 0;
+ if(obj.offsetParent)
+ while(1)
+ {
+ curtop += obj.offsetTop;
+ if(!obj.offsetParent)
+ break;
+ obj = obj.offsetParent;
+ }
+ else if(obj.y)
+ curtop += obj.y;
+ return curtop;
},
- findPosY: function(obj) {
- var curtop = 0;
- if (obj.offsetParent)
- {
- while (obj.offsetParent)
- {
- curtop += obj.offsetTop
- obj = obj.offsetParent;
+ isMSIE: false,
+
+ findScreenHeight: function() {
+ if ( window.innerHeight ) {
+ return window.innerHeight;
+ }
+ else {
+ if ( document.documentElement.clientHeight ) {
+ return document.documentElement.clientHeight;
+ }
+ else {
+ if ( document.body.clientHeight ) {
+ return document.body.clientHeight;
+ }
}
}
- else if (obj.y)
- curtop += obj.y;
- return curtop;
},
- isMSIE: false
+ getScrollTop: function() {
+ if (document.body && document.body.scrollTop)
+ return document.body.scrollTop;
+ if (document.documentElement && document.documentElement.scrollTop)
+ return document.documentElement.scrollTop;
+ if (window.pageYOffset)
+ return window.pageYOffset;
+ return 0;
+ }
};
/* This sets Jifty.Utils.isMSIE to true in IE
Modified: jifty/branches/plugin_rewrite/share/web/static/js/key_bindings.js
==============================================================================
--- jifty/branches/plugin_rewrite/share/web/static/js/key_bindings.js (original)
+++ jifty/branches/plugin_rewrite/share/web/static/js/key_bindings.js Mon Jul 3 20:57:21 2006
@@ -99,6 +99,11 @@
}
if ( dl.hasChildNodes() ) {
+ var label = document.createElement("div");
+ label.setAttribute("class", "keybindings_label");
+ label.appendChild( document.createTextNode("Hotkeys:") );
+
+ e.appendChild( label );
e.appendChild( dl );
Element.addClassName(e, 'keybindings-written');
Modified: jifty/branches/plugin_rewrite/share/web/templates/__jifty/halo
==============================================================================
--- jifty/branches/plugin_rewrite/share/web/templates/__jifty/halo (original)
+++ jifty/branches/plugin_rewrite/share/web/templates/__jifty/halo Mon Jul 3 20:57:21 2006
@@ -15,7 +15,7 @@
<li><a href="#" class="halo_comp_info" onmouseover="halo_over('<% $item->{id} %>')"
onmouseout="halo_out('<% $item->{id} %>')"
onclick="halo_toggle('<% $item->{id} %>'); return false;">
-<% $item->{'path'} %> - <% $item->{'render_time'} %></a>
+<% $item->{'name'} %> - <% $item->{'render_time'} %></a>
% unless ($item->{subcomponent}) {
<% Jifty->web->tangent( url =>"/__jifty/edit/mason_component/".$item->{'path'}, label => 'Edit') %>
% }
@@ -114,7 +114,7 @@
<li>
<span class="fixed"><% $_->[1] %></span><br />
% if (@{$_->[2]}) {
-<b>Bindings:</b> <tt><% join(',', map {defined $_ ? ($_ =~ /\0/ ? "*BLOB*" : $_ ) : "undef"} @{$_->[2]}) %></tt><br />
+<b>Bindings:</b> <tt><% join(',', map {defined $_ ? ($_ =~ /[^[:space:][:graph:]]/ ? "*BLOB*" : $_ ) : "undef"} @{$_->[2]}) %></tt><br />
% }
<i><% _('%1 seconds', $_->[3]) %></i>
</li>
Modified: jifty/branches/plugin_rewrite/t/03-form-protocol.t
==============================================================================
--- jifty/branches/plugin_rewrite/t/03-form-protocol.t (original)
+++ jifty/branches/plugin_rewrite/t/03-form-protocol.t Mon Jul 3 20:57:21 2006
@@ -17,6 +17,7 @@
moniker: mymoniker
class: DoSomething
active: 1
+ has_run: 0
arguments:
id: 23
something: else
@@ -43,6 +44,7 @@
moniker: mymoniker
class: DoSomething
active: 1
+ has_run: 0
arguments:
id: 23
something: else
@@ -50,6 +52,7 @@
moniker: second
class: DoSomething
active: 1
+ has_run: 0
arguments:
id: 42
something: bla
@@ -79,6 +82,7 @@
moniker: mymoniker
class: DoSomething
active: 1
+ has_run: 0
arguments:
id: 23
something: else
@@ -86,6 +90,7 @@
moniker: second
class: DoThat
active: 1
+ has_run: 0
arguments:
id: 42
something: bla
@@ -114,6 +119,7 @@
moniker: mymoniker
class: DoSomething
active: 1
+ has_run: 0
arguments:
id: 23
something: else
@@ -142,6 +148,7 @@
moniker: mymoniker
class: DoSomething
active: 0
+ has_run: 0
arguments:
id: 23
something: else
@@ -149,6 +156,7 @@
moniker: second
class: DoThat
active: 1
+ has_run: 0
arguments:
id: 42
something: bla
@@ -177,6 +185,7 @@
moniker: mymoniker
class: DoSomething
active: 1
+ has_run: 0
arguments:
id: 23
something: else
@@ -184,6 +193,7 @@
moniker: second
class: DoThat
active: 1
+ has_run: 0
arguments:
id: 42
something: bla
@@ -215,6 +225,7 @@
moniker: mymoniker
class: DoSomething
active: 1
+ has_run: 0
arguments:
id: 23
something: else
@@ -222,6 +233,7 @@
moniker: second
class: DoThat
active: 1
+ has_run: 0
arguments:
id: 42
something: bla
@@ -253,6 +265,7 @@
moniker: mymoniker
class: DoSomething
active: 1
+ has_run: 0
arguments:
id: 23
something: else
@@ -260,6 +273,7 @@
moniker: second
class: DoThat
active: 1
+ has_run: 0
arguments:
id: 42
something: bla
@@ -286,6 +300,7 @@
moniker: mymoniker
class: DoSomething
active: 1
+ has_run: 0
arguments:
id: 23
something: else
@@ -311,6 +326,7 @@
moniker: mymoniker
class: DoSomething
active: 1
+ has_run: 0
arguments:
id: 23
something: else
@@ -335,6 +351,7 @@
moniker: mymoniker
class: DoSomething
active: 1
+ has_run: 0
arguments:
id: 96
something: else
@@ -362,6 +379,7 @@
moniker: mymoniker
class: DoSomething
active: 1
+ has_run: 0
arguments:
id: 23
something: else
@@ -369,6 +387,7 @@
moniker: second
class: DoThat
active: 1
+ has_run: 0
arguments:
id: 42
something: feepy
@@ -398,6 +417,7 @@
moniker: mymoniker
class: DoSomething
active: 1
+ has_run: 0
arguments:
id: 123
something: else
@@ -424,6 +444,7 @@
moniker: mymoniker
class: DoSomething
active: 1
+ has_run: 0
arguments:
id: 123
something: else
@@ -449,6 +470,7 @@
moniker: mymoniker
class: DoSomething
active: 1
+ has_run: 0
arguments:
id: 456
something: else
@@ -473,6 +495,7 @@
moniker: mymoniker
class: DoSomething
active: 1
+ has_run: 0
arguments:
id: 789
something: else
@@ -500,6 +523,7 @@
moniker: mymoniker
class: DoSomething
active: 1
+ has_run: 0
arguments:
id: 23
something: else
@@ -507,6 +531,7 @@
moniker: second
class: DoSomething
active: 1
+ has_run: 0
arguments:
id: 42
something: bla
Modified: jifty/branches/plugin_rewrite/t/Continuations/lib/Continuations/Dispatcher.pm
==============================================================================
--- jifty/branches/plugin_rewrite/t/Continuations/lib/Continuations/Dispatcher.pm (original)
+++ jifty/branches/plugin_rewrite/t/Continuations/lib/Continuations/Dispatcher.pm Mon Jul 3 20:57:21 2006
@@ -1,12 +1,12 @@
package Continuations::Dispatcher;
use Jifty::Dispatcher -base;
-
+my $before = 0;
before '/tutorial' => run {
unless (Jifty->web->session->get('got_help')) {
Jifty->web->tangent(url => '/index-help.html');
}
- set been_helped => 1;
+ set been_helped => ++$before;
};
on '/tutorial' => run {
@@ -17,6 +17,4 @@
Jifty->web->session->set(got_help => 1);
};
-on '*' => show;
-
1;
Modified: jifty/branches/plugin_rewrite/t/Continuations/share/web/templates/index.html
==============================================================================
--- jifty/branches/plugin_rewrite/t/Continuations/share/web/templates/index.html (original)
+++ jifty/branches/plugin_rewrite/t/Continuations/share/web/templates/index.html Mon Jul 3 20:57:21 2006
@@ -14,5 +14,5 @@
<% Jifty->web->form->end %>
% if($been_helped) {
-<p>Congratulations on being helped.</p>
+<p>Congratulations on being helped: <% $been_helped %>.</p>
% }
Modified: jifty/branches/plugin_rewrite/t/Continuations/t/04-before-blocks.t
==============================================================================
--- jifty/branches/plugin_rewrite/t/Continuations/t/04-before-blocks.t (original)
+++ jifty/branches/plugin_rewrite/t/Continuations/t/04-before-blocks.t Mon Jul 3 20:57:21 2006
@@ -12,7 +12,7 @@
BEGIN {chdir "t/Continuations"}
use lib '../../lib';
-use Jifty::Test tests => 7;
+use Jifty::Test tests => 9;
use_ok('Jifty::Test::WWW::Mechanize');
@@ -25,9 +25,11 @@
$mech->follow_link_ok(text => 'Done');
like($mech->uri, qr'/tutorial', 'Continuation call worked properly');
$mech->content_contains('Congratulations', 'before blocks got run properly on continuation call');
+$mech->content_contains('being helped: 1', 'before blocks got run only once');
$mech->get($URL . '/tutorial');
$mech->content_contains('Congratulations', 'before blocks got run properly');
+$mech->content_contains('being helped: 2', 'before blocks got run only once again');
1;
More information about the Jifty-commit
mailing list