pointless_feedback 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.md +138 -0
  3. data/Rakefile +40 -0
  4. data/app/assets/javascripts/pointless_feedback/application.js +15 -0
  5. data/app/assets/stylesheets/pointless_feedback/application.css +13 -0
  6. data/app/controllers/pointless_feedback/messages_controller.rb +22 -0
  7. data/app/helpers/pointless_feedback/application_helper.rb +26 -0
  8. data/app/mailers/pointless_feedback/feedback_mailer.rb +16 -0
  9. data/app/models/pointless_feedback/message.rb +26 -0
  10. data/app/views/layouts/pointless_feedback/application.html.erb +14 -0
  11. data/app/views/pointless_feedback/feedback_mailer/feedback.html.erb +6 -0
  12. data/app/views/pointless_feedback/messages/new.html.erb +57 -0
  13. data/config/locales/en.yml +1 -0
  14. data/config/routes.rb +5 -0
  15. data/db/migrate/20130501182659_create_pointless_feedback_messages.rb +12 -0
  16. data/lib/generators/pointless_feedback/install_generator.rb +13 -0
  17. data/lib/generators/pointless_feedback/views_generator.rb +16 -0
  18. data/lib/generators/templates/pointless_feedback.rb +13 -0
  19. data/lib/pointless_feedback/controllers/helpers.rb +10 -0
  20. data/lib/pointless_feedback/engine.rb +13 -0
  21. data/lib/pointless_feedback/version.rb +3 -0
  22. data/lib/pointless_feedback.rb +32 -0
  23. data/lib/tasks/pointless_feedback_tasks.rake +4 -0
  24. data/test/dummy/README.rdoc +261 -0
  25. data/test/dummy/Rakefile +7 -0
  26. data/test/dummy/app/assets/javascripts/application.js +15 -0
  27. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  28. data/test/dummy/app/controllers/application_controller.rb +3 -0
  29. data/test/dummy/app/controllers/home_controller.rb +4 -0
  30. data/test/dummy/app/helpers/application_helper.rb +2 -0
  31. data/test/dummy/app/views/home/index.html.erb +1 -0
  32. data/test/dummy/app/views/layouts/application.html.erb +16 -0
  33. data/test/dummy/config/application.rb +59 -0
  34. data/test/dummy/config/boot.rb +10 -0
  35. data/test/dummy/config/database.yml +25 -0
  36. data/test/dummy/config/environment.rb +5 -0
  37. data/test/dummy/config/environments/development.rb +37 -0
  38. data/test/dummy/config/environments/production.rb +67 -0
  39. data/test/dummy/config/environments/test.rb +37 -0
  40. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  41. data/test/dummy/config/initializers/inflections.rb +15 -0
  42. data/test/dummy/config/initializers/mime_types.rb +5 -0
  43. data/test/dummy/config/initializers/secret_token.rb +7 -0
  44. data/test/dummy/config/initializers/session_store.rb +8 -0
  45. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  46. data/test/dummy/config/locales/en.yml +5 -0
  47. data/test/dummy/config/routes.rb +5 -0
  48. data/test/dummy/config.ru +4 -0
  49. data/test/dummy/db/development.sqlite3 +0 -0
  50. data/test/dummy/db/schema.rb +25 -0
  51. data/test/dummy/db/test.sqlite3 +0 -0
  52. data/test/dummy/log/development.log +187 -0
  53. data/test/dummy/log/test.log +9624 -0
  54. data/test/dummy/public/404.html +26 -0
  55. data/test/dummy/public/422.html +26 -0
  56. data/test/dummy/public/500.html +25 -0
  57. data/test/dummy/public/favicon.ico +0 -0
  58. data/test/dummy/script/rails +6 -0
  59. data/test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
  60. data/test/dummy/tmp/cache/assets/CDA/AF0/sprockets%2F2b009905de1eb97e693a12d62f76c221 +0 -0
  61. data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  62. data/test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
  63. data/test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
  64. data/test/dummy/tmp/cache/assets/D72/890/sprockets%2F6208de944cfe6b5b3c3c37c89d32f41a +0 -0
  65. data/test/dummy/tmp/cache/assets/DD9/830/sprockets%2Fc25e8f936dbc8c2b26c7c7b3d7ff6d13 +0 -0
  66. data/test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
  67. data/test/dummy/tmp/cache/assets/E02/8C0/sprockets%2Fdcaacb4effc911c9573def4b74b82590 +0 -0
  68. data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  69. data/test/dummy/tmp/capybara/capybara-201306030928415341101962.html +48 -0
  70. data/test/dummy/tmp/capybara/capybara-201306030937025132981181.html +48 -0
  71. data/test/dummy/tmp/capybara/capybara-201306030937083494523886.html +48 -0
  72. data/test/dummy/tmp/capybara/capybara-20130603093722783471600.html +65 -0
  73. data/test/dummy/tmp/capybara/capybara-20130603094056611257399.html +241 -0
  74. data/test/dummy/tmp/capybara/capybara-201306030944524823294090.html +14 -0
  75. data/test/dummy/tmp/capybara/capybara-20130828105343685535937.html +50 -0
  76. data/test/dummy/tmp/capybara/capybara-201308281055176538066301.html +52 -0
  77. data/test/dummy/tmp/capybara/capybara-201311071553562925508230.html +58 -0
  78. data/test/factories/messages.rb +8 -0
  79. data/test/functional/pointless_feedback/feedback_mailer_test.rb +25 -0
  80. data/test/functional/pointless_feedback/messages_controller_test.rb +61 -0
  81. data/test/generators/install_generator_test.rb +14 -0
  82. data/test/generators/views_generator_test.rb +14 -0
  83. data/test/integration/pointless_feedback/feedback_submission_test.rb +54 -0
  84. data/test/integration/pointless_feedback/main_app_root_url_test.rb +9 -0
  85. data/test/pointless_feedback_test.rb +7 -0
  86. data/test/test_helper.rb +26 -0
  87. data/test/tmp/app/views/pointless_feedback/messages/new.html.erb +57 -0
  88. data/test/unit/helpers/pointless_feedback/application_helper_test.rb +39 -0
  89. data/test/unit/pointless_feedback/message_test.rb +96 -0
  90. metadata +280 -0
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2013 Viget
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,138 @@
1
+ # Pointless Feedback
2
+
3
+ A Rails engine that provides a platform for your app to submit user feedback to
4
+ a specified service. Messages are stored in your database as a fail-safe when
5
+ the specified service is unavailable. Currently, only email, Unfuddle, and
6
+ Github Issues are supported.
7
+
8
+ *Brought to you by the fine folks at [Viget](http://viget.com) and commissioned
9
+ under [Pointless Corp](http://www.pointlesscorp.com/).*
10
+
11
+ ## Contents
12
+
13
+ 1. [Installation](#installation)
14
+ 2. [Customization](#customization)
15
+ 3. [Development](#development)
16
+ 4. [Roadmap](#roadmap)
17
+ 5. [Contributors](#contributors)
18
+
19
+ ## Installation
20
+
21
+ Pointless Feedback has been tested against Rails 3.2+. To install, simply add
22
+ the following to your Gemfile:
23
+
24
+ ```ruby
25
+ gem 'pointless_feedback', :git => 'git@github.com:vigetlabs/pointless-feedback.git'
26
+ ```
27
+
28
+ After you install Pointless Feedback and add it to your Gemfile, you need to
29
+ run the generator and install the engine migrations:
30
+
31
+ ```
32
+ bundle exec rails generate pointless_feedback:install
33
+ bundle exec rake pointless_feedback:install:migrations
34
+ bundle exec rake db:migrate
35
+ ```
36
+
37
+ The generator will install an initializer which describes ALL Pointless
38
+ Feedback's configuration options and you MUST take a look at it. When you are
39
+ done, you are ready to mount the routes in your `config/routes.rb` file.
40
+
41
+ ```ruby
42
+ mount PointlessFeedback::Engine, :at => '/feedback'
43
+ ```
44
+
45
+ Pointless Feedback uses flash messages to let users know if feedback was
46
+ successfully sent. Pointless Feedback expects your application to call
47
+ `flash[:notice]` as appropriate.
48
+
49
+ After submitting feedback, Pointless Feedback will use your application's
50
+ default `root_path`. This means that you need to set the root inside your
51
+ routes:
52
+
53
+ ```ruby
54
+ root :to => 'home#index'
55
+ ```
56
+
57
+ That's it! Start your Rails server and navigate to `/feedback` to see a basic
58
+ feedback form that users can submit.
59
+
60
+ ## Customization
61
+
62
+ Pointless Feedback provides you with a simple setup that should cover most
63
+ cases. However, certain things are customizable to suit your app's needs.
64
+
65
+ #### Views
66
+
67
+ Since Pointless Feedback is an engine, all its views are packaged inside the
68
+ gem. These views will help you get started, but after some time you may want
69
+ to change them. If this is the case, you just need to invoke the following
70
+ generator, and it will copy all views to your application:
71
+
72
+ ```
73
+ bundle exec rails generate pointless_feedback:views
74
+ ```
75
+
76
+ After doing so, you will find the views at `app/views/pointless_feedback/`
77
+ within your application.
78
+
79
+ **Note: Any url helpers used while on the feedback form page will need to prefaced with `main_app`.**
80
+
81
+ #### I18n
82
+
83
+ Most of the messaging in the Pointless Feedback engine uses I18n and can be
84
+ customized within your respective localization file.
85
+
86
+ To customize the flash notification upon successful submission, add the
87
+ following to your `config/locales/en.yml` file:
88
+
89
+ ```yml
90
+ pointless_feedback:
91
+ messages:
92
+ saved: "Thanks for your feedback!"
93
+ ```
94
+
95
+ The error messages output defaults to the following:
96
+
97
+ ```yml
98
+ activerecord:
99
+ errors:
100
+ header: "Invalid Fields"
101
+ message: "Correct the following errors and try again."
102
+ ```
103
+
104
+ To customize the subject of the feedback email, add the following to your
105
+ `config/locales/en.yml` file as well:
106
+
107
+ ```yml
108
+ pointless_feedback:
109
+ email:
110
+ subject: "Pointless Feedback"
111
+ ```
112
+
113
+ #### Controllers
114
+
115
+ You can overwrite `after_message_create_path` in your `ApplicationController`
116
+ to customize your redirect hook.
117
+
118
+ ## Development
119
+
120
+ 1. Clone the repo: `git clone git://github.com/vigetlabs/pointless-feedback.git`
121
+ 2. Install dependencies: `bundle install`
122
+ 3. Setup databases: `bundle exec rake db:migrate && rake app:db:test:prepare`
123
+ 4. Run the test suite: `bundle exec rake test`
124
+ 5. Make your changes in a feature branch
125
+ 6. Make sure the test suite passes before submitting a Pull Request
126
+
127
+ ## Roadmap
128
+
129
+ - [ ] Add service to send to Unfuddle
130
+ - [ ] Add service to send to Github
131
+ - [ ] Add admin view for messages with comments
132
+
133
+ ## Contributors
134
+
135
+ * [@zporter](https://github.com/zporter)
136
+ * [@efatsi](https://github.com/efatsi)
137
+
138
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'PointlessFeedback'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
24
+ load 'rails/tasks/engine.rake'
25
+
26
+
27
+
28
+ Bundler::GemHelper.install_tasks
29
+
30
+ require 'rake/testtask'
31
+
32
+ Rake::TestTask.new(:test) do |t|
33
+ t.libs << 'lib'
34
+ t.libs << 'test'
35
+ t.pattern = 'test/**/*_test.rb'
36
+ t.verbose = false
37
+ end
38
+
39
+
40
+ task :default => :test
@@ -0,0 +1,15 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require_tree .
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,22 @@
1
+ module PointlessFeedback
2
+ class MessagesController < PointlessFeedback.parent_controller.constantize
3
+ helper PointlessFeedback::ApplicationHelper
4
+
5
+ def new
6
+ @message = Message.new
7
+ end
8
+
9
+ def create
10
+ @message = Message.new(params[:message])
11
+
12
+ if @message.save
13
+ flash[:notice] = I18n.t('pointless_feedback.messages.saved',
14
+ :default => 'Thanks for your feedback!')
15
+
16
+ redirect_to after_message_create_path
17
+ else
18
+ render :new
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,26 @@
1
+ module PointlessFeedback
2
+ module ApplicationHelper
3
+ delegate :root_url, :root_path, :to => :main_app
4
+
5
+ # Can search for named routes directly in the main app, omitting
6
+ # the "main_app." prefix
7
+ def method_missing(method, *args, &block)
8
+ if main_app_url_helper?(method)
9
+ main_app.send(method, *args)
10
+ else
11
+ super
12
+ end
13
+ end
14
+
15
+ def respond_to_missing?(method, include_all)
16
+ main_app_url_helper?(method) || super
17
+ end
18
+
19
+
20
+ private
21
+
22
+ def main_app_url_helper?(method)
23
+ /\A\w+(_path|_url)\z/ === method.to_s && main_app.respond_to?(method)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,16 @@
1
+ module PointlessFeedback
2
+ class FeedbackMailer < ActionMailer::Base
3
+ default :from => PointlessFeedback.from_email
4
+
5
+ def feedback(email, message)
6
+ @message = message
7
+ mail(:to => email, :subject => feedback_subject)
8
+ end
9
+
10
+ private
11
+
12
+ def feedback_subject
13
+ I18n.t('pointless_feedback.email.subject', :default => 'Pointless Feedback')
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,26 @@
1
+ module PointlessFeedback
2
+ class Message < ActiveRecord::Base
3
+ attr_accessible :description, :email_address, :name, :topic, :contact_info
4
+ attr_accessor :contact_info
5
+
6
+ validates :name, :email_address, :topic, :description, :presence => true
7
+ validates :topic, :inclusion => PointlessFeedback.message_topics
8
+ validates :email_address, :format => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
9
+
10
+ after_save :export_feedback, :unless => :honeypot_filled_in?
11
+
12
+ private
13
+
14
+ def export_feedback
15
+ if PointlessFeedback.email_feedback
16
+ PointlessFeedback.to_emails.each do |email|
17
+ FeedbackMailer.feedback(email, self).deliver
18
+ end
19
+ end
20
+ end
21
+
22
+ def honeypot_filled_in?
23
+ contact_info.present?
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>PointlessFeedback</title>
5
+ <%= stylesheet_link_tag "pointless_feedback/application", :media => "all" %>
6
+ <%= javascript_include_tag "pointless_feedback/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,6 @@
1
+ You've got feedback!
2
+
3
+ <p>Name: <%= @message.name %></p>
4
+ <p>Email Address: <%= @message.email_address %></p>
5
+ <p>Topic: <%= @message.topic %></p>
6
+ <p>Description: <%= @message.description %></p>
@@ -0,0 +1,57 @@
1
+ <%= form_for @message do |f| %>
2
+ <% if @message.errors.any? %>
3
+ <div class="error_messages">
4
+ <h2>
5
+ <%= I18n.t('activerecord.errors.header', :default => 'Invalid Fields') %>
6
+ </h2>
7
+
8
+ <p>
9
+ <%= I18n.t('activerecord.errors.message', :default => 'Correct the following errors and try again.') %>
10
+ </p>
11
+
12
+ <ul>
13
+ <% @message.errors.full_messages.each do |message| %>
14
+ <li><%= message.html_safe %></li>
15
+ <% end %>
16
+ </ul>
17
+ </div>
18
+ <% end %>
19
+
20
+ <fieldset class="user-fields">
21
+ <legend>About You</legend>
22
+
23
+ <div class="field">
24
+ <%= f.label :name %>
25
+ <%= f.text_field :name %>
26
+ </div>
27
+
28
+ <div class="field">
29
+ <%= f.label :email_address %>
30
+ <%= f.text_field :email_address %>
31
+ </div>
32
+ </fieldset>
33
+
34
+ <fieldset class="feedback-fields">
35
+ <legend>Leave Your Feedback</legend>
36
+
37
+ <div class="field">
38
+ <%= f.label :topic %>
39
+ <%= f.select :topic, PointlessFeedback.message_topics, { :prompt => true } %>
40
+ </div>
41
+
42
+ <div class="field">
43
+ <%= f.label :description %>
44
+ <%= f.text_area :description %>
45
+ </div>
46
+
47
+ <!-- This is a honeypot field to keep the spammers away. Do not remove. -->
48
+ <!-- If this field is filled in, feedback will not be emailed -->
49
+ <div class="contact-input" style="position: absolute; left: -9999px;">
50
+ <%= f.text_field :contact_info %>
51
+ </div>
52
+ <!-- End of honeypot field -->
53
+
54
+ </fieldset>
55
+
56
+ <%= f.submit 'Submit' %>
57
+ <% end %>
@@ -0,0 +1 @@
1
+ en:
data/config/routes.rb ADDED
@@ -0,0 +1,5 @@
1
+ PointlessFeedback::Engine.routes.draw do
2
+ root :to => 'messages#new'
3
+
4
+ resources :messages, :only => [:new, :create]
5
+ end
@@ -0,0 +1,12 @@
1
+ class CreatePointlessFeedbackMessages < ActiveRecord::Migration
2
+ def change
3
+ create_table :pointless_feedback_messages do |t|
4
+ t.string :name
5
+ t.string :email_address
6
+ t.string :topic
7
+ t.text :description
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ module PointlessFeedback
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path("../../templates", __FILE__)
5
+
6
+ desc "Creates a PointlessFeedback initializer for your application."
7
+
8
+ def copy_initializer
9
+ template "pointless_feedback.rb", "config/initializers/pointless_feedback.rb"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,16 @@
1
+ module PointlessFeedback
2
+ module Generators
3
+ class ViewsGenerator < Rails::Generators::Base
4
+ desc "Copies Pointless Feedback views to your application."
5
+ source_root File.expand_path("../../../../app/views/pointless_feedback", __FILE__)
6
+
7
+ public_task :copy_views
8
+
9
+ def copy_views
10
+ directory 'messages', 'app/views/pointless_feedback/messages' do |content|
11
+ content
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,13 @@
1
+ PointlessFeedback.setup do |config|
2
+ # ==> Message Configuration
3
+ # Configure the topics for the user to choose from on the feedback form
4
+ # config.message_topics = ['Error on page', 'Other']
5
+
6
+ # ==> Email Configuration
7
+ # Configure feedback email properties (disabled by default)
8
+ # Variables needed for emailing feedback
9
+ config.email_feedback = false
10
+ # config.from_email = 'feedback@pointlesscorp.com'
11
+ # config.to_emails = ['first@example.com', 'second@example.com']
12
+
13
+ end
@@ -0,0 +1,10 @@
1
+ module PointlessFeedback
2
+ module Controllers
3
+ # Those helpers are convenience methods added to ApplicationController.
4
+ module Helpers
5
+ def after_message_create_path
6
+ main_app.respond_to?(:root_path) ? main_app.root_path : '/'
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ module PointlessFeedback
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace PointlessFeedback
4
+
5
+ initializer "pointless_feedback.controller.helpers" do
6
+ ActiveSupport.on_load(:action_controller) do
7
+ if defined?(PointlessFeedback::Controllers::Helpers)
8
+ include PointlessFeedback::Controllers::Helpers
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ module PointlessFeedback
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,32 @@
1
+ require "pointless_feedback/engine"
2
+
3
+ module PointlessFeedback
4
+ module Controllers
5
+ autoload :Helpers, 'pointless_feedback/controllers/helpers'
6
+ end
7
+
8
+ # The parent controller all PointlessFeedback controllers inherit from.
9
+ # Defaults to ApplicationController. This should be set early
10
+ # in the initialization process and should be set to a string.
11
+ mattr_accessor :parent_controller
12
+ @@parent_controller = "ApplicationController"
13
+
14
+ # Custom topics to display on message form
15
+ mattr_accessor :message_topics
16
+ @@message_topics = ['Error on page', 'Other']
17
+
18
+ # Variables needed for emailing feedback
19
+ mattr_accessor :email_feedback
20
+ @@send_emails = false
21
+ mattr_accessor :from_email
22
+ @@from_email = 'feedback@pointlesscorp.com'
23
+ mattr_accessor :to_emails
24
+ @@to_emails = ['first@example.com', 'second@example.com']
25
+
26
+ # Default way to setup PointlessFeedback. Run rails generate
27
+ # pointless_feedback_install to create a fresh initializer with all
28
+ # configuration values.
29
+ def self.setup
30
+ yield self
31
+ end
32
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :pointless_feedback do
3
+ # # Task goes here
4
+ # end