[Jifty-commit] r3384 - in jifty/branches/js-refactor: . lib/Jifty
lib/Jifty/Plugin lib/Jifty/Plugin/CompressedCSSandJS
lib/Jifty/Plugin/Feedback lib/Jifty/Plugin/Feedback/Action
lib/Jifty/Script lib/Jifty/Web share/web/static/js
t/TestApp/lib/TestApp
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Thu Jun 7 04:08:10 EDT 2007
Author: trs
Date: Thu Jun 7 04:08:10 2007
New Revision: 3384
Added:
jifty/branches/js-refactor/lib/Jifty/Plugin/Feedback/
jifty/branches/js-refactor/lib/Jifty/Plugin/Feedback.pm
jifty/branches/js-refactor/lib/Jifty/Plugin/Feedback/Action/
jifty/branches/js-refactor/lib/Jifty/Plugin/Feedback/Action/SendFeedback.pm (contents, props changed)
jifty/branches/js-refactor/lib/Jifty/Plugin/Feedback/View.pm
Modified:
jifty/branches/js-refactor/ (props changed)
jifty/branches/js-refactor/lib/Jifty/Plugin/CompressedCSSandJS/Dispatcher.pm
jifty/branches/js-refactor/lib/Jifty/Plugin/SinglePage.pm
jifty/branches/js-refactor/lib/Jifty/Script/Plugin.pm
jifty/branches/js-refactor/lib/Jifty/Util.pm
jifty/branches/js-refactor/lib/Jifty/Web/Form.pm
jifty/branches/js-refactor/share/po/en.po
jifty/branches/js-refactor/share/web/static/js/jifty.js
jifty/branches/js-refactor/t/TestApp/lib/TestApp/Dispatcher.pm
Log:
r21775 at zot (orig r3376): clkao | 2007-06-06 21:57:13 -0400
correct en.po charset.
r21776 at zot (orig r3377): clkao | 2007-06-06 22:24:03 -0400
In SPA mode, allow Action::Redirect to happen within webservice and have
the client js accepts it.
r21777 at zot (orig r3378): jesse | 2007-06-06 23:13:31 -0400
r58024 at pinglin: jesse | 2007-06-05 19:23:04 -0400
* Removing a spurious 'warn'
r21778 at zot (orig r3379): jesse | 2007-06-06 23:14:49 -0400
r58045 at pinglin: jesse | 2007-06-06 23:02:18 -0400
* Added a 'feedback' plugin
r21779 at zot (orig r3380): jesse | 2007-06-06 23:14:58 -0400
r58046 at pinglin: jesse | 2007-06-06 23:10:17 -0400
* docs!
r21782 at zot (orig r3381): bartb | 2007-06-07 00:30:49 -0400
typo fix
r21784 at zot (orig r3382): trs | 2007-06-07 00:48:54 -0400
r21781 at zot: tom | 2007-06-07 00:45:50 -0400
Only squelch "can't locate" errors relating to the class we're trying to require. If it's something else, it's likely a module use'd by the module we're requiring.
r21788 at zot (orig r3383): trs | 2007-06-07 01:38:08 -0400
r21787 at zot: tom | 2007-06-07 01:37:58 -0400
Back that back out for now -- breaks Doxory
Modified: jifty/branches/js-refactor/lib/Jifty/Plugin/CompressedCSSandJS/Dispatcher.pm
==============================================================================
--- jifty/branches/js-refactor/lib/Jifty/Plugin/CompressedCSSandJS/Dispatcher.pm (original)
+++ jifty/branches/js-refactor/lib/Jifty/Plugin/CompressedCSSandJS/Dispatcher.pm Thu Jun 7 04:08:10 2007
@@ -19,7 +19,6 @@
on '/__jifty/js/*' => run {
my $arg = $1;
- warn "My arg is $arg";
if ( $arg !~ /^[0-9a-f]{32}\.js$/ ) {
# This doesn't look like a real request for squished JS,
Added: jifty/branches/js-refactor/lib/Jifty/Plugin/Feedback.pm
==============================================================================
--- (empty file)
+++ jifty/branches/js-refactor/lib/Jifty/Plugin/Feedback.pm Thu Jun 7 04:08:10 2007
@@ -0,0 +1,42 @@
+use strict;
+use warnings;
+
+package Jifty::Plugin::Feedback;
+use base qw/Jifty::Plugin Class::Accessor/;
+
+# Your plugin goes here. If takes any configuration or arguments, you
+# probably want to override L<Jifty::Plugin/init>.
+
+=head1 NAME
+
+Jifty::Plugin::Feedback
+
+=head1 DESCRIPTION
+
+This plugin provides a "feedback box" for your app.
+
+
+Add to your app's config:
+
+ Plugins:
+ - Feedback:
+ from: defaultsender at example.com
+ to: recipient at example.com
+
+Add to your app's UI where you want the feedback box:
+
+ show '/feedback/request_feedback';
+
+
+=cut
+
+__PACKAGE__->mk_accessors(qw(from to));
+
+sub init {
+ my $self = shift;
+ my %opt = @_;
+ $self->from($opt{'from'});
+ $self->to($opt{'to'});
+}
+
+1;
Added: jifty/branches/js-refactor/lib/Jifty/Plugin/Feedback/Action/SendFeedback.pm
==============================================================================
--- (empty file)
+++ jifty/branches/js-refactor/lib/Jifty/Plugin/Feedback/Action/SendFeedback.pm Thu Jun 7 04:08:10 2007
@@ -0,0 +1,95 @@
+
+use warnings;
+use strict;
+
+=head1 NAME
+
+Jifty::Plugin::Feedback::Action::SendFeedback
+
+=cut
+
+package Jifty::Plugin::Feedback::Action::SendFeedback;
+use base qw/Jifty::Action/;
+
+
+=head2 arguments
+
+The fields for C<SendFeedback> are:
+
+=over 4
+
+=item content: a big box where the user can type in what eits them
+
+
+=back
+
+=cut
+
+sub arguments {
+ {
+ content => {
+ label => '',
+ render_as => 'Textarea',
+ rows => 5,
+ cols => 60,
+ sticky => 0
+ },
+ }
+
+}
+
+=head2 take_action
+
+Send some mail to the hiveminders describing the issue.
+
+=cut
+
+sub take_action {
+ my $self = shift;
+ return 1 unless ( $self->argument_value('content') );
+
+ my ($plugin) = Jifty->find_plugin('Jifty::Plugin::Feedback');
+ my $debug_info = $self->build_debugging_info();
+
+ my $msg = $self->argument_value('content') . "\n\n" . $debug_info;
+ my $subject = substr( $self->argument_value('content'), 0, 60 );
+ $subject =~ s/\n/ /g;
+
+ # Fall back to normal email
+ my $mail = Jifty::Notification->new;
+ $mail->body($msg);
+ $mail->from(
+ ( Jifty->web->current_user->id
+ && Jifty->web->current_user->user_object->can('email')
+ )
+ ? Jifty->web->current_user->user_object->email()
+ : $plugin->from
+ );
+ $mail->recipients( $plugin->to );
+ $mail->subject( "["
+ . Jifty->config->framework('ApplicationName')
+ . " feedback] "
+ . $subject );
+ $mail->send_one_message;
+
+ $self->result->message(qq[Thanks for the feedback. We appreciate it!]);
+ return 1;
+}
+
+=head2 build_debugging_info
+
+Strings together the current environment to attach to outgoing
+email. Returns it as a scalar.
+
+=cut
+
+sub build_debugging_info {
+ my $self = shift;
+ my $message = "-- \nPrivate debugging information:\n";
+ $message .= " $_: $ENV{$_}\n"
+ for sort grep {/^(HTTP|REMOTE|REQUEST)_/} keys %ENV;
+
+ return $message;
+}
+
+1;
Added: jifty/branches/js-refactor/lib/Jifty/Plugin/Feedback/View.pm
==============================================================================
--- (empty file)
+++ jifty/branches/js-refactor/lib/Jifty/Plugin/Feedback/View.pm Thu Jun 7 04:08:10 2007
@@ -0,0 +1,53 @@
+use warnings;
+use strict;
+package Jifty::Plugin::Feedback::View;
+
+use Jifty::View::Declare -base;
+
+
+template 'feedback/request_feedback' => sub {
+ div {
+ attr { id => 'feedback_wrapper' };
+
+ h3 { _('Send us feedback!') } p {
+ "Tell us what's good, what's bad, and what else you want "
+ . Jifty->config->framework('ApplicationName')
+ . " to do!";
+ };
+ render_region(
+ 'feedback',
+ path => "/feedback/region",
+ defaults => {}
+ );
+ };
+};
+
+
+template 'feedback/region' => sub {
+ my $feedback = Jifty->web->new_action(
+ class => "SendFeedback",
+ moniker => "feedback"
+ );
+
+ if ( Jifty->web->response->result("feedback")) {
+ span {
+ attr { id => 'feedback-result' };
+ Jifty->web->response->result("feedback")->{'message'};
+ };
+ };
+ div {
+ attr { id => 'feedback' };
+
+ form {
+ render_param( $feedback => 'content' );
+ form_submit(
+ label => "Send",
+ onclick => {
+ submit => $feedback,
+ refresh_self => 1
+ }
+ );
+ }
+ }
+};
+1;
Modified: jifty/branches/js-refactor/lib/Jifty/Plugin/SinglePage.pm
==============================================================================
--- jifty/branches/js-refactor/lib/Jifty/Plugin/SinglePage.pm (original)
+++ jifty/branches/js-refactor/lib/Jifty/Plugin/SinglePage.pm Thu Jun 7 04:08:10 2007
@@ -20,9 +20,7 @@
my $url = $args->{'url'};
if ( $url && $url !~ m/^#/ ) {
delete $args->{'url'};
-
# XXX mind the existing onclick
- use Data::Dumper;
warn 'ooops got original onclick' . Dumper( $args->{onclick} )
if $args->{onclick};
$args->{onclick} = {
@@ -31,6 +29,11 @@
args => delete $args->{parameters}
};
}
+ elsif (exists $args->{submit}) {
+ $args->{onclick} = { submit => delete $args->{submit} };
+ $args->{refresh_self} = 1;
+ $args->{as_button} = 1;
+ }
my $onclick = $args->{onclick};
if ( ref($onclick) eq 'HASH' ) {
if ( $onclick->{region} && !ref( $onclick->{region} ) ) {
Modified: jifty/branches/js-refactor/lib/Jifty/Script/Plugin.pm
==============================================================================
--- jifty/branches/js-refactor/lib/Jifty/Script/Plugin.pm (original)
+++ jifty/branches/js-refactor/lib/Jifty/Script/Plugin.pm Thu Jun 7 04:08:10 2007
@@ -93,7 +93,7 @@
package $mod_name;
use base qw/Jifty::Plugin/;
-# Your plugin goes here. If takes any configuration or arguments, you
+# Your plugin goes here. If it takes any configuration or arguments, you
# probably want to override L<Jifty::Plugin/init>.
1;
Modified: jifty/branches/js-refactor/lib/Jifty/Util.pm
==============================================================================
--- jifty/branches/js-refactor/lib/Jifty/Util.pm (original)
+++ jifty/branches/js-refactor/lib/Jifty/Util.pm Thu Jun 7 04:08:10 2007
@@ -245,7 +245,7 @@
return 0;
}
elsif ( $UNIVERSAL::require::ERROR !~ /^Can't locate/) {
- die $UNIVERSAL::require::ERROR;
+ die $UNIVERSAL::require::ERROR;
} else {
Jifty->log->error(sprintf("$error at %s line %d\n", (caller(1))[1,2]));
return 0;
Modified: jifty/branches/js-refactor/lib/Jifty/Web/Form.pm
==============================================================================
--- jifty/branches/js-refactor/lib/Jifty/Web/Form.pm (original)
+++ jifty/branches/js-refactor/lib/Jifty/Web/Form.pm Thu Jun 7 04:08:10 2007
@@ -218,22 +218,9 @@
sub submit {
my $self = shift;
- my $button = Jifty::Web::Form::Clickable->new(submit => undef, @_);
- my ($spa) = Jifty->find_plugin('Jifty::Plugin::SinglePage');
- if ($spa) {
- # XXX: move to _sp_link hook.
- if ($button->onclick) {
- Carp::cluck "already has onclick, fix me later";
- }
- else {
- my $submit = delete $button->{submit};
- $button->onclick({ submit => $submit },
- refresh_self => 1);
- }
- }
-
+ my $button = Jifty::Web::Form::Clickable->new(submit => undef, @_)->generate;
Jifty->web->out(qq{<div class="submit_button">});
- $button->generate->render_widget;
+ $button->render_widget;
Jifty->web->out(qq{</div>});
return '';
Modified: jifty/branches/js-refactor/share/po/en.po
==============================================================================
--- jifty/branches/js-refactor/share/po/en.po (original)
+++ jifty/branches/js-refactor/share/po/en.po Thu Jun 7 04:08:10 2007
@@ -12,7 +12,7 @@
"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-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: lib/Jifty/Plugin/Authentication/Password/Notification/ConfirmLostPassword.pm:38
Modified: jifty/branches/js-refactor/share/web/static/js/jifty.js
==============================================================================
--- jifty/branches/js-refactor/share/web/static/js/jifty.js (original)
+++ jifty/branches/js-refactor/share/web/static/js/jifty.js Thu Jun 7 04:08:10 2007
@@ -746,13 +746,21 @@
// default to disable fields
var form = Form.Element.getForm(trigger);
if (form)
- Form.getActions(form).map(function(x){named_args['actions'][x.moniker] = 1 });
+ Form.getActions(form).map(function(x){
+ named_args['actions'][x.moniker] = 1;
+ });
}
// Build actions structure
request['actions'] = $H();
+ var optional_fragments;
for (var moniker in named_args['actions']) {
var disable = named_args['actions'][moniker];
var a = new Action(moniker, button_args);
+ // Special case for Redirect, allow optional, implicit __page
+ // from the response to be used.
+ if (a.actionClass == 'Jifty::Action::Redirect')
+ optional_fragments = [ prepare_element_for_update({'mode':'Replace','args':{},'region':'__page','path': a.fields().last().value}) ];
+
if (a.register) {
if (a.hasUpload())
return true;
@@ -786,13 +794,14 @@
// Grab the XML response
var response = transport.responseXML.documentElement;
// Loop through the result looking for it
+ var expected_fragments = optional_fragments ? optional_fragments : named_args['fragments'];
for (var response_fragment = response.firstChild;
response_fragment != null && response_fragment.nodeName == 'fragment';
response_fragment = response_fragment.nextSibling) {
var f;
- for (var i = 0; i < named_args['fragments'].length; i++) {
- f = named_args['fragments'][i];
+ for (var i = 0; i < expected_fragments.length; i++) {
+ f = expected_fragments[i];
if (response_fragment.getAttribute("id") == f['region'])
break;
}
Modified: jifty/branches/js-refactor/t/TestApp/lib/TestApp/Dispatcher.pm
==============================================================================
--- jifty/branches/js-refactor/t/TestApp/lib/TestApp/Dispatcher.pm (original)
+++ jifty/branches/js-refactor/t/TestApp/lib/TestApp/Dispatcher.pm Thu Jun 7 04:08:10 2007
@@ -70,4 +70,16 @@
};
+before '__jifty/webservices/*' => run {
+ my (@actions) = grep { $_->class eq 'Jifty::Action::Redirect' } values %{ Jifty->web->request->{'actions'} };
+ $_->active(0) for @actions;
+};
+
+on qr{(__jifty/webservices/.*)} => run {
+ use Data::Dumper;
+ for $act (@actions) {
+ warn Dumper($act);
+ }
+};
+
1;
More information about the Jifty-commit
mailing list