bcms_feedback_form 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/README ADDED
@@ -0,0 +1,2 @@
1
+ == bcms_feedback_form - A Feedback Form module for the BrowserCMS content management system.
2
+
@@ -0,0 +1,10 @@
1
+ # Filters added to this controller apply to all controllers in the application.
2
+ # Likewise, all the methods added will be available for all controllers.
3
+
4
+ class ApplicationController < ActionController::Base
5
+ helper :all # include all helpers, all the time
6
+ protect_from_forgery # See ActionController::RequestForgeryProtection for details
7
+
8
+ # Scrub sensitive parameters from your log
9
+ # filter_parameter_logging :password
10
+ end
@@ -0,0 +1,2 @@
1
+ class Cms::FeedbackFormsController < Cms::ContentBlockController
2
+ end
@@ -0,0 +1,26 @@
1
+ class FeedbackFormsController < ApplicationController
2
+ def submit
3
+ feedback_form = FeedbackForm.find(params[:id])
4
+ if feedback_form.use_recaptcha == true
5
+ if verify_recaptcha
6
+ Feedback.deliver_feedback(feedback_form, params)
7
+ else
8
+ raise
9
+ end
10
+ else
11
+ Feedback.deliver_feedback(feedback_form, params)
12
+ end
13
+ if request.xhr?
14
+ render :text => ((feedback_form.thank_you.blank?) ? 'Thanks!' : feedback_form.thank_you), :layout => false and return
15
+ else
16
+ redirect_to((params[:_redirect_to].blank?) ? '/' : params[:_redirect_to]) and return
17
+ end
18
+ rescue
19
+ if request.xhr?
20
+ render :text => 'There seems to have been an error. Please try again', :layout => false and return
21
+ else
22
+ redirect_to((params[:_redirect_to].blank?) ? '/' : params[:_redirect_to]) and return
23
+ end
24
+ end
25
+
26
+ end
@@ -0,0 +1,3 @@
1
+ # Methods added to this helper will be available to all templates in the application.
2
+ module ApplicationHelper
3
+ end
@@ -0,0 +1,2 @@
1
+ module FeedbackFormsHelper
2
+ end
@@ -0,0 +1,10 @@
1
+ class Feedback < ActionMailer::Base
2
+
3
+ def feedback(feedback_form,params)
4
+ recipients feedback_form.send_to.split(',')
5
+ from (feedback_form.from.blank?) ? params[:from] : feedback_form.from
6
+ subject (feedback_form.subject.blank?) ? 'Feedback form submission' : feedback_form.subject
7
+ body :feedback_form => feedback_form, :cgi_params => params, :fields => params[:feedback_form].keys
8
+ end
9
+
10
+ end
@@ -0,0 +1,9 @@
1
+ class FeedbackForm < ActiveRecord::Base
2
+ acts_as_content_block
3
+ validates_length_of :send_to, :maximum => 500
4
+ validates_length_of :subject, :maximum => 200, :allow_blank => true
5
+ validates_length_of :from, :maximum => 100, :allow_blank => true
6
+ validates_length_of :form, :maximum => 10000, :allow_blank => true
7
+ validates_length_of :description, :thank_you, :maximum => 5000, :allow_blank => true
8
+ validates_format_of :from, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :allow_blank => true
9
+ end
@@ -0,0 +1,18 @@
1
+ <%= f.cms_text_field :name %>
2
+ <%= f.cms_text_field :send_to, :instructions => 'A single email address or a comma-separated list of email addresses.' %>
3
+ <%= f.cms_text_field :from, :instructions => 'A single email address that the form is sent "from". We\'ll try to parse the from out of the params if you don\'t specify it here - name the field "from".' %>
4
+
5
+ <div class="fields checkbox_group">
6
+ <label>Use ReCaptcha</label>
7
+ <div class="checkboxes">
8
+ <div class="checkbox_fields">
9
+ <%= f.check_box :use_recaptcha %> <%= f.label :use_recaptcha, 'Use Recaptcha to protect this form from spammers. HIGHLY recommended.' %>
10
+ </div>
11
+ </div>
12
+ <br clear="all" />
13
+ </div>
14
+
15
+ <%= f.cms_text_field :subject, :instructions => 'The subject line of the outgoing email.' %>
16
+ <%= f.cms_text_editor :description, :label => 'Description: The html / text that appears above the rendered form on the website.' %>
17
+ <%= f.cms_text_editor :thank_you, :label => 'Thank you: The html / text that appears after a successful form submission' %>
18
+ <%= f.cms_text_area :form, :label => 'Form: (OPTIONAL). You can define a form here manually and it will be wrapped in the correct form tag. All form elements you want sent through the mailer should live in the "feedback_form[]" parameter namespace, so they\'d have names like "feedback_form[message]"' %>
@@ -0,0 +1,24 @@
1
+ <div class="feedback-form">
2
+ <%= @content_block.description %>
3
+ <div id="feedback-form-<%= @content_block.id %>">
4
+ <% form_remote_tag(:url => url_for(:controller => '/feedback_forms', :action => :submit, :id => @content_block.id), :update => "feedback-form-#{@content_block.id}" ) do -%>
5
+ <% unless @content_block.form.blank? %>
6
+ <%= @content_block.form %>
7
+ <% else %>
8
+ <p><strong>Name:</strong> <%= text_field_tag 'feedback_form[name]' %></p>
9
+ <p><strong>Email:</strong> <%= text_field_tag 'feedback_form[from]' %></p>
10
+ <p><strong>About:</strong> <%= text_field_tag 'feedback_form[about]' %></p>
11
+ <p>
12
+ <strong>Message:</strong><br/>
13
+ <%= text_area_tag 'feedback_form[message]', '', :size => '60x4' %>
14
+ </p>
15
+ <% end %>
16
+ <% if @content_block.use_recaptcha %>
17
+ <p><strong>Please enter the text below:</strong></p>
18
+ <%= recaptcha_tags %>
19
+ <% end %>
20
+ <%= hidden_field_tag '_redirect_to', url_for() %>
21
+ <%= submit_tag 'Submit form' %>
22
+ <% end %>
23
+ </div>
24
+ </div>
@@ -0,0 +1,12 @@
1
+ <h2>Feedback form submission</h2>
2
+
3
+ <table border="0" cellpadding="3">
4
+ <% @fields.each do |field| -%>
5
+ <tr>
6
+ <th><strong><%=h field.titleize %></strong></th>
7
+ <td><%=h @cgi_params[:feedback_form][field] %></td>
8
+ </tr>
9
+ <% end -%>
10
+ </table>
11
+
12
+ <p>at: <%= Time.now.to_s %></p>
@@ -0,0 +1,7 @@
1
+ Feedback form submission:
2
+
3
+ <% @fields.each do |field| -%>
4
+ <%= field.titleize %> => <%= @cgi_params[:feedback_form][field] %>
5
+ <% end -%>
6
+
7
+ at: <%= Time.now.to_s %>
@@ -0,0 +1,2 @@
1
+ <h1>FeedbackForms#submit</h1>
2
+ <p>Find me in app/views/feedback_forms/submit.html.erb</p>
@@ -0,0 +1,2 @@
1
+ ENV['RECAPTCHA_PUBLIC_KEY'] = 'YOUR PUBLIC KEY HERE'
2
+ ENV['RECAPTCHA_PRIVATE_KEY'] = 'YOUR PRIVATE KEY HERE'
@@ -0,0 +1,22 @@
1
+ class CreateFeedbackForms < ActiveRecord::Migration
2
+ def self.up
3
+ create_content_table :feedback_forms do |t|
4
+ t.string :send_to, :limit => 500
5
+ t.string :subject, :limit => 200
6
+ t.string :from, :limit => 100
7
+ t.string :form, :limit => 10000
8
+ t.string :description, :limit => 5000
9
+ t.string :thank_you, :limit => 5000
10
+ t.boolean :use_recaptcha, :default => true
11
+ end
12
+ ContentType.create!(:name => "FeedbackForm", :group_name => "FeedbackForm")
13
+ end
14
+
15
+ def self.down
16
+ ContentType.delete_all(['name = ?', 'FeedbackForm'])
17
+ CategoryType.all(:conditions => ['name = ?', 'Feedback Form']).each(&:destroy)
18
+ #If you aren't creating a versioned table, be sure to comment this out.
19
+ drop_table :feedback_form_versions
20
+ drop_table :feedback_forms
21
+ end
22
+ end
@@ -0,0 +1 @@
1
+ require 'bcms_feedback_form/routes'
@@ -0,0 +1,8 @@
1
+ module Cms::Routes
2
+ def routes_for_bcms_feedback_form
3
+ self.connect 'feedback_forms/:action/:id.:format', :controller => 'feedback_forms'
4
+ namespace(:cms) do |cms|
5
+ cms.content_blocks :feedback_forms
6
+ end
7
+ end
8
+ end
@@ -0,0 +1 @@
1
+ Use this directory to add public files that should copied from the gem into the project.
data/rails/init.rb ADDED
@@ -0,0 +1,4 @@
1
+ gem_root = File.expand_path(File.join(File.dirname(__FILE__), ".."))
2
+ Cms.add_to_rails_paths gem_root
3
+ Cms.add_generator_paths gem_root, "db/migrate/[0-9]*_*.rb"
4
+ Cms.add_generator_paths gem_root, "public/bcms/feedback_form/**/*"
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bcms_feedback_form
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Daniel Collis-Puro
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-03-12 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: djcp+github@cyber.law.harvard.edu
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README
24
+ files:
25
+ - app/helpers/application_helper.rb
26
+ - app/helpers/feedback_forms_helper.rb
27
+ - app/views/feedback_forms/submit.html.erb
28
+ - app/views/feedback/feedback.text.plain.erb
29
+ - app/views/feedback/feedback.text.html.erb
30
+ - app/views/cms/feedback_forms/render.html.erb
31
+ - app/views/cms/feedback_forms/_form.html.erb
32
+ - app/controllers/feedback_forms_controller.rb
33
+ - app/controllers/application_controller.rb
34
+ - app/controllers/cms/feedback_forms_controller.rb
35
+ - app/models/feedback.rb
36
+ - app/models/feedback_form.rb
37
+ - db/migrate/20100312161745_create_feedback_forms.rb
38
+ - lib/bcms_feedback_form.rb
39
+ - lib/bcms_feedback_form/routes.rb
40
+ - rails/init.rb
41
+ - config/initializers/recaptcha.rb
42
+ - public/bcms/feedback_form/README
43
+ - README
44
+ has_rdoc: true
45
+ homepage: http://github.com/djcp/bcms_feedback_form
46
+ licenses: []
47
+
48
+ post_install_message:
49
+ rdoc_options: []
50
+
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: "0"
58
+ version:
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: "0"
64
+ version:
65
+ requirements: []
66
+
67
+ rubyforge_project: bcms_feedback_form
68
+ rubygems_version: 1.3.5
69
+ signing_key:
70
+ specification_version: 3
71
+ summary: A Feedback Form Module for BrowserCMS
72
+ test_files: []
73
+