[Jifty-commit] r2191 - in jifty/branches/template-declare: . lib
lib/Jifty lib/Jifty/Action lib/Jifty/Event lib/Jifty/Manual
lib/Jifty/Param lib/Jifty/Plugin/REST lib/Jifty/Script
lib/Jifty/Web lib/Jifty/Web/Form lib/Jifty/Web/Form/Field
plugins/AuthLDAPLogin plugins/AuthLDAPLogin/debian
plugins/AuthLDAPLogin/doc plugins/AuthLDAPLogin/lib
plugins/AuthLDAPLogin/lib/Jifty
plugins/AuthLDAPLogin/lib/Jifty/Plugin
plugins/AuthLDAPLogin/lib/Jifty/Plugin/AuthLDAPLogin
plugins/AuthLDAPLogin/lib/Jifty/Plugin/AuthLDAPLogin/Action
plugins/AuthLDAPLogin/lib/Jifty/Plugin/AuthLDAPLogin/Model
plugins/AuthLDAPLogin/share plugins/AuthLDAPLogin/share/web
plugins/AuthLDAPLogin/share/web/static
plugins/AuthLDAPLogin/share/web/templates
plugins/AuthLDAPLogin/t plugins/AuthLDAPOnly
plugins/AuthLDAPOnly/debian plugins/AuthLDAPOnly/doc
plugins/AuthLDAPOnly/lib plugins/AuthLDAPOnly/lib/Jifty
plugins/AuthLDAPOnly/lib/Jifty/Plugin
plugins/AuthLDAPOnly/lib/Jifty/Plugin/AuthLDAPOnly
plugins/AuthLDAPOnly/lib/Jifty/Plugin/AuthLDAPOnly/Action
plugins/AuthLDAPOnly/lib/Jifty/Plugin/AuthLDAPOnly/Model
plugins/AuthLDAPOnly/share plugins/AuthLDAPOnly/share/po
plugins/AuthLDAPOnly/share/web plugins/AuthLDAPOnly/share/web/static
plugins/AuthLDAPOnly/share/web/templates
plugins/AuthLDAPOnly/t plugins/Login
plugins/Login/lib/Jifty/Plugin share/web/static/css
share/web/static/js share/web/templates/__jifty
share/web/templates/__jifty/admin/fragments/list t
t/TestApp/lib/TestApp/Action t/TestApp/t
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Wed Nov 22 09:33:00 EST 2006
Author: clkao
Date: Wed Nov 22 09:32:58 2006
New Revision: 2191
Added:
jifty/branches/template-declare/plugins/AuthLDAPLogin/
jifty/branches/template-declare/plugins/AuthLDAPLogin/MANIFEST
jifty/branches/template-declare/plugins/AuthLDAPLogin/Makefile.PL
jifty/branches/template-declare/plugins/AuthLDAPLogin/debian/
jifty/branches/template-declare/plugins/AuthLDAPLogin/debian/changelog
jifty/branches/template-declare/plugins/AuthLDAPLogin/debian/compat
jifty/branches/template-declare/plugins/AuthLDAPLogin/debian/control
jifty/branches/template-declare/plugins/AuthLDAPLogin/debian/copyright
jifty/branches/template-declare/plugins/AuthLDAPLogin/debian/rules (contents, props changed)
jifty/branches/template-declare/plugins/AuthLDAPLogin/doc/
jifty/branches/template-declare/plugins/AuthLDAPLogin/lib/
jifty/branches/template-declare/plugins/AuthLDAPLogin/lib/Jifty/
jifty/branches/template-declare/plugins/AuthLDAPLogin/lib/Jifty/Plugin/
jifty/branches/template-declare/plugins/AuthLDAPLogin/lib/Jifty/Plugin/AuthLDAPLogin/
jifty/branches/template-declare/plugins/AuthLDAPLogin/lib/Jifty/Plugin/AuthLDAPLogin.pm
jifty/branches/template-declare/plugins/AuthLDAPLogin/lib/Jifty/Plugin/AuthLDAPLogin/Action/
jifty/branches/template-declare/plugins/AuthLDAPLogin/lib/Jifty/Plugin/AuthLDAPLogin/Action/LDAPLogin.pm
jifty/branches/template-declare/plugins/AuthLDAPLogin/lib/Jifty/Plugin/AuthLDAPLogin/Action/LDAPLogout.pm
jifty/branches/template-declare/plugins/AuthLDAPLogin/lib/Jifty/Plugin/AuthLDAPLogin/Dispatcher.pm
jifty/branches/template-declare/plugins/AuthLDAPLogin/lib/Jifty/Plugin/AuthLDAPLogin/Model/
jifty/branches/template-declare/plugins/AuthLDAPLogin/share/
jifty/branches/template-declare/plugins/AuthLDAPLogin/share/po/
jifty/branches/template-declare/plugins/AuthLDAPLogin/share/po/en.po
jifty/branches/template-declare/plugins/AuthLDAPLogin/share/po/fr.po
jifty/branches/template-declare/plugins/AuthLDAPLogin/share/web/
jifty/branches/template-declare/plugins/AuthLDAPLogin/share/web/static/
jifty/branches/template-declare/plugins/AuthLDAPLogin/share/web/templates/
jifty/branches/template-declare/plugins/AuthLDAPLogin/share/web/templates/ldaplogin
jifty/branches/template-declare/plugins/AuthLDAPLogin/share/web/templates/ldaplogout
jifty/branches/template-declare/plugins/AuthLDAPLogin/t/
jifty/branches/template-declare/plugins/AuthLDAPOnly/
jifty/branches/template-declare/plugins/AuthLDAPOnly/MANIFEST
jifty/branches/template-declare/plugins/AuthLDAPOnly/Makefile.PL
jifty/branches/template-declare/plugins/AuthLDAPOnly/debian/
jifty/branches/template-declare/plugins/AuthLDAPOnly/debian/changelog
jifty/branches/template-declare/plugins/AuthLDAPOnly/debian/compat
jifty/branches/template-declare/plugins/AuthLDAPOnly/debian/control
jifty/branches/template-declare/plugins/AuthLDAPOnly/debian/copyright
jifty/branches/template-declare/plugins/AuthLDAPOnly/debian/rules (contents, props changed)
jifty/branches/template-declare/plugins/AuthLDAPOnly/doc/
jifty/branches/template-declare/plugins/AuthLDAPOnly/lib/
jifty/branches/template-declare/plugins/AuthLDAPOnly/lib/Jifty/
jifty/branches/template-declare/plugins/AuthLDAPOnly/lib/Jifty/Plugin/
jifty/branches/template-declare/plugins/AuthLDAPOnly/lib/Jifty/Plugin/AuthLDAPOnly/
jifty/branches/template-declare/plugins/AuthLDAPOnly/lib/Jifty/Plugin/AuthLDAPOnly.pm
jifty/branches/template-declare/plugins/AuthLDAPOnly/lib/Jifty/Plugin/AuthLDAPOnly/Action/
jifty/branches/template-declare/plugins/AuthLDAPOnly/lib/Jifty/Plugin/AuthLDAPOnly/Action/LDAPLogin.pm
jifty/branches/template-declare/plugins/AuthLDAPOnly/lib/Jifty/Plugin/AuthLDAPOnly/Action/LDAPLogout.pm
jifty/branches/template-declare/plugins/AuthLDAPOnly/lib/Jifty/Plugin/AuthLDAPOnly/CurrentUser.pm
jifty/branches/template-declare/plugins/AuthLDAPOnly/lib/Jifty/Plugin/AuthLDAPOnly/Dispatcher.pm
jifty/branches/template-declare/plugins/AuthLDAPOnly/lib/Jifty/Plugin/AuthLDAPOnly/Model/
jifty/branches/template-declare/plugins/AuthLDAPOnly/lib/Jifty/Plugin/AuthLDAPOnly/Model/LDAPUser.pm
jifty/branches/template-declare/plugins/AuthLDAPOnly/share/
jifty/branches/template-declare/plugins/AuthLDAPOnly/share/po/
jifty/branches/template-declare/plugins/AuthLDAPOnly/share/po/en.po
jifty/branches/template-declare/plugins/AuthLDAPOnly/share/po/fr.po
jifty/branches/template-declare/plugins/AuthLDAPOnly/share/web/
jifty/branches/template-declare/plugins/AuthLDAPOnly/share/web/static/
jifty/branches/template-declare/plugins/AuthLDAPOnly/share/web/templates/
jifty/branches/template-declare/plugins/AuthLDAPOnly/share/web/templates/ldaplogin
jifty/branches/template-declare/plugins/AuthLDAPOnly/share/web/templates/ldaplogout
jifty/branches/template-declare/plugins/AuthLDAPOnly/t/
jifty/branches/template-declare/t/DateTime.t
Modified:
jifty/branches/template-declare/ (props changed)
jifty/branches/template-declare/MANIFEST
jifty/branches/template-declare/META.yml
jifty/branches/template-declare/Makefile.PL
jifty/branches/template-declare/lib/Jifty.pm
jifty/branches/template-declare/lib/Jifty/Action.pm
jifty/branches/template-declare/lib/Jifty/Action/Record.pm
jifty/branches/template-declare/lib/Jifty/DateTime.pm
jifty/branches/template-declare/lib/Jifty/Event/Model.pm
jifty/branches/template-declare/lib/Jifty/Handler.pm
jifty/branches/template-declare/lib/Jifty/I18N.pm
jifty/branches/template-declare/lib/Jifty/Manual/AccessControl.pod
jifty/branches/template-declare/lib/Jifty/Manual/Actions.pod
jifty/branches/template-declare/lib/Jifty/Manual/Cookbook.pod
jifty/branches/template-declare/lib/Jifty/Manual/Models.pod
jifty/branches/template-declare/lib/Jifty/Manual/RequestHandling.pod
jifty/branches/template-declare/lib/Jifty/Manual/UsingCSSandJS.pod
jifty/branches/template-declare/lib/Jifty/Param/Schema.pm
jifty/branches/template-declare/lib/Jifty/Plugin/REST/Dispatcher.pm
jifty/branches/template-declare/lib/Jifty/Record.pm
jifty/branches/template-declare/lib/Jifty/Request.pm
jifty/branches/template-declare/lib/Jifty/Result.pm
jifty/branches/template-declare/lib/Jifty/Script/Action.pm
jifty/branches/template-declare/lib/Jifty/Script/App.pm
jifty/branches/template-declare/lib/Jifty/Script/Plugin.pm
jifty/branches/template-declare/lib/Jifty/Script/Po.pm
jifty/branches/template-declare/lib/Jifty/Script/Schema.pm
jifty/branches/template-declare/lib/Jifty/Subs.pm
jifty/branches/template-declare/lib/Jifty/Web.pm
jifty/branches/template-declare/lib/Jifty/Web/Form.pm
jifty/branches/template-declare/lib/Jifty/Web/Form/Element.pm
jifty/branches/template-declare/lib/Jifty/Web/Form/Field.pm
jifty/branches/template-declare/lib/Jifty/Web/Form/Field/Combobox.pm
jifty/branches/template-declare/lib/Jifty/Web/Form/Link.pm
jifty/branches/template-declare/plugins/Login/MANIFEST
jifty/branches/template-declare/plugins/Login/META.yml
jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login.pm
jifty/branches/template-declare/share/web/static/css/base.css
jifty/branches/template-declare/share/web/static/css/forms.css
jifty/branches/template-declare/share/web/static/js/jifty.js
jifty/branches/template-declare/share/web/templates/__jifty/admin/fragments/list/update
jifty/branches/template-declare/share/web/templates/__jifty/admin/fragments/list/view
jifty/branches/template-declare/share/web/templates/__jifty/validator.xml
jifty/branches/template-declare/t/TestApp/lib/TestApp/Action/DoSomething.pm
jifty/branches/template-declare/t/TestApp/t/06-validation.t
Log:
pull for template-declare jifty branch.
Modified: jifty/branches/template-declare/MANIFEST
==============================================================================
--- jifty/branches/template-declare/MANIFEST (original)
+++ jifty/branches/template-declare/MANIFEST Wed Nov 22 09:32:58 2006
@@ -219,9 +219,6 @@
plugins/ProfileBehaviour/Makefile.PL
plugins/ProfileBehaviour/share/web/static/css/behaviour-profile.css
plugins/ProfileBehaviour/share/web/static/js/behaviour.js
-plugins/REST/lib/Jifty/Plugin/REST.pm
-plugins/REST/lib/Jifty/Plugin/REST/Dispatcher.pm
-plugins/REST/Makefile.PL
README
share/dtd/xhtml-lat1.ent
share/dtd/xhtml-special.ent
Modified: jifty/branches/template-declare/META.yml
==============================================================================
--- jifty/branches/template-declare/META.yml (original)
+++ jifty/branches/template-declare/META.yml Wed Nov 22 09:32:58 2006
@@ -69,7 +69,7 @@
Hook::LexWrap: 0
IPC::PubSub: 0.11
JSON::Syck: 0.14
- Jifty::DBI: 0.25
+ Jifty::DBI: 0.26
LWP::UserAgent: 0
Locale::Maketext::Extract: 0.20
Locale::Maketext::Lexicon: 0.60
Modified: jifty/branches/template-declare/Makefile.PL
==============================================================================
--- jifty/branches/template-declare/Makefile.PL (original)
+++ jifty/branches/template-declare/Makefile.PL Wed Nov 22 09:32:58 2006
@@ -41,7 +41,7 @@
requires('Hash::Merge');
requires('Hook::LexWrap');
requires('IPC::PubSub' => '0.11' );
-requires('Jifty::DBI' => '0.25' ); # Jifty::DBI::Collection Jifty::DBI::Handle Jifty::DBI::Record::Cachable Jifty::DBI::SchemaGenerator
+requires('Jifty::DBI' => '0.26' ); # Jifty::DBI::Collection Jifty::DBI::Handle Jifty::DBI::Record::Cachable Jifty::DBI::SchemaGenerator
requires('Locale::Maketext::Extract' => '0.20');
requires('Locale::Maketext::Lexicon' => '0.60');
requires('Log::Log4perl');
Modified: jifty/branches/template-declare/lib/Jifty.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty.pm (original)
+++ jifty/branches/template-declare/lib/Jifty.pm Wed Nov 22 09:32:58 2006
@@ -135,6 +135,12 @@
push @plugins, $class->new(%options);
}
+ Jifty->plugins(@plugins);
+
+ # Now that we have the config set up and loaded plugins,
+ # load the localization files.
+ Jifty::I18N->refresh();
+
# Get a classloader set up
my $class_loader = Jifty::ClassLoader->new(
base => Jifty->app_class,
@@ -143,10 +149,6 @@
Jifty->class_loader($class_loader);
$class_loader->require;
- Jifty->plugins(@plugins);
-
- Jifty::I18N->refresh(); # can't do this before we have the config set up and load plugins
-
Jifty->handler(Jifty::Handler->new());
Jifty->api(Jifty::API->new());
Modified: jifty/branches/template-declare/lib/Jifty/Action.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Action.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Action.pm Wed Nov 22 09:32:58 2006
@@ -36,7 +36,10 @@
See also L<Jifty::Action::Record> for data-oriented actions,
L<Jifty::Result> for how to return values from actions.
-See L<Jifty::Param::Schema> for more details.
+See L<Jifty::Param::Schema> for more details on the declarative
+syntax.
+
+See L<Jifty::Manual::Actions> for examples of using actions.
=cut
@@ -686,6 +689,20 @@
return 'warnings-' . $self->form_field_name($field_name);
}
+=head2 canonicalization_note_div_id ARGUMENT
+
+Turn one of this action's L<arguments|Jifty::Manual::Glossary/arguments> into
+the id for the div in which its canonicalization notes live; takes name of the field
+as an argument.
+
+=cut
+
+sub canonicalization_note_div_id {
+ my $self = shift;
+ my $field_name = shift;
+ return 'canonicalization_note-' . $self->form_field_name($field_name);
+}
+
=head1 VALIDATION METHODS
@@ -1057,6 +1074,29 @@
return 1;
}
+=head2 canonicalization_note ARGUMENT => NOTE
+
+Used to send an informational message to the user from the canonicalizer.
+Inside a canonicalizer you can write:
+
+ $self->canonicalization_note( $field => "I changed $field for you");
+
+..where C<$field> is the name of the argument which the canonicalizer is
+processing
+
+=cut
+
+sub canonicalization_note {
+ my $self = shift;
+ my $field = shift;
+ my $info = shift;
+
+ $self->result->field_canonicalization_note($field => $info);
+
+ return;
+
+}
+
=head2 autogenerated
Autogenerated Actions will always return true when this method is called.
Modified: jifty/branches/template-declare/lib/Jifty/Action/Record.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Action/Record.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Action/Record.pm Wed Nov 22 09:32:58 2006
@@ -1,7 +1,5 @@
use warnings;
use strict;
-use Date::Manip ();
-use UNIVERSAL::require;
package Jifty::Action::Record;
@@ -122,7 +120,7 @@
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>
+L<Jifty::Action::_autocomplete_argument|Jifty::Action/_autocomplete_argument>
C<canonicalized_FIELD> should return the canonicalized value.
Modified: jifty/branches/template-declare/lib/Jifty/DateTime.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/DateTime.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/DateTime.pm Wed Nov 22 09:32:58 2006
@@ -5,17 +5,18 @@
=head1 NAME
-Jifty::DateTime - a DateTime subclass that knows about Jifty users
+Jifty::DateTime - a DateTime subclass that knows about Jifty users
+
=head1 DESCRIPTION
Jifty natively stores timestamps in the database in GMT. Dates are stored
-without timezone. This class loads and parses dates and sets them
+without timezone. This class loads and parses dates and sets them
into the proper timezone.
=cut
-use base qw'Jifty::Object DateTime';
+use base qw(Jifty::Object DateTime);
use Date::Manip ();
@@ -69,6 +70,7 @@
my $class = shift;
my $string = shift;
my $now;
+
{
# Date::Manip interprets days of the week (eg, ''monday'') as
# days within the *current* week. Detect these and prepend
Modified: jifty/branches/template-declare/lib/Jifty/Event/Model.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Event/Model.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Event/Model.pm Wed Nov 22 09:32:58 2006
@@ -6,6 +6,31 @@
use base qw/Jifty::Event/;
+
+=head1 NAME
+
+Jifty::Event::Model
+
+=head1 DESCRIPTION
+
+Objects in this class represent changes to Jifty::Record classes (any action on a model class)
+as Jifty::Events.
+
+As yet, this functionality is unused.
+
+
+=cut
+
+=head2 new
+
+creates a new L<Jifty::Event::Model> object. If C<PubSub> is enabled for your application,
+checks to make sure that this event has the following (underdocumented) parameters:
+
+ record_id record_class action_class action_arguments timestamp result as_hash_before as_hash_after current_user_id
+
+=cut
+
+
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
Modified: jifty/branches/template-declare/lib/Jifty/Handler.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Handler.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Handler.pm Wed Nov 22 09:32:58 2006
@@ -66,8 +66,7 @@
# $_[-1] = Jifty->handler->cgi if Jifty->handler->cgi;
# };
- $self->dispatcher(
- Jifty->config->framework('ApplicationClass') . "::Dispatcher" );
+ $self->dispatcher( Jifty->app_class( "Dispatcher" ) );
Jifty::Util->require( $self->dispatcher );
$self->dispatcher->import_plugins;
$self->dispatcher->dump_rules;
Modified: jifty/branches/template-declare/lib/Jifty/I18N.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/I18N.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/I18N.pm Wed Nov 22 09:32:58 2006
@@ -42,8 +42,10 @@
);
foreach my $plugin (Jifty->plugins) {
+ my $dir = eval { module_dir(ref($plugin)); };
+ next unless $dir;
push @import, 'Gettext';
- push @import, module_dir(ref($plugin)).'/po/*.po';
+ push @import, $dir . '/po/*.po';
};
Locale::Maketext::Lexicon->import(
Modified: jifty/branches/template-declare/lib/Jifty/Manual/AccessControl.pod
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Manual/AccessControl.pod (original)
+++ jifty/branches/template-declare/lib/Jifty/Manual/AccessControl.pod Wed Nov 22 09:32:58 2006
@@ -97,20 +97,32 @@
behavior a confirmation mail is sent out that has to get followed by
the user.
-=item F</confirm_email>
+=item F</chgpasswd>
-is called in the mail and results in accepting
-the user.
+allows a user to change his password.
+
+=item F</passwordreminder>
+
+after entering his mail address, the user will receive a mail that
+contains a link to F</let/reset_lost_password>.
+
+=item F</let/confirm_email>
+
+is called in the mail and results in accepting the user.
+
+=item F</let/reset_lost_password>
+
+enabled by the passwordreminder template, this template allows a user
+to reenter a password for future use.
=back
=head2 Doing checks at other places in your code
If you need to check more than Model-based record operations you will
-have to do some coding on your
-own. C<Jifty-E<gt>web-E<gt>current_user> provides a
-C<App::CurrentUser> object that can get queried about the current
-user. This object provides some convenience methods:
+have to do some coding on your own. C<< Jifty->web->current_user >> provides a
+C<App::CurrentUser> object that can get queried about the current user.
+This object provides some convenience methods:
=over 4
Modified: jifty/branches/template-declare/lib/Jifty/Manual/Actions.pod
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Manual/Actions.pod (original)
+++ jifty/branches/template-declare/lib/Jifty/Manual/Actions.pod Wed Nov 22 09:32:58 2006
@@ -153,13 +153,58 @@
You can also do validation in the model -- see
L<Jifty::Action::Record>
-Note that if, instead of failing, you want to automatically modify
+=head3 canonicalization
+
+If, instead of failing, you want to automatically modify
invalid content to be valid, you want a
L<canonicalizer|Jifty::Manual::Glossary/canonicalize>, not a
validator.
-Additionally, if you set C<ajax_validates> or C<ajax_canonicalizes> to
-true for an argument, then Jifty will automatically validate or
+ use Regexp::Common 'profanity_us';
+
+ sub canonicalize_body {
+ my $self = shift;
+ my $body = shift;
+ $body =~ s/$RE{profanity}/**expletives**/gi;
+ return $body;
+ }
+
+A L<canonicalizer|Jifty::Manual::Glossary/canonicalize> can also
+change other parts of the action. This lets you update the display
+dynamically in an L<AJAX|Jifty::Manual::Glossary/ajax>-enabled browser
+based on what the user has entered. For example, we can let a user
+use magic syntax to provide tags for their blog post by surrounding the
+tags with square brackets. You can also let the user know you're
+doing something magical by using C<canonicalization_note> which
+will display a message to the user.
+
+ use Jifty::Param::Schema;
+ use Jifty::Action schema {
+ param title =>
+ label is 'Title',
+ hints is "You can provide tags like this [tag1 tag2]",
+ ajax canonicalizes;
+
+ param tags =>
+ label is 'Tags';
+ };
+
+ sub canonicalize_title {
+ my $self = shift;
+ my $value = shift;
+
+ if ($value =~ s/\[(.*?)\]//) {
+ # this clobbers, may want to merge
+ $self->argument_value( tags => $1 );
+ $self->canonicalization_note( title => 'Removed tags from your title' );
+ }
+
+ return $value;
+ }
+
+
+If you set C<ajax validates> or C<ajax canonicalizes>
+for an argument, then Jifty will automatically validate or
canonicalize it in an L<AJAX|Jifty::Manual::Glossary/ajax>-enabled
browser when the user stops typing.
Modified: jifty/branches/template-declare/lib/Jifty/Manual/Cookbook.pod
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Manual/Cookbook.pod (original)
+++ jifty/branches/template-declare/lib/Jifty/Manual/Cookbook.pod Wed Nov 22 09:32:58 2006
@@ -14,7 +14,7 @@
=head2 Add Atom/RSS Feeds ?
You could generate atom/rss feeds for virtually any model in your application.
-For instance, suppose there's a "Post" model (like a blog post), you could use
+For instance, suppose there's a "Post" model (like a blog entry), you could use
L<XML::Feed> to do this:
# In '/feed' template
@@ -219,7 +219,7 @@
generated. You do not have to modify any code in your view. Jifty does
it for you.
-The ajax canonicalization happenes when the input focus leaves that
+The ajax canonicalization happens when the input focus leaves that
field. You would see the effect a bit latter that the value in the
field is changed.
Modified: jifty/branches/template-declare/lib/Jifty/Manual/Models.pod
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Manual/Models.pod (original)
+++ jifty/branches/template-declare/lib/Jifty/Manual/Models.pod Wed Nov 22 09:32:58 2006
@@ -285,7 +285,7 @@
question.
The C<operator> (whose default is '=') can be any legal SQL operator
-like C<=>, C<E<lt>=>, C<E<gt>=>, C<E<lt>E<gt>>, C<LIKE>, C<IS>, C<IS
+like C<=>, C<< <= >>, C<< >= >>, C<< != >>, C<LIKE>, C<IS>, C<IS
NOT> as well as some convenience operators that silently use C<LIKE>
with properly set wildcards (C<MATCHES>, C<STARTSWITH> or
C<ENDSWITH>).
Modified: jifty/branches/template-declare/lib/Jifty/Manual/RequestHandling.pod
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Manual/RequestHandling.pod (original)
+++ jifty/branches/template-declare/lib/Jifty/Manual/RequestHandling.pod Wed Nov 22 09:32:58 2006
@@ -11,7 +11,7 @@
As soon as a http request (whatever the method might be like GET,
POST, PUT, ...) arrives at Jifty's border, the request is forwarded to
-a handler. By default, C<Jifty-E<gt>handler> points to a L<Jifty::Handler>
+a handler. By default, C<< Jifty->handler >> points to a L<Jifty::Handler>
object that is responsible for handling an incoming request. The
handler receives a L<CGI> object on which it operates.
@@ -28,7 +28,7 @@
=item build a stash
The stash is a storage area that can be reached by simply accessing
-C<Jifty-E<gt>handler-E<gt>stash-E<gt>{some_key}>. The stash will start fresh with
+C<< Jifty->handler->stash->{some_key} >>. The stash will start fresh with
every request and lives for the entire lifetime of a request. Using
the stash, transporting data between otherwise unconnected modules
will become possible.
@@ -37,13 +37,14 @@
Using the L<CGI> object, a L<Jifty::Request> object is constructed and
its data is populated with the CGI's data. The request can be reached
-later using C<Jifty-E<gt>web-E<gt>request>. The request holds information
+later using C<< Jifty->web->request >>. The request holds information
about all actions involved, all page fragments, contains state
variables and arguments (usually GET/POST parameters).
Also, an empty L<Jifty::Response> object is constructed that contains
one or more L<Jifty::Result> objects, each of which holds one
-L<Jifty::Action>'s result. The response object can be retrieved with C<Jifty-E<gt>web-E<gt>response>
+L<Jifty::Action>'s result. The response object can be retrieved with
+the C<< Jifty->web->response >> method.
=item setup plugins
@@ -60,19 +61,20 @@
Based on a cookie that is sent with every http response, the current
user is assigned a unique session. The session is stored in a
-L<Jifty::Web::Session> object and can be used with C<Jifty-E<gt>web-E<gt>session>.
+L<Jifty::Web::Session> object and can be accessed using with the
+C<< Jifty->web->session >> method.
=item return from a continuation if requested
If there is an open continuation on the stack (e.g. from a
-C<Jifty-E<gt>web-E<gt>tangent> link) and the return has been requested
-(e.g. by a C<Jifty-E<gt>web-E<gt>return> link), the return will execute at
+C<< Jifty->web->tangent >> link) and the return has been requested
+(e.g. by a C<< Jifty->web->return >> link), the return will execute at
this stage.
=item handle dynamic request unless already served
First, the user is given a cookie containing the session-id. Then, the
-request is forwarded to C<Jifty-E<gt>handler-E<gt>dispatcher>, a
+request is forwarded to C<< Jifty->handler->dispatcher >>, a
L<Jifty::Dispatcher> object to handle the request. The dispatcher
works through the following steps:
Modified: jifty/branches/template-declare/lib/Jifty/Manual/UsingCSSandJS.pod
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Manual/UsingCSSandJS.pod (original)
+++ jifty/branches/template-declare/lib/Jifty/Manual/UsingCSSandJS.pod Wed Nov 22 09:32:58 2006
@@ -158,13 +158,22 @@
=head2 Assembly of JS definitions
Jifty maintains a complete list of JS files to include. This list may
-be retrieved or set by the accessor
-C<Jifty-E<gt>web-E<gt>javascript_libs>. There should, however, rarely
-arise a situation to do that, because Jifty already reserved two files
-that may get added to your application. C<app.css> which is initially
-empty can get all JS functions you need to define and
-C<app_behaviour.js> is intentionally reserved for defining behaviors
-for DOM objects using the C<behaviour.js> library.
+be retrieved or set by the accessor C<< Jifty->web->javascript_libs >>.
+There should, However, rarely arise a situation to do that, because
+Jifty already reserved two files that may get added to your application:
+
+=over 4
+
+=item F<app.js>
+
+Initially empty; put all JS functions you need to define here.
+
+=item F<app_behaviour.js>
+
+Reserved for defining behaviors for DOM objects using the C<behaviour.js>
+library.
+
+=back
The assembly process of all JS definitions is done in L<Jifty::Web> by
the method C<include_javascript>.
Modified: jifty/branches/template-declare/lib/Jifty/Param/Schema.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Param/Schema.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Param/Schema.pm Wed Nov 22 09:32:58 2006
@@ -149,6 +149,20 @@
HASH => sub { Hash::Merge::_merge_hashes( $_[0], $_[1] ) } }
};
+=head2 merge_params HASHREF HASHREF
+
+Takes two hashrefs. Merges them together and returns the merged hashref.
+
+ - Empty fields in subclasses don't override nonempty fields in superclass anymore.
+ - Arrays don't merge; e.g. if parent class's valid_values is [1,2,3,4], and
+ subclass's valid_values() is [1,2], they don't somehow become [1,2,3,4,1,2].
+
+BUG: This should either be a private routine or factored out into Jifty::Util
+
+
+
+=cut
+
sub merge_params {
my $prev_behaviour = Hash::Merge::get_behavior();
Hash::Merge::specify_behavior( MERGE_PARAM_BEHAVIOUR, "merge_params" );
Modified: jifty/branches/template-declare/lib/Jifty/Plugin/REST/Dispatcher.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Plugin/REST/Dispatcher.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Plugin/REST/Dispatcher.pm Wed Nov 22 09:32:58 2006
@@ -5,6 +5,7 @@
use CGI qw( start_html end_html ol ul li a dl dt dd );
+use Carp;
use Jifty::Dispatcher -base;
use Jifty::YAML ();
use Jifty::JSON ();
@@ -34,11 +35,30 @@
on GET '/=/action' => \&list_actions;
on POST '/=/action/*' => \&run_action;
+
+=head2 list PREFIX items
+
+Takes a URL prefix and a set of items to render. passes them on.
+
+=cut
+
+
+
sub list {
my $prefix = shift;
outs($prefix, \@_)
}
+
+
+=head2 outs PREFIX DATASTRUCTURE
+
+TAkes a url path prefix and a datastructure. Depending on what content types the other side of the HTTP connection can accept,
+renders the content as yaml, json, javascript, perl, xml or html.
+
+=cut
+
+
sub outs {
my $prefix = shift;
my $accept = ($ENV{HTTP_ACCEPT} || '');
@@ -90,6 +110,12 @@
our $xml_config = { SuppressEmpty => '',
NoAttr => 1 };
+=head2 render_as_xml DATASTRUCTURE
+
+Attempts to render DATASTRUCTURE as simple, tag-based XML.
+
+=cut
+
sub render_as_xml {
my $content = shift;
@@ -104,6 +130,12 @@
}
+=head2 render_as_html PREFIX URL DATASTRUCTURE
+
+Attempts to render DATASTRUCTURE as simple semantic HTML suitable for humans to look at.
+
+=cut
+
sub render_as_html {
my $prefix = shift;
my $url = shift;
@@ -135,6 +167,12 @@
}
+=head2 html_dump DATASTRUCTURE
+
+Recursively render DATASTRUCTURE as some simple html dls and ols.
+
+=cut
+
sub html_dump {
my $content = shift;
@@ -159,6 +197,12 @@
}
}
+=head2 html_dump_record Jifty::Record
+
+Returns a nice simple HTML definition list of the keys and values of a Jifty::Record object.
+
+=cut
+
sub html_dump_record {
my $item = shift;
@@ -167,10 +211,24 @@
return dl( map {dt($_), dd($hash{$_}) } keys %hash )
}
-sub action { resolve($_[0], 'Jifty::Action', Jifty->api->actions) }
-sub model { resolve($_[0], 'Jifty::Record', Jifty->class_loader->models) }
+=head2 action ACTION
+
+Canonicalizes ACTION into the form preferred by the code. (Cleans up casing, canonicalizing, etc. Returns 404 if it can't work its magic
+
+=cut
-sub resolve {
+
+sub action { _resolve($_[0], 'Jifty::Action', Jifty->api->actions) }
+
+=head2 model MODEL
+
+Canonicalizes MODEL into the form preferred by the code. (Cleans up casing, canonicalizing, etc. Returns 404 if it can't work its magic
+
+=cut
+
+sub model { _resolve($_[0], 'Jifty::Record', Jifty->class_loader->models) }
+
+sub _resolve {
my $name = shift;
my $base = shift;
return $name if $name->isa($base);
@@ -184,6 +242,13 @@
abort(404);
}
+
+=head2 list_models
+
+Sends the user a list of models in this application, with the names transformed from Perlish::Syntax to Everything.Else.Syntax
+
+=cut
+
sub list_models {
list(['model'], map {s/::/./g; $_ } Jifty->class_loader->models);
}
@@ -208,6 +273,14 @@
valid_values
);
+
+=head2 list_model_columns
+
+Sends the user a nice list of all columns in a given model class. Exactly which model is shoved into $1 by the dispatcher. This should probably be improved.
+
+
+=cut
+
sub list_model_columns {
my ($model) = model($1);
@@ -222,6 +295,13 @@
);
}
+=head2 list_model_items MODELCLASS COLUMNNAME
+
+Returns a list of items in MODELCLASS sorted by COLUMNNAME, with only COLUMNAME displayed. (This should have some limiting thrown in)
+
+=cut
+
+
sub list_model_items {
# Normalize model name - fun!
@@ -235,6 +315,16 @@
map { $_->$column() } @{ $col->items_array_ref || [] } );
}
+
+=head2 show_item_field $model, $column, $key, $field
+
+Loads up a model of type C<$model> which has a column C<$column> with a value C<$key>. Returns the value of C<$field> for that object.
+Returns 404 if it doesn't exist.
+
+
+
+=cut
+
sub show_item_field {
my ( $model, $column, $key, $field ) = ( model($1), $2, $3, $4 );
my $rec = $model->new;
@@ -244,6 +334,14 @@
outs( [ 'model', $model, $column, $key, $field ], $rec->$field());
}
+=head2 show_item $model, $column, $key
+
+Loads up a model of type C<$model> which has a column C<$column> with a value C<$key>. Returns all columns for the object
+
+Returns 404 if it doesn't exist.
+
+=cut
+
sub show_item {
my ($model, $column, $key) = (model($1), $2, $3);
my $rec = $model->new;
@@ -252,18 +350,45 @@
outs( ['model', $model, $column, $key], { map {$_ => $rec->$_()} map {$_->name} $rec->columns});
}
+
+=head2 replace_item
+
+UNIMPLEMENTED
+
+=cut
+
sub replace_item {
die "hey replace item";
}
+=head2 delete_item
+
+UNIMPLEMENTED
+
+=cut
+
sub delete_item {
die "hey delete item";
}
+=head2 list_actions
+
+Returns a list of all actions allowed to the current user. (Canonicalizes Perl::Style to Everything.Else.Style).
+
+=cut
+
sub list_actions {
list(['action'], map {s/::/./g; $_} Jifty->api->actions);
}
+=head2 list_action_params
+
+Takes a single parameter, $action, supplied by the dispatcher.
+
+Shows the user all possible parameters to the action, currently in the form of a form to run that action.
+
+=cut
+
sub list_action_params {
my ($action) = action($1) or abort(404);
Jifty::Util->require($action) or abort(404);
Modified: jifty/branches/template-declare/lib/Jifty/Record.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Record.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Record.pm Wed Nov 22 09:32:58 2006
@@ -295,6 +295,9 @@
return undef unless $classname;
return unless $classname->isa( 'Jifty::DBI::Collection' );
+ if ( my $prefetched_collection = $self->_prefetched_collection($method_name)) {
+ return $prefetched_collection;
+ }
my $coll = $classname->new( current_user => $self->current_user );
if ($column->by and $self->id) {
Modified: jifty/branches/template-declare/lib/Jifty/Request.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Request.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Request.pm Wed Nov 22 09:32:58 2006
@@ -4,7 +4,7 @@
package Jifty::Request;
use base qw/Jifty::Object Class::Accessor::Fast/;
-__PACKAGE__->mk_accessors(qw(top_request arguments just_validating path continuation_id continuation_type continuation_path));
+__PACKAGE__->mk_accessors(qw(_top_request arguments just_validating path continuation_id continuation_type continuation_path));
use Jifty::JSON;
use Jifty::YAML;
@@ -837,7 +837,7 @@
sub is_subrequest {
my $self = shift;
- return $self->_top_request_accessor ? 1 : undef;
+ return $self->_top_request ? 1 : undef;
}
=head2 top_request
@@ -850,8 +850,8 @@
sub top_request {
my $self = shift;
- $self->_top_request_accessor(@_) if @_;
- return $self->_top_request_accessor || $self;
+ $self->_top_request(@_) if @_;
+ return $self->_top_request || $self;
}
package Jifty::Request::Action;
Modified: jifty/branches/template-declare/lib/Jifty/Result.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Result.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Result.pm Wed Nov 22 09:32:58 2006
@@ -19,7 +19,7 @@
use base qw/Jifty::Object Class::Accessor::Fast/;
-__PACKAGE__->mk_accessors(qw(failure action_class message content));
+__PACKAGE__->mk_accessors(qw(failure action_class message _content));
=head2 new
@@ -35,7 +35,7 @@
my $self = bless {}, $class;
$self->failure(0);
- $self->_content_accessor({});
+ $self->_content({});
return $self;
}
@@ -135,6 +135,32 @@
return %{$self->{field_warnings} || {}};
}
+=head2 field_canonicalization_note FIELD [NOTE]
+
+Gets or sets a canonicalization note for a specific field on the action.
+
+=cut
+
+sub field_canonicalization_note {
+ my $self = shift;
+ my $field = shift;
+
+ $self->{field_canonicalization_notes}{ $field } = shift if @_;
+ return $self->{field_canonicalization_notes}{ $field };
+}
+
+=head2 field_canonicalization_notes
+
+Returns a hash which maps L<argument|Jifty::Manual::Glossary/argument>
+name to canonicalization notes.
+
+=cut
+
+sub field_canonicalization_notes {
+ my $self = shift;
+ return %{$self->{field_canonicalization_notes} || {}};
+}
+
=head2 content [KEY [, VALUE]]
Gets or sets the content C<KEY>. This is used when actions need to
@@ -146,11 +172,11 @@
sub content {
my $self = shift;
- return $self->_content_accessor unless @_;
+ return $self->_content unless @_;
my $key = shift;
- $self->_content_accessor->{$key} = shift if @_;
- return $self->_content_accessor->{$key};
+ $self->_content->{$key} = shift if @_;
+ return $self->_content->{$key};
}
1;
Modified: jifty/branches/template-declare/lib/Jifty/Script/Action.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Script/Action.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Script/Action.pm Wed Nov 22 09:32:58 2006
@@ -77,13 +77,10 @@
package @{[$appclass]}::Action::@{[$action]};
use base qw/@{[$appclass]}::Action Jifty::Action/;
-=head2 arguments
+use Jifty::Param::Schema;
+use Jifty::Action schema {
-=cut
-
-sub arguments {
- # This should return an arrayref of arguments
-}
+};
=head2 take_action
Modified: jifty/branches/template-declare/lib/Jifty/Script/App.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Script/App.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Script/App.pm Wed Nov 22 09:32:58 2006
@@ -2,7 +2,7 @@
use strict;
package Jifty::Script::App;
-use base qw'App::CLI::Command Class::Accessor::Fast';
+use base qw(App::CLI::Command Class::Accessor::Fast);
use File::Copy;
use Jifty::Config;
Modified: jifty/branches/template-declare/lib/Jifty/Script/Plugin.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Script/Plugin.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Script/Plugin.pm Wed Nov 22 09:32:58 2006
@@ -2,7 +2,7 @@
use strict;
package Jifty::Script::Plugin;
-use base qw'App::CLI::Command Class::Accessor::Fast';
+use base qw(App::CLI::Command Class::Accessor::Fast);
use File::Copy;
use Jifty::Config;
Modified: jifty/branches/template-declare/lib/Jifty/Script/Po.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Script/Po.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Script/Po.pm Wed Nov 22 09:32:58 2006
@@ -2,7 +2,7 @@
use strict;
package Jifty::Script::Po;
-use base qw'App::CLI::Command Class::Accessor::Fast';
+use base qw(App::CLI::Command Class::Accessor::Fast);
use File::Copy;
use Jifty::Config;
Modified: jifty/branches/template-declare/lib/Jifty/Script/Schema.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Script/Schema.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Script/Schema.pm Wed Nov 22 09:32:58 2006
@@ -129,20 +129,18 @@
my $self = shift;
# Set up application-specific parts
- $self->{'_application_class'}
- = Jifty->config->framework('ApplicationClass');
$self->{'_schema_generator'}
= Jifty::DBI::SchemaGenerator->new( Jifty->handle )
or die "Can't make Jifty::DBI::SchemaGenerator";
# This creates a sub "models" which when called, finds packages under
-# $self->{'_application_class'}::Model, requires them, and returns a list of their
+# the application's ::Model, requires them, and returns a list of their
# names.
Jifty::Module::Pluggable->import(
require => 1,
except => qr/\.#/,
search_path =>
- [ "Jifty::Model", $self->{'_application_class'} . "::Model" ],
+ [ "Jifty::Model", Jifty->app_class("Model") ],
sub_name => 'models',
);
}
@@ -208,7 +206,7 @@
my $log = Log::Log4perl->get_logger("SchemaTool");
$log->info(
- "Generating SQL for application $self->{'_application_class'}...");
+ "Generating SQL for application @{[Jifty->app_class]}...");
my $appv
= version->new( Jifty->config->framework('Database')->{'Version'} );
@@ -261,7 +259,7 @@
# Load initial data
eval {
- my $bootstrapper = $self->{'_application_class'} . "::Bootstrap";
+ my $bootstrapper = Jifty->app_class("Bootstrap");
Jifty::Util->require($bootstrapper);
$bootstrapper->run()
@@ -327,7 +325,7 @@
my $appv
= version->new( Jifty->config->framework('Database')->{'Version'} );
- return unless $self->upgrade_tables( $self->{_application_class} => $dbv, $appv );
+ return unless $self->upgrade_tables( Jifty->app_class, $dbv, $appv );
if( $self->{print} ) {
warn "Need to upgrade application_db_version to $appv here!";
} else {
Modified: jifty/branches/template-declare/lib/Jifty/Subs.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Subs.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Subs.pm Wed Nov 22 09:32:58 2006
@@ -29,20 +29,48 @@
=cut
+=head2 add PARAMHASH
+
+Add a subscription for the current window or session.
+
+Takes the following parameters
+
+=over
+
+=item class
+
+What class of object shall we subscribe to notifications on
+
+=item queries
+
+An array of queries to match items of class C<class> against. The implementation of C<queries> is dependent on the type of object events are being recorded against
+
+=item mode
+
+How should the fragment sent to the client on matching events be rendered. Valid modes are C<Replace>, C<Bottom> and C<Top>
+
+=item region
+
+The moniker of the region that updates to this subscription should be rendered into
+
+=item render_with
+
+The path of the fragment used to render items matching this subscription
+
+=back
+
+=cut
+
sub add {
my $class = shift;
my $args = {@_};
- unless (Jifty->config->framework('PubSub')->{'Enable'}) {
+ unless (Jifty->config->framework('PubSub')->{'Enable'}) {
Jifty->log->error("PubSub disabled, but $class->add called");
- return undef
+ return undef;
}
my $id = ($args->{window_id} || Jifty->web->session->id);
- my $event_class = join('::' =>
- Jifty->config->framework("ApplicationClass"),
- 'Event',
- $args->{class},
- );
+ my $event_class = Jifty->app_class("Event", $args->{class});
my $queries = $args->{queries} || [];
my $channel = $event_class->encode_queries(@$queries);
@@ -83,12 +111,18 @@
return "$channel!$id";
}
+=head2 cancel CHANNEL_ID
+
+Cancels session or window's subscription to CHANNEL_ID
+
+=cut
+
sub cancel {
my ($class, $channel_id) = @_;
- unless (Jifty->config->framework('PubSub')->{'Enable'}) {
+ unless (Jifty->config->framework('PubSub')->{'Enable'}) {
Jifty->log->error("PubSub disabled, but $class->add called");
- return undef
+ return undef;
}
my ($channel, $id) = split(/!/, $channel_id, 2);
@@ -104,7 +138,7 @@
Jifty->bus->modify(
"$id-render" => sub {
- delete $_->{$channel}
+ delete $_->{$channel};
}
);
@@ -115,12 +149,19 @@
);
}
+=head2 list [window/sessionid]
+
+Returns a lost of channel ids this session or window is subscribed to.
+
+=cut
+
+
sub list {
my $self = shift;
- unless (Jifty->config->framework('PubSub')->{'Enable'}) {
+ unless (Jifty->config->framework('PubSub')->{'Enable'}) {
Jifty->log->error("PubSub disabled, but $self->add called");
- return undef
+ return undef;
}
my $id = (shift || Jifty->web->session->id);
Modified: jifty/branches/template-declare/lib/Jifty/Web.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Web.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Web.pm Wed Nov 22 09:32:58 2006
@@ -123,15 +123,36 @@
if ($args{'scheme'}) {
$self->log->error("Jifty->web->url no longer accepts a 'scheme' argument");
}
-
+
my $uri;
- if ($ENV{'HTTP_HOST'}) {
- my $host = $ENV{HTTP_HOST};
- if ($host !~ m{^http://}) {
- $host = 'http://' . $host;
- }
- $uri = URI->new($host);
- } else {
+
+ # Try to get a host out of the environment, useful in remote testing.
+ # The code is a little hairy because there's no guarantee these
+ # environment variables have all the information.
+ if (my $http_host_env = $ENV{HTTP_HOST}) {
+ # Explicit flag needed because URI->new("noscheme") is structurally
+ # different from URI->new("http://smth"). Clunky, but works.
+ my $dirty;
+ if ($http_host_env !~ m{^https?://}) {
+ $dirty++;
+ $http_host_env = "http://" . $http_host_env;
+ }
+ $uri = URI->new($http_host_env);
+ if ($dirty && (my $req_uri_env = $ENV{REQUEST_URI})) {
+ my $req_uri = URI->new($req_uri_env);
+ $uri->scheme($req_uri->scheme) if $req_uri->can('scheme');
+ $dirty = $uri->scheme;
+ }
+ # As a last resort, peek at the BaseURL configuration setting
+ # for the scheme, which is an often-missing part.
+ if ($dirty) {
+ my $config_uri = URI->new(
+ Jifty->config->framework("Web")->{BaseURL});
+ $uri->scheme($config_uri->scheme);
+ }
+ }
+
+ if (!$uri) {
my $url = Jifty->config->framework("Web")->{BaseURL};
my $port = Jifty->config->framework("Web")->{Port};
@@ -143,7 +164,7 @@
my $path = $args{path};
# strip off leading '/' because ->canonical provides one
$path =~ s{^/}{};
- $uri->path($path);
+ $uri->path_query($path);
}
return $uri->canonical->as_string;
Modified: jifty/branches/template-declare/lib/Jifty/Web/Form.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Web/Form.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Web/Form.pm Wed Nov 22 09:32:58 2006
@@ -184,10 +184,10 @@
}
}
- my $form_start = qq!<form method="post" action="$ENV{PATH_INFO}"!;
- $form_start .= qq! name="@{[ $self->name ]}"! if defined $self->name;
- $form_start .= qq! autocomplete="off"! if defined $self->disable_autocomplete;
- $form_start .= qq! enctype="multipart/form-data" >\n!;
+ my $form_start = qq!<form method="post" action="! . Jifty->web->escape( $ENV{PATH_INFO} ) . qq!"!;
+ $form_start .= qq! name="@{[ $self->name ]}"! if defined $self->name;
+ $form_start .= qq! autocomplete="off"! if defined $self->disable_autocomplete;
+ $form_start .= qq! enctype="multipart/form-data" >\n!;
Jifty->web->out($form_start);
# Write out state variables early, so that if a form gets
Modified: jifty/branches/template-declare/lib/Jifty/Web/Form/Element.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Web/Form/Element.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Web/Form/Element.pm Wed Nov 22 09:32:58 2006
@@ -145,7 +145,7 @@
=cut
sub accessors { shift->handlers, qw(class key_binding id label tooltip) }
-__PACKAGE__->mk_accessors(qw(onclick class key_binding id label tooltip));
+__PACKAGE__->mk_accessors(qw(_onclick class key_binding id label tooltip));
=head2 new PARAMHASH OVERRIDE
@@ -179,7 +179,7 @@
sub onclick {
my $self = shift;
- return $self->_onclick_accessor unless @_;
+ return $self->_onclick unless @_;
my ($arg) = @_;
@@ -213,7 +213,7 @@
}
- $self->_onclick_accessor($arg);
+ $self->_onclick($arg);
}
=head2 javascript
Modified: jifty/branches/template-declare/lib/Jifty/Web/Form/Field.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Web/Form/Field.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Web/Form/Field.pm Wed Nov 22 09:32:58 2006
@@ -104,30 +104,8 @@
=cut
-use constant ACCESSORS => qw(
- name
- label
- input_name
- type
- sticky
- sticky_value
- default_value
- action
- mandatory
- ajax_validates
- ajax_canonicalizes
- autocompleter
- preamble
- hints
- placeholder
- focus
- render_mode
- length
- element_id
-);
-
-sub accessors { shift->SUPER::accessors(), ACCESSORS }
-__PACKAGE__->mk_accessors(ACCESSORS);
+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 placeholder focus 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 placeholder focus render_mode length _element_id));
=head2 name [VALUE]
@@ -213,7 +191,7 @@
# Otherwise, we should ask our action, how to turn our "name"
# into a form input name.
- my $ret = $self->_input_name_accessor(@_);
+ my $ret = $self->_input_name(@_);
return $ret if $ret;
my $action = $self->action;
@@ -257,7 +235,7 @@
sub label {
my $self = shift;
- my $val = $self->_label_accessor(@_);
+ my $val = $self->_label(@_);
defined $val ? $val : $self->name;
}
@@ -273,7 +251,7 @@
sub element_id {
my $self = shift;
- return $self->_element_id_accessor || $self->_element_id_accessor( $self->input_name ."-".Jifty->web->serial);
+ return $self->_element_id || $self->_element_id( $self->input_name ."-".Jifty->web->serial);
}
=head2 action [VALUE]
@@ -287,11 +265,11 @@
sub action {
my $self = shift;
- my $action = $self->_action_accessor(@_);
+ my $action = $self->_action(@_);
# If we're setting the action, we need to weaken
# the reference to not get caught in a loop
- Scalar::Util::weaken( $self->{action} ) if @_;
+ Scalar::Util::weaken( $self->{_action} ) if @_;
return $action;
}
@@ -342,6 +320,7 @@
$self->render_hints();
$self->render_errors();
$self->render_warnings();
+ $self->render_canonicalization_notes();
} elsif ($self->render_mode eq 'read'){
$self->render_value();
}
@@ -682,4 +661,22 @@
return '';
}
+=head2 render_canonicalization_notes
+
+Outputs a <div> with any canonicalization notes for this action, even if there are
+none -- AJAX could fill it in.
+
+=cut
+
+sub render_canonicalization_notes {
+ my $self = shift;
+
+ return unless $self->action;
+
+ Jifty->web->out(
+qq!<span class="canonicalization_note @{[$self->classes]}" id="@{[$self->action->canonicalization_note_div_id($self->name)]}">@{[$self->action->result->field_canonicalization_note( $self->name ) || '']}</span>\n!
+ );
+ return '';
+}
+
1;
Modified: jifty/branches/template-declare/lib/Jifty/Web/Form/Field/Combobox.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Web/Form/Field/Combobox.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Web/Form/Field/Combobox.pm Wed Nov 22 09:32:58 2006
@@ -27,7 +27,7 @@
@{[ $self->_widget_class('combo-button')]}
></span></span><span style="display: none"></span><select
name="@{[ $self->input_name ]}"
- id="@{[ $self->_element_id_accessor ]}_List"
+ id="@{[ $self->_element_id ]}_List"
@{[ $self->_widget_class('combo-list')]}
onchange="ComboBox_SimpleAttach(this, this.form['@{[ $self->element_id ]}']); "
>
Modified: jifty/branches/template-declare/lib/Jifty/Web/Form/Link.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Web/Form/Link.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Web/Form/Link.pm Wed Nov 22 09:32:58 2006
@@ -109,7 +109,7 @@
Jifty->web->out(qq( title="@{[$self->tooltip]}")) if $tooltip;
Jifty->web->out(qq( target="@{[$self->target]}")) if $self->target;
Jifty->web->out(qq( accesskey="@{[$self->key_binding]}")) if $self->key_binding;
- Jifty->web->out(qq( href="@{[$self->url]}"));
+ Jifty->web->out(qq( href="@{[Jifty->web->escape($self->url)]}"));
Jifty->web->out( $self->javascript() );
Jifty->web->out(qq(>$label</a>));
$self->render_key_binding();
Added: jifty/branches/template-declare/plugins/AuthLDAPLogin/MANIFEST
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/AuthLDAPLogin/MANIFEST Wed Nov 22 09:32:58 2006
@@ -0,0 +1,15 @@
+debian/changelog
+debian/compat
+debian/control
+debian/copyright
+debian/rules
+lib/Jifty/Plugin/AuthLDAPLogin.pm
+lib/Jifty/Plugin/AuthLDAPLogin/Action/LDAPLogin.pm
+lib/Jifty/Plugin/AuthLDAPLogin/Action/LDAPLogout.pm
+lib/Jifty/Plugin/AuthLDAPLogin/Dispatcher.pm
+Makefile.PL
+MANIFEST
+share/po/en.po
+share/po/fr.po
+share/web/templates/ldaplogin
+share/web/templates/ldaplogout
Added: jifty/branches/template-declare/plugins/AuthLDAPLogin/Makefile.PL
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/AuthLDAPLogin/Makefile.PL Wed Nov 22 09:32:58 2006
@@ -0,0 +1,11 @@
+use inc::Module::Install;
+name('Jifty-Plugin-AuthLDAPLogin');
+license('Perl');
+version('0.01');
+requires('Jifty' => '0.60912');
+requires('Jifty::Plugin::Login');
+requires('Net::LDAP');
+
+install_share;
+
+WriteAll;
Added: jifty/branches/template-declare/plugins/AuthLDAPLogin/debian/changelog
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/AuthLDAPLogin/debian/changelog Wed Nov 22 09:32:58 2006
@@ -0,0 +1,6 @@
+libjifty-plugin-authldaplogin-perl (0-1) unstable; urgency=low
+
+ * Initial Release.
+
+ -- AGOSTINI Yves <agostini at univ-metz.fr> Fri, 17 Nov 2006 09:52:24 +0100
+
Added: jifty/branches/template-declare/plugins/AuthLDAPLogin/debian/compat
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/AuthLDAPLogin/debian/compat Wed Nov 22 09:32:58 2006
@@ -0,0 +1 @@
+4
Added: jifty/branches/template-declare/plugins/AuthLDAPLogin/debian/control
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/AuthLDAPLogin/debian/control Wed Nov 22 09:32:58 2006
@@ -0,0 +1,19 @@
+Source: libjifty-plugin-authldaplogin-perl
+Section: perl
+Priority: optional
+Build-Depends: debhelper (>= 4.0.2)
+Build-Depends-Indep: perl (>= 5.8.0-7)
+Maintainer: AGOSTINI Yves <agostini at univ-metz.fr>
+Standards-Version: 3.6.1
+
+Package: libjifty-plugin-authldaplogin-perl
+Architecture: all
+Depends: ${perl:Depends}, ${misc:Depends}, libjifty-plugin-login-perl,
+ libnet-ldap
+Description: Jifty::Plugin::AuthLDAPLogin
+ MUST BE USED WITH Login PLUGIN.
+ .
+ Add ldap users in Jifty::Plugin::Login::Model::User.
+ Distinct id for ldap users is email field with login at LDAP.user
+ .
+ This description was automagically extracted from the module by dh-make-perl.
Added: jifty/branches/template-declare/plugins/AuthLDAPLogin/debian/copyright
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/AuthLDAPLogin/debian/copyright Wed Nov 22 09:32:58 2006
@@ -0,0 +1,7 @@
+This is the debian package for the module.
+It was created by AGOSTINI Yves <agostini at univ-metz.fr> using dh-make-perl.
+
+This copyright info was automatically extracted from the perl module.
+It may not be accurate, so you better check the module sources
+if don't want to get into legal troubles.
+
Added: jifty/branches/template-declare/plugins/AuthLDAPLogin/debian/rules
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/AuthLDAPLogin/debian/rules Wed Nov 22 09:32:58 2006
@@ -0,0 +1,83 @@
+#!/usr/bin/make -f
+# This debian/rules file is provided as a template for normal perl
+# packages. It was created by Marc Brockschmidt <marc at dch-faq.de> for
+# the Debian Perl Group (http://pkg-perl.alioth.debian.org/) but may
+# be used freely wherever it is useful.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+# If set to a true value then MakeMaker's prompt function will
+# always return the default without waiting for user input.
+export PERL_MM_USE_DEFAULT=1
+
+PACKAGE=$(shell dh_listpackages)
+
+ifndef PERL
+PERL = /usr/bin/perl
+endif
+
+TMP =$(CURDIR)/debian/$(PACKAGE)
+
+build: build-stamp
+build-stamp:
+ dh_testdir
+
+ # Add commands to compile the package here
+ $(PERL) Makefile.PL INSTALLDIRS=vendor
+ $(MAKE) OPTIMIZE="-Wall -O2 -g"
+
+ touch build-stamp
+
+clean:
+ dh_testdir
+ dh_testroot
+
+ # Add commands to clean up after the build process here
+ -$(MAKE) distclean
+
+ dh_clean build-stamp install-stamp
+
+install: build install-stamp
+install-stamp:
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+
+ # Add commands to install the package into debian/$PACKAGE_NAME here
+ #$(MAKE) test
+ $(MAKE) install DESTDIR=$(TMP) PREFIX=/usr
+
+ # As this is a architecture independent package, we are not
+ # supposed to install stuff to /usr/lib. MakeMaker creates
+ # the dirs, we delete them from the deb:
+ rmdir --ignore-fail-on-non-empty --parents $(TMP)/usr/lib/perl5
+
+ touch install-stamp
+
+binary-arch:
+# We have nothing to do by default.
+
+binary-indep: build install
+ dh_testdir
+ dh_testroot
+# dh_installcron
+# dh_installmenu
+# dh_installexamples
+ dh_installdocs
+ dh_installchangelogs
+ dh_perl
+ dh_link
+ dh_strip
+ dh_compress
+ dh_fixperms
+ dh_installdeb
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+source diff:
+ @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary
Added: jifty/branches/template-declare/plugins/AuthLDAPLogin/lib/Jifty/Plugin/AuthLDAPLogin.pm
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/AuthLDAPLogin/lib/Jifty/Plugin/AuthLDAPLogin.pm Wed Nov 22 09:32:58 2006
@@ -0,0 +1,69 @@
+use strict;
+use warnings;
+
+=head1 NAME
+
+Jifty::Plugin::AuthLDAPLogin
+
+=head1 DESCRIPTION
+
+B<MUST BE USED WITH Login PLUGIN.>
+
+Add ldap users in L<Jifty::Plugin::Login::Model::User>.
+Distinct id for ldap users is C<email> field with C<login at LDAP.user>
+
+add /ldaplogin
+ /ldpalogout
+
+=head1 CONFIG
+
+in etc/config.yml
+
+ Plugins:
+ - Login: {}
+ - AuthLDAPLogin:
+ LDAPhost: ldap.univ.fr # ldap server
+ LDAPbase: ou=people,dc=..... # base ldap
+ LDAPuid: uid # optional
+
+=head1 SEE ALSO
+
+L<Net::LDAP>
+
+=cut
+
+package Jifty::Plugin::AuthLDAPLogin;
+use base qw/Jifty::Plugin/;
+use Net::LDAP;
+
+# Your plugin goes here. If takes any configuration or arguments, you
+# probably want to override L<Jifty::Plugin/init>.
+
+{
+ my ($LDAP, %params);
+
+ sub init {
+ my $self = shift;
+ my %args = @_;
+
+ $params{'Hostname'} = $args{LDAPhost};
+ $params{'base'} = $args{LDAPbase};
+ $params{'uid'} = $args{LDAPuid} || "uid";
+ $LDAP = Net::LDAP->new($params{Hostname},async=>1,onerror => 'undef', debug => 0);
+ }
+
+ sub LDAP {
+ return $LDAP;
+ }
+
+ sub base {
+ return $params{'base'};
+ }
+
+ sub uid {
+ return $params{'uid'};
+ }
+
+}
+
+1;
Added: jifty/branches/template-declare/plugins/AuthLDAPLogin/lib/Jifty/Plugin/AuthLDAPLogin/Action/LDAPLogin.pm
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/AuthLDAPLogin/lib/Jifty/Plugin/AuthLDAPLogin/Action/LDAPLogin.pm Wed Nov 22 09:32:58 2006
@@ -0,0 +1,106 @@
+use warnings;
+use strict;
+
+=head1 NAME
+
+Jifty::Plugin::AuthLDAPLogin::Action::LDAPLogin
+
+=cut
+
+package Jifty::Plugin::AuthLDAPLogin::Action::LDAPLogin;
+use base qw/Jifty::Action Jifty::Plugin::Login Jifty::Plugin::AuthLDAPLogin/;
+
+
+=head2 arguments
+
+Return the login form field
+
+=cut
+
+sub arguments {
+ return (
+ {
+ name => {
+ label => _('Login'),
+ mandatory => 1,
+ ajax_validates => 1,
+ },
+
+ password => {
+ type => 'password',
+ label => _('Password'),
+ mandatory => 1
+ },
+
+ }
+ );
+
+}
+
+=head2 validate_name NAME
+
+For ajax_validates.
+Makes sure that the name submitted is a legal login.
+
+
+=cut
+
+sub validate_name {
+ my $self = shift;
+ my $name = shift;
+
+ unless ( $name =~ /^[A-Za-z0-9-]+$/ ) {
+ return $self->validation_error(
+ name => _("That doesn't look like a valid login.") );
+ }
+
+
+ return $self->validation_ok('name');
+}
+
+
+=head2 take_action
+
+Bind on ldap to check the user's password. If it's right, log them in.
+Otherwise, throw an error.
+
+
+=cut
+
+sub take_action {
+ my $self = shift;
+ my $username = $self->argument_value('name');
+ my $dn = $self->uid().'='.$username.','.
+ $self->base();
+
+ # Bind on ldap
+ my $msg = $self->LDAP()->bind($dn ,'password' =>$self->argument_value('password'));
+
+ unless (not $msg->code) {
+ $self->result->error(
+ _('You may have mistyped your login or password. Give it another shot?')
+ );
+ return;
+ }
+
+ my $LDAPUser = $self->LoginUserClass();
+ my $CurrentUser = $self->CurrentUserClass();
+ my $u = $LDAPUser->new( current_user => $CurrentUser->superuser );
+
+ # Distinct id is login at LDAP.user
+ # Add user to User Login model
+ $u->load_by_cols( email => $username.'@LDAP.user');
+ my $id = $u->id;
+ if (!$id) {
+ ($id) = $u->create(name => $username, email => $username.'@LDAP.user');
+ }
+
+ Jifty->log->debug("Login user id: $id");
+
+ # Actually do the signin thing.
+ Jifty->web->current_user( $CurrentUser->new( id => $u->id ) );
+
+ return 1;
+}
+
+1;
Added: jifty/branches/template-declare/plugins/AuthLDAPLogin/lib/Jifty/Plugin/AuthLDAPLogin/Action/LDAPLogout.pm
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/AuthLDAPLogin/lib/Jifty/Plugin/AuthLDAPLogin/Action/LDAPLogout.pm Wed Nov 22 09:32:58 2006
@@ -0,0 +1,35 @@
+use warnings;
+use strict;
+
+=head1 NAME
+
+Jifty::Plugin::AuthLDAPLogin::Action::LDAPLogout
+
+=cut
+
+package Jifty::Plugin::AuthLDAPLogin::Action::LDAPLogout;
+use base qw/Jifty::Action/;
+
+=head2 arguments
+
+Return the email and password form fields
+
+=cut
+
+sub arguments {
+ return ( {} );
+}
+
+=head2 take_action
+
+Nuke the current user object
+
+=cut
+
+sub take_action {
+ my $self = shift;
+ Jifty->web->current_user(undef);
+ return 1;
+}
+
+1;
Added: jifty/branches/template-declare/plugins/AuthLDAPLogin/lib/Jifty/Plugin/AuthLDAPLogin/Dispatcher.pm
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/AuthLDAPLogin/lib/Jifty/Plugin/AuthLDAPLogin/Dispatcher.pm Wed Nov 22 09:32:58 2006
@@ -0,0 +1,31 @@
+use strict;
+use warnings;
+
+package Jifty::Plugin::AuthLDAPLogin::Dispatcher;
+use Jifty::Dispatcher -base;
+
+# Put any plugin-specific dispatcher rules here.
+
+# Log out
+before 'ldaplogout' => run {
+ Jifty->web->request->add_action(
+ class => 'LDAPLogout',
+ moniker => 'ldaplogout',
+ );
+};
+
+
+# Login
+on 'ldaplogin' => run {
+ set 'action' =>
+ Jifty->web->new_action(
+ class => 'LDAPLogin',
+ moniker => 'ldaploginbox'
+ );
+ set 'next' => Jifty->web->request->continuation
+ || Jifty::Continuation->new(
+ request => Jifty::Request->new( path => "/" ) );
+};
+
+
+1;
Added: jifty/branches/template-declare/plugins/AuthLDAPLogin/share/po/en.po
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/AuthLDAPLogin/share/po/en.po Wed Nov 22 09:32:58 2006
@@ -0,0 +1,25 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL at ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
+"Language-Team: LANGUAGE <LL at li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: lib/Jifty/Plugin/AuthLDAPLogin/Action/LDAPLogin.pm:54
+msgid "That doesn't look like a valid login."
+msgstr ""
+
+#: lib/Jifty/Plugin/AuthLDAPLogin/Action/LDAPLogin.pm:81
+msgid "You may have mistyped your login or password. Give it another shot?"
+msgstr ""
+
Added: jifty/branches/template-declare/plugins/AuthLDAPLogin/share/po/fr.po
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/AuthLDAPLogin/share/po/fr.po Wed Nov 22 09:32:58 2006
@@ -0,0 +1,25 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL at ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"POT-Creation-Date: 2006-11-17 10:23+ZONE\n"
+"PO-Revision-Date: 2006-11-17 10:23+ZONE\n"
+"Last-Translator: Yves Agostini <agostini at univ-metz.fr>\n"
+"Language-Team: LANGUAGE <LL at li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=ISO8859-15\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: lib/Jifty/Plugin/AuthLDAPLogin/Action/LDAPLogin.pm:54
+msgid "That doesn't look like a valid login."
+msgstr "Cet identifiant ne semble pas valide."
+
+#: lib/Jifty/Plugin/AuthLDAPLogin/Action/LDAPLogin.pm:81
+msgid "You may have mistyped your login or password. Give it another shot?"
+msgstr "Erreur dans votre identifiant ou votre mot de passe. Ré-essayez."
+
Added: jifty/branches/template-declare/plugins/AuthLDAPLogin/share/web/templates/ldaplogin
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/AuthLDAPLogin/share/web/templates/ldaplogin Wed Nov 22 09:32:58 2006
@@ -0,0 +1,19 @@
+<%args>
+$action => undef
+$next => undef
+</%args>
+<&|/_elements/wrapper, title => 'Login' &>
+
+% if (not Jifty->web->current_user->id) {
+<h2><% _('Login') %></h2>
+<% Jifty->web->form->start(call => $next, name => "ldaploginbox") %>
+<% $action->form_field('name') %>
+<% $action->form_field('password') %>
+%#<% $action->form_field('remember') %>
+<% Jifty->web->form->submit(label => _('Login'), submit => $action) %>
+<% Jifty->web->form->end %>
+% }
+% else {
+<% _("You're already logged in.") %>
+% }
+</&>
Added: jifty/branches/template-declare/plugins/AuthLDAPLogin/share/web/templates/ldaplogout
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/AuthLDAPLogin/share/web/templates/ldaplogout Wed Nov 22 09:32:58 2006
@@ -0,0 +1,3 @@
+<&| /_elements/wrapper, title => "Logged out" &>
+<p><% _("Ok, you're now logged out. Have a good day.") %></p>
+</&>
Added: jifty/branches/template-declare/plugins/AuthLDAPOnly/MANIFEST
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/AuthLDAPOnly/MANIFEST Wed Nov 22 09:32:58 2006
@@ -0,0 +1,12 @@
+lib/Jifty/Plugin/AuthLDAPOnly.pm
+lib/Jifty/Plugin/AuthLDAPOnly/Action/LDAPLogin.pm
+lib/Jifty/Plugin/AuthLDAPOnly/Action/LDAPLogout.pm
+lib/Jifty/Plugin/AuthLDAPOnly/CurrentUser.pm
+lib/Jifty/Plugin/AuthLDAPOnly/Dispatcher.pm
+lib/Jifty/Plugin/AuthLDAPOnly/Model/LDAPUser.pm
+Makefile.PL
+MANIFEST
+share/po/en.po
+share/po/fr.po
+share/web/templates/ldaplogin
+share/web/templates/ldaplogout
Added: jifty/branches/template-declare/plugins/AuthLDAPOnly/Makefile.PL
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/AuthLDAPOnly/Makefile.PL Wed Nov 22 09:32:58 2006
@@ -0,0 +1,11 @@
+use inc::Module::Install;
+name('Jifty-Plugin-AuthLDAPOnly');
+license('Perl');
+version('0.01');
+requires('Jifty' => '0.60912');
+requires('Scalar::Defer');
+requires('Net::LDAP');
+
+install_share;
+
+WriteAll;
Added: jifty/branches/template-declare/plugins/AuthLDAPOnly/debian/changelog
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/AuthLDAPOnly/debian/changelog Wed Nov 22 09:32:58 2006
@@ -0,0 +1,6 @@
+libjifty-plugin-authldaponly-perl (0-1) unstable; urgency=low
+
+ * Initial Release.
+
+ -- AGOSTINI Yves <agostini at univ-metz.fr> Fri, 17 Nov 2006 11:10:53 +0100
+
Added: jifty/branches/template-declare/plugins/AuthLDAPOnly/debian/compat
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/AuthLDAPOnly/debian/compat Wed Nov 22 09:32:58 2006
@@ -0,0 +1 @@
+4
Added: jifty/branches/template-declare/plugins/AuthLDAPOnly/debian/control
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/AuthLDAPOnly/debian/control Wed Nov 22 09:32:58 2006
@@ -0,0 +1,19 @@
+Source: libjifty-plugin-authldaponly-perl
+Section: perl
+Priority: optional
+Build-Depends: debhelper (>= 4.0.2)
+Build-Depends-Indep: perl (>= 5.8.0-7)
+Maintainer: AGOSTINI Yves <agostini at univ-metz.fr>
+Standards-Version: 3.6.1
+
+Package: libjifty-plugin-authldaponly-perl
+Architecture: all
+Depends: ${perl:Depends}, ${misc:Depends}, libjifty-perl, libnet-ldap-perl
+Description: Jifty::Plugin::AuthLDAPOnly
+ MUST NOT BE USED WITH Login PLUGIN
+ .
+ Provide authentication: only for users in your ldap.
+ .
+ If you need external users see Jifty::Plugin::AuthLDAPLogin
+ .
+ This description was automagically extracted from the module by dh-make-perl.
Added: jifty/branches/template-declare/plugins/AuthLDAPOnly/debian/copyright
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/AuthLDAPOnly/debian/copyright Wed Nov 22 09:32:58 2006
@@ -0,0 +1,7 @@
+This is the debian package for the module.
+It was created by AGOSTINI Yves <agostini at univ-metz.fr> using dh-make-perl.
+
+This copyright info was automatically extracted from the perl module.
+It may not be accurate, so you better check the module sources
+if don't want to get into legal troubles.
+
Added: jifty/branches/template-declare/plugins/AuthLDAPOnly/debian/rules
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/AuthLDAPOnly/debian/rules Wed Nov 22 09:32:58 2006
@@ -0,0 +1,83 @@
+#!/usr/bin/make -f
+# This debian/rules file is provided as a template for normal perl
+# packages. It was created by Marc Brockschmidt <marc at dch-faq.de> for
+# the Debian Perl Group (http://pkg-perl.alioth.debian.org/) but may
+# be used freely wherever it is useful.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+# If set to a true value then MakeMaker's prompt function will
+# always return the default without waiting for user input.
+export PERL_MM_USE_DEFAULT=1
+
+PACKAGE=$(shell dh_listpackages)
+
+ifndef PERL
+PERL = /usr/bin/perl
+endif
+
+TMP =$(CURDIR)/debian/$(PACKAGE)
+
+build: build-stamp
+build-stamp:
+ dh_testdir
+
+ # Add commands to compile the package here
+ $(PERL) Makefile.PL INSTALLDIRS=vendor
+ $(MAKE) OPTIMIZE="-Wall -O2 -g"
+
+ touch build-stamp
+
+clean:
+ dh_testdir
+ dh_testroot
+
+ # Add commands to clean up after the build process here
+ -$(MAKE) distclean
+
+ dh_clean build-stamp install-stamp
+
+install: build install-stamp
+install-stamp:
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+
+ # Add commands to install the package into debian/$PACKAGE_NAME here
+ #$(MAKE) test
+ $(MAKE) install DESTDIR=$(TMP) PREFIX=/usr
+
+ # As this is a architecture independent package, we are not
+ # supposed to install stuff to /usr/lib. MakeMaker creates
+ # the dirs, we delete them from the deb:
+ rmdir --ignore-fail-on-non-empty --parents $(TMP)/usr/lib/perl5
+
+ touch install-stamp
+
+binary-arch:
+# We have nothing to do by default.
+
+binary-indep: build install
+ dh_testdir
+ dh_testroot
+# dh_installcron
+# dh_installmenu
+# dh_installexamples
+ dh_installdocs
+ dh_installchangelogs
+ dh_perl
+ dh_link
+ dh_strip
+ dh_compress
+ dh_fixperms
+ dh_installdeb
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+source diff:
+ @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary
Added: jifty/branches/template-declare/plugins/AuthLDAPOnly/lib/Jifty/Plugin/AuthLDAPOnly.pm
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/AuthLDAPOnly/lib/Jifty/Plugin/AuthLDAPOnly.pm Wed Nov 22 09:32:58 2006
@@ -0,0 +1,83 @@
+use strict;
+use warnings;
+
+=head1 NAME
+
+Jifty::Plugin::AuthLDAPOnly
+
+=head1 DESCRIPTION
+
+B<MUST NOT BE USED WITH Login PLUGIN>
+
+Provide authentication: only for users in your ldap.
+
+If you need external users see C<Jifty::Plugin::AuthLDAPLogin>
+
+=head1 CONFIG
+
+in etc/config.yml
+ Plugins:
+ - AuthLDAPOnly:
+ LDAPhost: ldap1.univ-metz.fr # ldap host
+ LDAPbase: ou=people, ou=... # ldap base
+ LDAPuid: uid # optional
+
+in your user model
+ use base qw/Jifty::Plugin::AuthLDAPOnly::Model::LDAPUser/;
+
+in your application use /ldaplogin and /ldaplogout
+
+=head1 SEE ALSO
+
+L<Net::LDAP>
+
+=cut
+
+package Jifty::Plugin::AuthLDAPOnly;
+use base qw/Jifty::Plugin/;
+use Net::LDAP;
+
+# Your plugin goes here. If takes any configuration or arguments, you
+# probably want to override L<Jifty::Plugin/init>.
+
+{
+ my ($CurrentLDAPUserClass, $AuthLDAPUserClass, $LDAP, %params);
+
+ sub init {
+ my $self = shift;
+ my %args = @_;
+ my $appname = Jifty->config->framework('ApplicationName');
+ $CurrentLDAPUserClass = $args{CurrentUserClass}
+ || "${appname}::CurrentUser";
+ $AuthLDAPUserClass = $args{AuthLDAPUserClass}
+ || "${appname}::Model::LDAPUser";
+
+ $params{'Hostname'} = $args{LDAPhost};
+ $params{'base'} = $args{LDAPbase};
+ $params{'uid'} = $args{LDAPuid} || "uid";
+ $LDAP = Net::LDAP->new($params{Hostname},async=>1,onerror => 'undef', debug => 0);
+ }
+
+ sub CurrentLDAPUserClass {
+ return $CurrentLDAPUserClass;
+ }
+
+ sub AuthLDAPUserClass {
+ return $AuthLDAPUserClass;
+ }
+
+ sub LDAP {
+ return $LDAP;
+ }
+
+ sub base {
+ return $params{'base'};
+ }
+
+ sub uid {
+ return $params{'uid'};
+ }
+
+}
+
+1;
Added: jifty/branches/template-declare/plugins/AuthLDAPOnly/lib/Jifty/Plugin/AuthLDAPOnly/Action/LDAPLogin.pm
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/AuthLDAPOnly/lib/Jifty/Plugin/AuthLDAPOnly/Action/LDAPLogin.pm Wed Nov 22 09:32:58 2006
@@ -0,0 +1,103 @@
+use warnings;
+use strict;
+
+=head1 NAME
+
+Jifty::Plugin::AuthLDAPOnly::Action::LDAPLogin
+
+=cut
+
+package Jifty::Plugin::AuthLDAPOnly::Action::LDAPLogin;
+use base qw/Jifty::Action Jifty::Plugin::AuthLDAPOnly/;
+
+
+=head2 arguments
+
+Return the ticket form field
+
+=cut
+
+sub arguments {
+ return (
+ {
+ name => {
+ label => _('Login'),
+ mandatory => 1,
+ ajax_validates => 1,
+ },
+
+ password => {
+ type => 'password',
+ label => _('Password'),
+ mandatory => 1
+ },
+
+ }
+ );
+
+}
+
+=head2 validate_name NAME
+
+For ajax_validates.
+Makes sure that the name submitted is a legal login.
+
+
+=cut
+
+sub validate_name {
+ my $self = shift;
+ my $name = shift;
+
+ unless ( $name =~ /^[A-Za-z0-9-]+$/ ) {
+ return $self->validation_error(
+ name => _("That doesn't look like a valid login.") );
+ }
+
+
+ return $self->validation_ok('name');
+}
+
+
+=head2 take_action
+
+Bind on ldap to check the user's password. If it's right, log them in.
+Otherwise, throw an error.
+
+
+=cut
+
+sub take_action {
+ my $self = shift;
+ my $dn = $self->uid().'='.$self->argument_value('name').','.
+ $self->base();
+
+ # Bind on ldap
+ my $msg = $self->LDAP()->bind($dn ,'password' =>$self->argument_value('password'));
+
+ unless (not $msg->code) {
+ $self->result->error(
+ _('You may have mistyped your login or password. Give it another shot?')
+ );
+ return;
+ }
+
+ my $LDAPUser = $self->AuthLDAPUserClass();
+ my $CurrentUser = $self->CurrentLDAPUserClass();
+ my $u = $LDAPUser->new( current_user => $CurrentUser->superuser );
+
+ # Add user to LDAPUser model
+ $u->load_by_cols( name => $self->argument_value('name'));
+ my $id = $u->id;
+ if (!$id) {
+ ($id) = $u->create(name => $self->argument_value('name'), created_on => DateTime->now);
+ }
+ Jifty->log->debug("Login user id: $id");
+
+ # Actually do the signin thing.
+ Jifty->web->current_user( $CurrentUser->new( id => $u->id ) );
+
+ return 1;
+}
+
+1;
Added: jifty/branches/template-declare/plugins/AuthLDAPOnly/lib/Jifty/Plugin/AuthLDAPOnly/Action/LDAPLogout.pm
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/AuthLDAPOnly/lib/Jifty/Plugin/AuthLDAPOnly/Action/LDAPLogout.pm Wed Nov 22 09:32:58 2006
@@ -0,0 +1,35 @@
+use warnings;
+use strict;
+
+=head1 NAME
+
+Jifty::Plugin::AuthLDAPOnly::Action::LDAPLogout
+
+=cut
+
+package Jifty::Plugin::AuthLDAPOnly::Action::LDAPLogout;
+use base qw/Jifty::Action/;
+
+=head2 arguments
+
+Return the email and password form fields
+
+=cut
+
+sub arguments {
+ return ( {} );
+}
+
+=head2 take_action
+
+Nuke the current user object
+
+=cut
+
+sub take_action {
+ my $self = shift;
+ Jifty->web->current_user(undef);
+ return 1;
+}
+
+1;
Added: jifty/branches/template-declare/plugins/AuthLDAPOnly/lib/Jifty/Plugin/AuthLDAPOnly/CurrentUser.pm
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/AuthLDAPOnly/lib/Jifty/Plugin/AuthLDAPOnly/CurrentUser.pm Wed Nov 22 09:32:58 2006
@@ -0,0 +1,39 @@
+use warnings;
+use strict;
+
+
+package Jifty::Plugin::AuthLDAPOnly::CurrentUser;
+
+use base qw/Jifty::CurrentUser Jifty::Plugin::AuthLDAPOnly/;
+
+=head2 new PARAMHASH
+
+Instantiate a new current user object, loading the user by paramhash:
+
+ my $item = Jifty::Plugin::AuthLDAPOnly::Model::Item->new( Jifty::Plugin::AuthCASOnly::CurrentUser->new(email => 'user at LDAP.user'));
+
+if you give the param
+ _bootstrap => 1
+
+your object will be marked as a bootstrap user. You can use that to do an endrun around acls.
+
+=cut
+
+
+
+sub _init {
+ my $self = shift;
+ my %args = (@_);
+ my $AuthLDAPUserClass = $self->AuthLDAPUserClass;
+
+ if (delete $args{'_bootstrap'} ) {
+ $self->is_bootstrap_user(1);
+ } elsif (keys %args) {
+ $self->user_object($AuthLDAPUserClass->new(current_user => $self));
+ $self->user_object->load_by_cols(%args);
+ }
+ $self->SUPER::_init(%args);
+}
+
+
+1;
Added: jifty/branches/template-declare/plugins/AuthLDAPOnly/lib/Jifty/Plugin/AuthLDAPOnly/Dispatcher.pm
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/AuthLDAPOnly/lib/Jifty/Plugin/AuthLDAPOnly/Dispatcher.pm Wed Nov 22 09:32:58 2006
@@ -0,0 +1,31 @@
+use strict;
+use warnings;
+
+package Jifty::Plugin::AuthLDAPOnly::Dispatcher;
+use Jifty::Dispatcher -base;
+
+# Put any plugin-specific dispatcher rules here.
+
+# Log out
+before 'ldaplogout' => run {
+ Jifty->web->request->add_action(
+ class => 'LDAPLogout',
+ moniker => 'ldaplogout',
+ );
+};
+
+
+# Login
+on 'ldaplogin' => run {
+ set 'action' =>
+ Jifty->web->new_action(
+ class => 'LDAPLogin',
+ moniker => 'ldaploginbox'
+ );
+ set 'next' => Jifty->web->request->continuation
+ || Jifty::Continuation->new(
+ request => Jifty::Request->new( path => "/" ) );
+};
+
+
+1;
Added: jifty/branches/template-declare/plugins/AuthLDAPOnly/lib/Jifty/Plugin/AuthLDAPOnly/Model/LDAPUser.pm
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/AuthLDAPOnly/lib/Jifty/Plugin/AuthLDAPOnly/Model/LDAPUser.pm Wed Nov 22 09:32:58 2006
@@ -0,0 +1,70 @@
+package Jifty::Plugin::AuthLDAPOnly::Model::LDAPUser::Schema;
+use Jifty::DBI::Schema;
+use Scalar::Defer;
+
+column
+ name => type is 'text',
+ label is 'Name',
+ is mandatory,
+ is distinct;
+
+column 'created_on' =>
+ type is 'datetime',
+ is immutable,
+ default is defer { DateTime->now },
+ filters are 'Jifty::DBI::Filter::DateTime';
+
+
+package Jifty::Plugin::AuthLDAPOnly::Model::LDAPUser;
+use base qw/Jifty::Record/;
+
+sub create {
+ my $self = shift;
+ my %args = (@_);
+ my (@ret) = $self->SUPER::create(%args);
+
+# if ( $self->id and not $self->email_confirmed ) {
+# Jifty::Plugin::Login::Notification::ConfirmAddress->new( to => $self )
+# ->send;
+# }
+ return (@ret);
+}
+
+=head2 current_user_can
+
+Allows the current user to see all their own attributes and
+everyone else to see their username.
+
+Allows the current user to update any of their own attributes
+except whether or not their email has been confirmed.
+
+Passes everything else off to the superclass.
+
+=cut
+
+sub current_user_can {
+ my $self = shift;
+ my $right = shift;
+ my %args = (@_);
+ # This line breaks admin mode. I like admin mode.
+ # Carp::confess if ( $right eq 'read' and not $args{'column'} );
+ if ( $right eq 'read'
+ and $self->id == $self->current_user->id )
+ {
+ return 1;
+ }
+ elsif ( $right eq 'read' and $args{'column'} eq 'name' ) {
+ return (1);
+
+ }
+ elsif ( $right eq 'update'
+ and $self->id == $self->current_user->id
+ )
+ {
+ return (1);
+ }
+
+ return $self->SUPER::current_user_can( $right, %args );
+}
+
+1;
Added: jifty/branches/template-declare/plugins/AuthLDAPOnly/share/po/en.po
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/AuthLDAPOnly/share/po/en.po Wed Nov 22 09:32:58 2006
@@ -0,0 +1,40 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL at ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
+"Language-Team: LANGUAGE <LL at li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: lib/Jifty/Plugin/AuthLDAPOnly/Action/LDAPLogin.pm:24 share/web/templates/ldaplogin:13 share/web/templates/ldaplogin:8
+msgid "Login"
+msgstr ""
+
+#: share/web/templates/ldaplogout:2
+msgid "Ok, you're now logged out. Have a good day."
+msgstr ""
+
+#: lib/Jifty/Plugin/AuthLDAPOnly/Action/LDAPLogin.pm:31
+msgid "Password"
+msgstr ""
+
+#: lib/Jifty/Plugin/AuthLDAPOnly/Action/LDAPLogin.pm:54
+msgid "That doesn't look like a valid login."
+msgstr ""
+
+#: lib/Jifty/Plugin/AuthLDAPOnly/Action/LDAPLogin.pm:80
+msgid "You may have mistyped your login or password. Give it another shot?"
+msgstr ""
+
+#: share/web/templates/ldaplogin:17
+msgid "You're already logged in."
+msgstr ""
Added: jifty/branches/template-declare/plugins/AuthLDAPOnly/share/po/fr.po
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/AuthLDAPOnly/share/po/fr.po Wed Nov 22 09:32:58 2006
@@ -0,0 +1,25 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL at ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
+"Language-Team: LANGUAGE <LL at li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=ISO8859-15\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: lib/Jifty/Plugin/AuthLDAPOnly/Action/LDAPLogin.pm:54
+msgid "That doesn't look like a valid login."
+msgstr "Cet identifiant ne semble pas valide."
+
+#: lib/Jifty/Plugin/AuthLDAPOnly/Action/LDAPLogin.pm:80
+msgid "You may have mistyped your login or password. Give it another shot?"
+msgstr "Erreur dans votre identifiant ou votre mot de passe. Ré-essayez."
+
Added: jifty/branches/template-declare/plugins/AuthLDAPOnly/share/web/templates/ldaplogin
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/AuthLDAPOnly/share/web/templates/ldaplogin Wed Nov 22 09:32:58 2006
@@ -0,0 +1,19 @@
+<%args>
+$action => undef
+$next => undef
+</%args>
+<&|/_elements/wrapper, title => 'Login' &>
+
+% if (not Jifty->web->current_user->id) {
+<h2><% _('Login') %></h2>
+<% Jifty->web->form->start(call => $next, name => "ldaploginbox") %>
+<% $action->form_field('name') %>
+<% $action->form_field('password') %>
+%#<% $action->form_field('remember') %>
+<% Jifty->web->form->submit(label => _('Login'), submit => $action) %>
+<% Jifty->web->form->end %>
+% }
+% else {
+<% _("You're already logged in.") %>
+% }
+</&>
Added: jifty/branches/template-declare/plugins/AuthLDAPOnly/share/web/templates/ldaplogout
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/AuthLDAPOnly/share/web/templates/ldaplogout Wed Nov 22 09:32:58 2006
@@ -0,0 +1,3 @@
+<&| /_elements/wrapper, title => "Logged out" &>
+<p><% _("Ok, you're now logged out. Have a good day.") %></p>
+</&>
Modified: jifty/branches/template-declare/plugins/Login/MANIFEST
==============================================================================
--- jifty/branches/template-declare/plugins/Login/MANIFEST (original)
+++ jifty/branches/template-declare/plugins/Login/MANIFEST Wed Nov 22 09:32:58 2006
@@ -20,10 +20,14 @@
lib/Jifty/Plugin/Login/Dispatcher.pm
lib/Jifty/Plugin/Login/Model/User.pm
lib/Jifty/Plugin/Login/Notification/ConfirmAddress.pm
+lib/Jifty/Plugin/Login/Notification/ConfirmLostPassword.pm
Makefile.PL
MANIFEST This list of files
META.yml
share/web/templates/let/confirm_email
+share/web/templates/let/reset_lost_password
+share/web/templates/chgpasswd
share/web/templates/login
share/web/templates/logout
+share/web/templates/passwordreminder
share/web/templates/signup
Modified: jifty/branches/template-declare/plugins/Login/META.yml
==============================================================================
--- jifty/branches/template-declare/plugins/Login/META.yml (original)
+++ jifty/branches/template-declare/plugins/Login/META.yml Wed Nov 22 09:32:58 2006
@@ -2,7 +2,7 @@
ExtUtils::MakeMaker: 6.11
distribution_type: module
generated_by: Module::Install version 0.63
-license: unknown
+license: Perl
name: Jifty-Plugin-Login
no_index:
directory:
Modified: jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login.pm
==============================================================================
--- jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login.pm (original)
+++ jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login.pm Wed Nov 22 09:32:58 2006
@@ -1,9 +1,38 @@
use strict;
use warnings;
+=head1 NAME
+
+Jifty::Plugin::Login
+
+=cut
+
package Jifty::Plugin::Login;
use base qw/Jifty::Plugin/;
+=head1 SYNOPSIS
+
+ in etc/config.yml
+ Plugins:
+ - Login: {}
+
+ in your application Model/User.pm
+ use strict;
+ package YourApp::Model::User;
+ use base qw/Jifty::Plugin::Login::Model::User/;
+ 1;
+
+ in your application, you can use
+ http://localhost:8888/login
+ /logout
+ /signup
+ /chgpasswd
+ /passwordreminder
+
+=head1 DESCRIPTION
+
+=cut
+
# Your plugin goes here. If takes any configuration or arguments, you
# probably want to override L<Jifty::Plugin/init>.
{
Modified: jifty/branches/template-declare/share/web/static/css/base.css
==============================================================================
--- jifty/branches/template-declare/share/web/static/css/base.css (original)
+++ jifty/branches/template-declare/share/web/static/css/base.css Wed Nov 22 09:32:58 2006
@@ -12,6 +12,10 @@
color: #00a0a0;
}
+.canonicalization_note {
+ color: #009966;
+}
+
hr {
clear: both;
}
Modified: jifty/branches/template-declare/share/web/static/css/forms.css
==============================================================================
--- jifty/branches/template-declare/share/web/static/css/forms.css (original)
+++ jifty/branches/template-declare/share/web/static/css/forms.css Wed Nov 22 09:32:58 2006
@@ -31,7 +31,7 @@
color: #999999;
}
-div.form_field .error, div.form_field .warning {
+div.form_field .error, div.form_field .warning, div.form_field .canonicalization_note {
float: right;
width: 88%;
text-align: left;
Modified: jifty/branches/template-declare/share/web/static/js/jifty.js
==============================================================================
--- jifty/branches/template-declare/share/web/static/js/jifty.js (original)
+++ jifty/branches/template-declare/share/web/static/js/jifty.js Wed Nov 22 09:32:58 2006
@@ -176,7 +176,15 @@
}
} else if ((action.nodeName == 'canonicalizeaction') && (action.getAttribute("id") == id)) {
for (var field = action.firstChild; field != null; field = field.nextSibling) {
- // Possibilities for field.nodeName: it could be 'ignored', 'blank' or 'update'
+ // Possibilities for field.nodeName: it could be 'ignored', 'blank' , 'update', or 'info'
+ // info is a separate action from the update
+ if (field.nodeName == 'canonicalization_note') {
+ var note_div= document.getElementById(field.getAttribute("id"));
+ if (note_div != null) {
+ note_div.innerHTML = field.firstChild.data;
+ }
+ }
+
if (field.nodeName == 'update') {
var field_name = field.getAttribute("name");
for (var form_number = 0 ; form_number < document.forms.length; form_number++) {
Modified: jifty/branches/template-declare/share/web/templates/__jifty/admin/fragments/list/update
==============================================================================
--- jifty/branches/template-declare/share/web/templates/__jifty/admin/fragments/list/update (original)
+++ jifty/branches/template-declare/share/web/templates/__jifty/admin/fragments/list/update Wed Nov 22 09:32:58 2006
@@ -15,7 +15,7 @@
<div class="jifty_admin update item inline <%$object_type%>">
<div class="editlink">
<% Jifty->web->link(
- label => "Save",
+ label => _("Save"),
onclick => [
{ submit => $update },
{ replace_with => '/__jifty/admin/fragments/list/view',
@@ -23,9 +23,9 @@
}
]
) %>
-
+
<% Jifty->web->link(
- label => "Cancel",
+ label => _("Cancel"),
onclick => {
replace_with => '/__jifty/admin/fragments/list/view',
args => { object_type => $object_type, id => $id }
Modified: jifty/branches/template-declare/share/web/templates/__jifty/admin/fragments/list/view
==============================================================================
--- jifty/branches/template-declare/share/web/templates/__jifty/admin/fragments/list/view (original)
+++ jifty/branches/template-declare/share/web/templates/__jifty/admin/fragments/list/view Wed Nov 22 09:32:58 2006
@@ -11,10 +11,28 @@
moniker => "update-" . Jifty->web->serial,
record => $record
);
+my $delete = Jifty->web->new_action(
+ class => "Delete".$object_type,
+ moniker => "delete-" . Jifty->web->serial,
+ record => $record
+);
+
</%init>
<div class="jifty_admin read item inline">
<%
+ Jifty->web->form->submit(
+ class => "editlink",
+ label => "Delete",
+ submit => $delete,
+ onclick => {
+ confirm => _("Confirm delete?"),
+ delete => Jifty->web->current_region->qualified_name
+ },
+ )
+%>
+
+<%
Jifty->web->link(
label => "Edit",
class => "editlink",
@@ -22,9 +40,11 @@
replace_with => "/__jifty/admin/fragments/list/update",
args => { object_type => $object_type, id => $id }
},
+ as_button => 1
)
%>
+<% $delete->hidden('id',$id) %>
% foreach my $argument ($update->argument_names) {
% unless( $argument =~ /_confirm$/
% && lc $update->arguments->{$argument}{render_as} eq 'password') {
Modified: jifty/branches/template-declare/share/web/templates/__jifty/validator.xml
==============================================================================
--- jifty/branches/template-declare/share/web/templates/__jifty/validator.xml (original)
+++ jifty/branches/template-declare/share/web/templates/__jifty/validator.xml Wed Nov 22 09:32:58 2006
@@ -40,12 +40,21 @@
$writer->endTag();
$writer->startTag( "canonicalizeaction", id => $action->register_name );
for my $arg ( $action->argument_names ) {
- if ( not $action->arguments->{$arg}->{ajax_canonicalizes} ) {
+ if ($ra->arguments->{$arg} eq $action->argument_value($arg) ) {
+ # if the value doesn't change, it can be ignored.
+ # canonicalizers can change other parts of the action, so we want to send all changes
$writer->emptyTag( "ignored", name => $action->form_field_name($arg) );
} elsif ( not defined $action->argument_value($arg)
or length $action->argument_value($arg) == 0 ) {
$writer->emptyTag( "blank", name => $action->form_field_name($arg) );
} else {
+ if ( $action->result->field_canonicalization_note($arg) ) {
+ $writer->dataElement(
+ "canonicalization_note",
+ $action->result->field_canonicalization_note($arg),
+ id => $action->canonicalization_note_div_id($arg)
+ );
+ }
$writer->dataElement(
"update",
$action->argument_value($arg),
Added: jifty/branches/template-declare/t/DateTime.t
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/t/DateTime.t Wed Nov 22 09:32:58 2006
@@ -0,0 +1,9 @@
+#!/usr/bin/perl -w
+
+use Jifty::Test tests => 2;
+
+use_ok 'Jifty::DateTime';
+
+my $date = Jifty::DateTime->new_from_string("2006-05-03 01:23:45");
+my $date_clone = $date->clone();
+is $date, $date_clone;
Modified: jifty/branches/template-declare/t/TestApp/lib/TestApp/Action/DoSomething.pm
==============================================================================
--- jifty/branches/template-declare/t/TestApp/lib/TestApp/Action/DoSomething.pm (original)
+++ jifty/branches/template-declare/t/TestApp/lib/TestApp/Action/DoSomething.pm Wed Nov 22 09:32:58 2006
@@ -14,6 +14,7 @@
my $self = shift;
my $address = shift;
+ $self->canonicalization_note(email => "Lowercased your email");
return lc($address);
}
Modified: jifty/branches/template-declare/t/TestApp/t/06-validation.t
==============================================================================
--- jifty/branches/template-declare/t/TestApp/t/06-validation.t (original)
+++ jifty/branches/template-declare/t/TestApp/t/06-validation.t Wed Nov 22 09:32:58 2006
@@ -5,7 +5,7 @@
use lib 't/lib';
use Jifty::SubTest;
-use Jifty::Test tests => 13;
+use Jifty::Test tests => 14;
use Jifty::Test::WWW::Mechanize;
my $server = Jifty::Test->make_server;
@@ -40,4 +40,5 @@
"Getting validator.xml output for a canonicalization");
$mech->content_contains('<update name="J:A:F-email-dosomething">upper at email.com</update>',
" ... canonicalizer returned all lower case (good)");
-
+$mech->content_contains('<canonicalization_note id="canonicalization_note-J:A:F-email-dosomething">Lowercased your email</canonicalization_note>',
+ " ... canonicalizer warned user");
More information about the Jifty-commit
mailing list