[Jifty-commit] r3379 - in jifty/trunk: . lib/Jifty/Plugin/Feedback/Action

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Wed Jun 6 23:14:50 EDT 2007


Author: jesse
Date: Wed Jun  6 23:14:49 2007
New Revision: 3379

Added:
   jifty/trunk/lib/Jifty/Plugin/Feedback/
   jifty/trunk/lib/Jifty/Plugin/Feedback/Action/
   jifty/trunk/lib/Jifty/Plugin/Feedback/Action/SendFeedback.pm   (contents, props changed)
   jifty/trunk/lib/Jifty/Plugin/Feedback/View.pm
Modified:
   jifty/trunk/   (props changed)

Log:
 r58045 at pinglin:  jesse | 2007-06-06 23:02:18 -0400
 * Added a 'feedback' plugin
 


Added: jifty/trunk/lib/Jifty/Plugin/Feedback/Action/SendFeedback.pm
==============================================================================
--- (empty file)
+++ jifty/trunk/lib/Jifty/Plugin/Feedback/Action/SendFeedback.pm	Wed Jun  6 23:14:49 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/trunk/lib/Jifty/Plugin/Feedback/View.pm
==============================================================================
--- (empty file)
+++ jifty/trunk/lib/Jifty/Plugin/Feedback/View.pm	Wed Jun  6 23:14:49 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;


More information about the Jifty-commit mailing list