europeana-feedback-button 0.0.2

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 (77) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +13 -0
  3. data/.rspec +3 -0
  4. data/Gemfile +13 -0
  5. data/Gemfile.lock +174 -0
  6. data/LICENSE.md +119 -0
  7. data/QUICKSTART.md +30 -0
  8. data/README.md +19 -0
  9. data/Rakefile +4 -0
  10. data/app/assets/images/europeana_feedback_button/.keep +0 -0
  11. data/app/assets/javascripts/europeana_feedback_button/application.js +13 -0
  12. data/app/assets/stylesheets/europeana_feedback_button/application.css +15 -0
  13. data/app/controllers/europeana/feedback_button/application_controller.rb +7 -0
  14. data/app/controllers/europeana/feedback_button/feedback_controller.rb +26 -0
  15. data/app/helpers/europeana/feedback_button/application_helper.rb +6 -0
  16. data/app/helpers/europeana/feedback_button/feedback_helper.rb +13 -0
  17. data/app/mailers/europeana/feedback_button/feedback_mailer.rb +19 -0
  18. data/app/models/.keep +0 -0
  19. data/app/views/concerns/europeana/feedback_button/feedbackable_view.rb +20 -0
  20. data/app/views/europeana/feedback_button/feedback_mailer/post.text.erb +5 -0
  21. data/app/views/layouts/europeana/feedback_button/application.html.erb +14 -0
  22. data/bin/rails +12 -0
  23. data/config/initializers/action_mailer.rb +1 -0
  24. data/config/routes.rb +3 -0
  25. data/europeana-feedback-button.gemspec +29 -0
  26. data/lib/europeana/feedback_button.rb +7 -0
  27. data/lib/europeana/feedback_button/engine.rb +18 -0
  28. data/lib/europeana/feedback_button/version.rb +5 -0
  29. data/lib/tasks/europeana_feedback_button_tasks.rake +4 -0
  30. data/spec/controllers/feedback_controller_spec.rb +39 -0
  31. data/spec/dummy/README.rdoc +28 -0
  32. data/spec/dummy/Rakefile +6 -0
  33. data/spec/dummy/app/assets/images/.keep +0 -0
  34. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  35. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  36. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  37. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  38. data/spec/dummy/app/controllers/welcome_controller.rb +9 -0
  39. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  40. data/spec/dummy/app/mailers/.keep +0 -0
  41. data/spec/dummy/app/mailers/application_mailer.rb +4 -0
  42. data/spec/dummy/app/models/.keep +0 -0
  43. data/spec/dummy/app/models/concerns/.keep +0 -0
  44. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  45. data/spec/dummy/app/views/layouts/mailer.html.erb +9 -0
  46. data/spec/dummy/bin/bundle +3 -0
  47. data/spec/dummy/bin/rails +4 -0
  48. data/spec/dummy/bin/rake +4 -0
  49. data/spec/dummy/bin/setup +29 -0
  50. data/spec/dummy/config.ru +4 -0
  51. data/spec/dummy/config/application.rb +31 -0
  52. data/spec/dummy/config/boot.rb +5 -0
  53. data/spec/dummy/config/database.yml +25 -0
  54. data/spec/dummy/config/environment.rb +5 -0
  55. data/spec/dummy/config/environments/development.rb +41 -0
  56. data/spec/dummy/config/environments/production.rb +79 -0
  57. data/spec/dummy/config/environments/test.rb +42 -0
  58. data/spec/dummy/config/initializers/assets.rb +11 -0
  59. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  60. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  61. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  62. data/spec/dummy/config/initializers/inflections.rb +16 -0
  63. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  64. data/spec/dummy/config/initializers/session_store.rb +3 -0
  65. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  66. data/spec/dummy/config/locales/en.yml +23 -0
  67. data/spec/dummy/config/routes.rb +60 -0
  68. data/spec/dummy/config/secrets.yml +22 -0
  69. data/spec/dummy/lib/assets/.keep +0 -0
  70. data/spec/dummy/log/.keep +0 -0
  71. data/spec/dummy/public/404.html +67 -0
  72. data/spec/dummy/public/422.html +67 -0
  73. data/spec/dummy/public/500.html +66 -0
  74. data/spec/dummy/public/favicon.ico +0 -0
  75. data/spec/helpers/feedback_helper_spec.rb +0 -0
  76. data/spec/spec_helper.rb +22 -0
  77. metadata +257 -0
@@ -0,0 +1,6 @@
1
+ module Europeana
2
+ module FeedbackButton
3
+ module ApplicationHelper
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+ module Europeana
3
+ module FeedbackButton
4
+ ##
5
+ # Methods used by feedback controller and views
6
+ module FeedbackHelper
7
+ def feedback_enabled?
8
+ Rails.application.config.x.feedback_mail_to.present?
9
+ end
10
+ end
11
+ end
12
+ end
13
+
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+ module Europeana
3
+ module FeedbackButton
4
+ class FeedbackMailer < ApplicationMailer
5
+ include FeedbackHelper
6
+
7
+ def post(text:, type:, page:, ip:)
8
+ fail Errors::NoRecipient unless feedback_enabled?
9
+
10
+ @text = text
11
+ @type = type
12
+ @page = page
13
+ @ip = ip
14
+
15
+ mail(to: Rails.application.config.x.feedback_mail_to, subject: 'User feedback')
16
+ end
17
+ end
18
+ end
19
+ end
File without changes
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Europeana
4
+ module FeedbackButton
5
+ ##
6
+ # Feedback form display methods
7
+ module FeedbackableView
8
+ extend ActiveSupport::Concern
9
+
10
+ def feedback
11
+ return nil unless feedback_enabled?
12
+ {
13
+ form_action: europeana_feedback_button.feedback_path,
14
+ maxlength: 400,
15
+ minwords: 5
16
+ }
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,5 @@
1
+ IP: <%= @ip %>
2
+ Type: <%= @type %>
3
+ URL: <%= @page %>
4
+ Text:
5
+ <%= @text %>
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>EuropeanaFeedbackButton</title>
5
+ <%= stylesheet_link_tag "europeana/feedback_button/application", media: "all" %>
6
+ <%= javascript_include_tag "europeana/feedback_button/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
3
+
4
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
5
+ ENGINE_PATH = File.expand_path('../../lib/europeana/feedback_button/engine', __FILE__)
6
+
7
+ # Set up gems listed in the Gemfile.
8
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
9
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
10
+
11
+ require 'rails/all'
12
+ require 'rails/engine/commands'
@@ -0,0 +1 @@
1
+ Rails.application.config.x.feedback_mail_to = ENV['FEEDBACK_MAIL_TO']
@@ -0,0 +1,3 @@
1
+ Europeana::FeedbackButton::Engine.routes.draw do
2
+ post 'feedback', to: 'feedback#create', defaults: { format: 'json' }
3
+ end
@@ -0,0 +1,29 @@
1
+ #lib = File.expand_path('../lib', __FILE__)
2
+ #$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ $:.push File.expand_path("../lib", __FILE__)
5
+
6
+ require "europeana/feedback_button/version"
7
+
8
+ Gem::Specification.new do |s|
9
+ s.name = "europeana-feedback-button"
10
+ s.version = Europeana::FeedbackButton::VERSION
11
+ s.authors = ["Lutz Biedinger"]
12
+ s.email = ["lutz.biedinger@gmail.com"]
13
+ s.homepage = "http://github.org/europeana/europeana-feedback-button"
14
+ s.summary = "Europeana Feedback Button."
15
+ s.description = "An engine which allows the Europeana Feedback Button to be displayed."
16
+ s.license = 'EUPL-1.1'
17
+
18
+ s.files = `git ls-files -z`.split("\x0")
19
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
20
+ s.require_paths = ['lib']
21
+
22
+ s.add_dependency 'rails', '~> 4.2', '>= 4.2.7.1'
23
+
24
+ s.add_development_dependency 'bundler', '~> 1.8'
25
+ s.add_development_dependency 'rake', '~> 11.0'
26
+ s.add_development_dependency 'rspec-rails', '~> 3.0'
27
+ s.add_development_dependency 'dotenv-rails', '~> 2.1'
28
+ s.add_development_dependency 'shoulda-matchers', '~> 2.8'
29
+ end
@@ -0,0 +1,7 @@
1
+ require 'europeana/feedback_button/engine'
2
+
3
+ module Europeana
4
+ module FeedbackButton
5
+ autoload :FeedbackableView, 'europeana/feedback_button/feedbackable_view'
6
+ end
7
+ end
@@ -0,0 +1,18 @@
1
+ module Europeana
2
+ module FeedbackButton
3
+ class Engine < ::Rails::Engine
4
+ isolate_namespace Europeana::FeedbackButton
5
+
6
+ engine_name 'europeana_feedback_button'
7
+
8
+ config.generators do |g|
9
+ g.test_framework :rspec
10
+ end
11
+
12
+ config.autoload_paths += %W(
13
+ #{config.root}/app/views/concerns
14
+ #{config.root}/app/views/layouts
15
+ )
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,5 @@
1
+ module Europeana
2
+ module FeedbackButton
3
+ VERSION = "0.0.2"
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ # desc "runs rspec tests"
2
+ # task :europeana-feedback-button do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,39 @@
1
+ RSpec.describe Europeana::FeedbackButton::FeedbackController do
2
+ def main_app
3
+ Rails.application.class.routes.url_helpers
4
+ end
5
+
6
+ routes { Europeana::FeedbackButton::Engine.routes }
7
+
8
+ describe 'POST create' do
9
+ let(:params) { { locale: 'en', type: 'comment', text: 'This is good, five words!', url: main_app.root_path(locale: 'en'), format: :json } }
10
+ subject { post :create, params }
11
+
12
+ context 'with recipient configured' do
13
+ before do
14
+ Rails.application.config.x.feedback_mail_to = 'feedback@example.com'
15
+ end
16
+
17
+ it "should queue an email job" do
18
+ expect { subject }.to change(ActionMailer::Base.deliveries, :length)
19
+ end
20
+ #it '' do
21
+ # message_delivery = instance_double(ActionMailer::MessageDelivery)
22
+ # expect(ServiceMailer).to receive(:new_user).with(@user).and_return(message_delivery)
23
+ # expect(message_delivery).to receive(:deliver_later)
24
+ # subject
25
+ #expect { subject }.to change { Delayed::Job.where("handler LIKE '%FeedbackMailer%'").count }.by(1)
26
+ #end
27
+ end
28
+
29
+ context 'without recipient configured' do
30
+ before do
31
+ Rails.application.config.x.feedback_mail_to = nil
32
+ end
33
+
34
+ it 'should not queue an email job' do
35
+ expect { subject }.to_not change(ActionMailer::Base.deliveries, :length)
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
File without changes
@@ -0,0 +1,13 @@
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 any plugin's vendor/assets/javascripts directory 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
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,15 @@
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 any plugin's vendor/assets/stylesheets directory 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 bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
@@ -0,0 +1,9 @@
1
+ ##
2
+ # Static pages controller
3
+ class WellcomeController < ApplicationController
4
+
5
+ def index
6
+
7
+ end
8
+
9
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
File without changes
@@ -0,0 +1,4 @@
1
+ class ApplicationMailer < ActionMailer::Base
2
+ default from: 'from@exmaple.com'
3
+ layout 'mailer'
4
+ end
File without changes
File without changes
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,9 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
5
+ </head>
6
+ <body>
7
+ <%= yield %>
8
+ </body>
9
+ </html>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+
4
+ # path to your application root.
5
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6
+
7
+ Dir.chdir APP_ROOT do
8
+ # This script is a starting point to setup your application.
9
+ # Add necessary setup steps to this file:
10
+
11
+ puts "== Installing dependencies =="
12
+ system "gem install bundler --conservative"
13
+ system "bundle check || bundle install"
14
+
15
+ # puts "\n== Copying sample files =="
16
+ # unless File.exist?("config/database.yml")
17
+ # system "cp config/database.yml.sample config/database.yml"
18
+ # end
19
+
20
+ puts "\n== Preparing database =="
21
+ system "bin/rake db:setup"
22
+
23
+ puts "\n== Removing old logs and tempfiles =="
24
+ system "rm -f log/*"
25
+ system "rm -rf tmp/cache"
26
+
27
+ puts "\n== Restarting application server =="
28
+ system "touch tmp/restart.txt"
29
+ end
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Rails.application
@@ -0,0 +1,31 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ # Pick the frameworks you want:
4
+ require 'active_record/railtie'
5
+ require 'action_controller/railtie'
6
+ require 'action_mailer/railtie'
7
+ require 'action_view/railtie'
8
+ require 'sprockets/railtie'
9
+ # require 'rails/test_unit/railtie'
10
+
11
+ Bundler.require(*Rails.groups)
12
+ require 'europeana/feedback_button'
13
+
14
+ module Dummy
15
+ class Application < Rails::Application
16
+ # Settings in config/environments/* take precedence over those specified here.
17
+ # Application configuration should go into files in config/initializers
18
+ # -- all .rb files in that directory are automatically loaded.
19
+
20
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
21
+ # Run 'rake -D time' for a list of tasks for finding time zone names. Default is UTC.
22
+ # config.time_zone = 'Central Time (US & Canada)'
23
+
24
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
25
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
26
+ # config.i18n.default_locale = :de
27
+
28
+ # Do not swallow errors in after_commit/after_rollback callbacks.
29
+ # config.active_record.raise_in_transactional_callbacks = true
30
+ end
31
+ end
@@ -0,0 +1,5 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5
+ $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)