ecm_contact2 4.0.2 → 5.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +28 -0
  4. data/Rakefile +13 -12
  5. data/app/assets/config/ecm_contact_manifest.js +2 -0
  6. data/app/assets/javascripts/ecm/contact/application/keep.js +0 -0
  7. data/app/assets/javascripts/ecm/contact/application.js +13 -0
  8. data/app/assets/stylesheets/ecm/contact/application/keep.css +0 -0
  9. data/app/assets/stylesheets/ecm/contact/application.css +15 -0
  10. data/app/controllers/ecm/contact/application_controller.rb +7 -0
  11. data/app/controllers/ecm/contact/contact_requests_controller.rb +51 -9
  12. data/app/helpers/ecm/contact/application_helper.rb +6 -0
  13. data/app/jobs/ecm/contact/application_job.rb +6 -0
  14. data/app/jobs/ecm/contact/notify_new_contact_request_job.rb +25 -0
  15. data/app/mailers/ecm/contact/application_mailer.rb +8 -0
  16. data/app/mailers/ecm/contact/contact_request_mailer.rb +31 -0
  17. data/app/models/ecm/contact/application_record.rb +7 -0
  18. data/app/models/ecm/contact/contact_request.rb +36 -0
  19. data/app/views/de.yml +47 -0
  20. data/app/views/ecm/contact/contact_request_mailer/notify.html.haml +7 -0
  21. data/app/views/ecm/contact/contact_request_mailer/notify.text.erb +5 -0
  22. data/app/views/ecm/contact/contact_requests/_form.haml +6 -0
  23. data/app/views/ecm/contact/contact_requests/_form_errors.haml +6 -0
  24. data/app/views/ecm/contact/contact_requests/new.haml +6 -0
  25. data/app/views/layouts/ecm/contact/application.html.erb +14 -0
  26. data/app/views/layouts/ecm/contact/mailer.html.erb +13 -0
  27. data/app/views/layouts/ecm/contact/mailer.text.erb +1 -0
  28. data/config/locales/de.yml +37 -35
  29. data/config/locales/en.yml +36 -34
  30. data/db/migrate/20170813142704_create_ecm_contact_contact_requests.rb +15 -0
  31. data/lib/ecm/contact/configuration.rb +1 -1
  32. data/lib/ecm/contact/engine.rb +7 -0
  33. data/lib/ecm/contact/version.rb +1 -1
  34. data/lib/ecm_contact2.rb +3 -4
  35. data/lib/generators/ecm/contact/install/templates/initializer.rb +7 -7
  36. metadata +45 -86
  37. data/README.rdoc +0 -37
  38. data/app/assets/stylesheets/ecm_contact.css +0 -19
  39. data/app/helpers/ecm/contact_helper.rb +0 -19
  40. data/app/mail_forms/ecm/contact/contact_request.rb +0 -29
  41. data/app/views/ecm/contact/contact_requests/_contact_request.erb +0 -40
  42. data/app/views/ecm/contact/contact_requests/_form.erb +0 -23
  43. data/app/views/ecm/contact/contact_requests/index.html.erb +0 -11
  44. data/app/views/mail_form/contact.erb +0 -1
  45. data/config/initializers/assets.rb +0 -1
  46. data/lib/generators/ecm/contact/locales/locales_generator.rb +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b21f9c40a67d16e198bde07233bbe654877f47f
4
- data.tar.gz: 170731c1bef3497718826c1cfdbf54792928c0b1
3
+ metadata.gz: d7dc9e1f9ccc5505944a124cb9dd010f12f182fa
4
+ data.tar.gz: 1074f2dc531272031fb29549e5363f2fc69341fe
5
5
  SHA512:
6
- metadata.gz: 290355612788ec2f6f537ab88d87d2051819ec821819c2d9df3cf42856563ee24bb5c37ca09230f26db63ffdf848e631f31a7bb75cf4557b76b1770b93ac1994
7
- data.tar.gz: 2b58fe34085a24b3899a87685310337526a896c2b4363010d0ba2096fecc63d58771cdd0ff9a7780f45e263f6f90811d4711d3c1e7798c697f91dcaf1f6b2b20
6
+ metadata.gz: 5d2493c48949ed18d74e7abef9f4247adf7d6059ad68e173452badcbc20d719a7b68ede2342ed0f6a4b82966d3ec3cede7bc92265d1ea1655b2e9f6f7c570494
7
+ data.tar.gz: 7af4b4ecea5f8b35a0f89d66f6b7de70b9a05e085fb765a1bb38764528475db2038c457bdc0e593687eb2eac9cc284ce45c74448491261abef6f2a883ee1fd4e
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2015 Roberto Vásquez Angel
1
+ Copyright 2017 Roberto Vasquez Angel
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # Ecm::Contact
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'ecm_contact'
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install ecm_contact
22
+ ```
23
+
24
+ ## Contributing
25
+ Contribution directions go here.
26
+
27
+ ## License
28
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile CHANGED
@@ -1,25 +1,26 @@
1
- #!/usr/bin/env rake
2
1
  begin
3
2
  require 'bundler/setup'
4
3
  rescue LoadError
5
4
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
5
  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
6
+
7
+ require 'rdoc/task'
14
8
 
15
9
  RDoc::Task.new(:rdoc) do |rdoc|
16
10
  rdoc.rdoc_dir = 'rdoc'
17
- rdoc.title = 'ECM Contact 2'
11
+ rdoc.title = 'Ecm::Contact'
18
12
  rdoc.options << '--line-numbers'
19
- rdoc.rdoc_files.include('README.rdoc')
13
+ rdoc.rdoc_files.include('README.md')
20
14
  rdoc.rdoc_files.include('lib/**/*.rb')
21
15
  end
22
16
 
23
- Bundler::GemHelper.install_tasks
17
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+ load 'rails/tasks/statistics.rake'
22
+
23
+
24
+
25
+ require 'bundler/gem_tasks'
24
26
 
25
- require 'rails/dummy/tasks'
@@ -0,0 +1,2 @@
1
+ //= link_directory ../javascripts/ecm/contact .js
2
+ //= link_directory ../stylesheets/ecm/contact .css
@@ -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. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree ./application
@@ -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 other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree ./application
14
+ *= require_self
15
+ */
@@ -0,0 +1,7 @@
1
+ module Ecm
2
+ module Contact
3
+ class ApplicationController < ActionController::Base
4
+ protect_from_forgery with: :exception
5
+ end
6
+ end
7
+ end
@@ -1,31 +1,73 @@
1
1
  module Ecm
2
2
  module Contact
3
3
  class ContactRequestsController < Ecm::Contact::Configuration.base_controller.constantize
4
+ before_action :initialize_resource, only: [:index, :new]
5
+ before_action :initialize_resource_for_create, only: [:create]
6
+
7
+ respond_to :html
8
+ responders :flash
9
+
10
+ def self.resource_class
11
+ Ecm::Contact::ContactRequest
12
+ end
13
+
4
14
  def index
5
- @title = I18n.t('ecm.contact.request.index.title')
6
- @contact_request = ContactRequest.new
15
+ new
16
+ render :new
7
17
  end
8
18
 
9
- def create
10
- @title = I18n.t('ecm.contact.request.index.title')
11
- @contact_request = ContactRequest.new(permitted_params)
19
+ def new; end
12
20
 
13
- if @contact_request.deliver
14
- redirect_to(after_create_url, notice: -> { I18n.t('ecm.contact.form.messages.delivered') }.call)
21
+ def create
22
+ @resource.ip_address = request.remote_ip
23
+ if @resource.save
24
+ respond_with @resource, location: after_create_url
15
25
  else
16
- render :index
26
+ respond_with @resource
17
27
  end
18
28
  end
19
29
 
20
30
  private
21
31
 
32
+ def initialize_resource_for_create
33
+ @resource = initialize_scope.new(permitted_params)
34
+ end
35
+
36
+ def initialize_resource
37
+ @resource = initialize_scope.new
38
+ end
39
+
40
+ def initialize_scope
41
+ resource_class
42
+ end
43
+
44
+ def resource_class
45
+ self.class.resource_class
46
+ end
47
+
22
48
  def permitted_params
23
- params.require(:contact_request).permit(:nickname, :name, :email, :phone, :message, :terms_of_service)
49
+ params.require(:contact_request).permit(:nickname, :name, :email, :phone, :message, :accept_terms_of_service)
24
50
  end
25
51
 
26
52
  def after_create_url
27
53
  Ecm::Contact::Configuration.after_create_url.call(self)
28
54
  end
55
+
56
+ # def index
57
+ # @title = I18n.t('ecm.contact.request.index.title')
58
+ # @contact_request = ContactRequest.new
59
+ # end
60
+
61
+ # def create
62
+ # @title = I18n.t('ecm.contact.request.index.title')
63
+ # @contact_request = ContactRequest.new(permitted_params)
64
+
65
+ # if @contact_request.deliver
66
+ # redirect_to(after_create_url, notice: -> { I18n.t('ecm.contact.form.messages.delivered') }.call)
67
+ # else
68
+ # render :index
69
+ # end
70
+ # end
29
71
  end
30
72
  end
31
73
  end
@@ -0,0 +1,6 @@
1
+ module Ecm
2
+ module Contact
3
+ module ApplicationHelper
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Ecm
2
+ module Contact
3
+ class ApplicationJob < ActiveJob::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,25 @@
1
+ module Ecm::Contact
2
+ class NotifyNewContactRequestJob < ApplicationJob
3
+ queue_as :contact_requests
4
+
5
+ def perform(contact_request_id)
6
+ load_contact_request(contact_request_id)
7
+ deliver
8
+ mark_as_notified
9
+ end
10
+
11
+ private
12
+
13
+ def load_contact_request(id)
14
+ @contact_request = ContactRequest.find(id)
15
+ end
16
+
17
+ def deliver
18
+ ContactRequestMailer.notify(@contact_request).deliver_now
19
+ end
20
+
21
+ def mark_as_notified
22
+ @contact_request.update(notified_at: Time.zone.now)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,8 @@
1
+ module Ecm
2
+ module Contact
3
+ class ApplicationMailer < ActionMailer::Base
4
+ default from: 'from@example.com'
5
+ layout 'mailer'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,31 @@
1
+ module Ecm::Contact
2
+ class ContactRequestMailer < ApplicationMailer
3
+
4
+ # Subject can be set in your I18n file at config/locales/en.yml
5
+ # with the following lookup:
6
+ #
7
+ # en.contact_request_mailer.notify.subject
8
+ #
9
+ def notify(contact_request)
10
+ @contact_request = contact_request
11
+
12
+ mail to: notification_recipients,
13
+ from: notification_sender(contact_request),
14
+ subject: notification_subject
15
+ end
16
+
17
+ private
18
+
19
+ def notification_subject
20
+ default_i18n_subject(application_name: Rails.application.class.to_s.split('::').first.underscore.humanize.titleize)
21
+ end
22
+
23
+ def notification_sender(contact_request)
24
+ "#{contact_request.name} <#{contact_request.email}>"
25
+ end
26
+
27
+ def notification_recipients
28
+ Ecm::Contact::Configuration.recipients[Rails.env]
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,7 @@
1
+ module Ecm
2
+ module Contact
3
+ class ApplicationRecord < ActiveRecord::Base
4
+ self.abstract_class = true
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,36 @@
1
+ module Ecm::Contact
2
+ class ContactRequest < ApplicationRecord
3
+ validates :name, presence: true
4
+ validates :email, presence: true
5
+ validates :phone, presence: true
6
+ validates :ip_address, presence: true
7
+ validates :message, presence: true
8
+ validates :accept_terms_of_service, acceptance: true
9
+
10
+ module SpamProtection
11
+ attr_accessor :nickname
12
+
13
+ def save
14
+ if nickname.present?
15
+ valid?
16
+ return true
17
+ else
18
+ super
19
+ end
20
+ end
21
+ end
22
+
23
+ module Notification
24
+ def self.included(base)
25
+ base.after_save :notify, if: -> { notified_at.nil? }
26
+ end
27
+
28
+ def notify
29
+ NotifyNewContactRequestJob.perform_later(id)
30
+ end
31
+ end
32
+
33
+ prepend SpamProtection
34
+ include Notification
35
+ end
36
+ end
data/app/views/de.yml ADDED
@@ -0,0 +1,47 @@
1
+ de:
2
+ ecm:
3
+ contact:
4
+ form:
5
+ messages:
6
+ delivered: "Ihre Kontaktanfrage wurde versandt."
7
+ contact_request:
8
+ index:
9
+ page_title: Kontaktanfrage
10
+ meta_description: Kontaktieren Sie uns über unser Kontaktformular
11
+ title: Kontaktanfrage
12
+ contact_requests:
13
+ form:
14
+ submit: Abschicken
15
+ request:
16
+ subject: "[%{application_name}] Neue Kontaktanfrage"
17
+ views:
18
+ actions:
19
+ back: 'Zurück'
20
+ routes:
21
+ ecm_contact_engine: kontakt
22
+ # ecm_contact: kontakt
23
+ contact_requests: anfrage
24
+ simple_form:
25
+ "yes": 'Ja'
26
+ "no": 'Nein'
27
+ required:
28
+ text: 'Pflichtfeld'
29
+ mark: '*'
30
+ placeholders:
31
+ contact_request:
32
+ name: "Max Mustermann"
33
+ email: "max.mustermann@example.com"
34
+ message: "Hi Dave..."
35
+ phone: "+49 69 12345678"
36
+ mail_form:
37
+ models:
38
+ ecm/contact/contact_request: Kontaktanfrage
39
+ attributes:
40
+ ecm/contact/contact_request:
41
+ email: E-Mail
42
+ name: Name
43
+ message: Nachricht
44
+ phone: Telefon
45
+ accept_terms_of_service: Hiermit erlaube ich dem Seitenbetreiber die Nutzung meiner Daten zwecks Beantwortung dieser Kontaktanfrage.
46
+ contact_request:
47
+ title: "Kontaktanfrage"
@@ -0,0 +1,7 @@
1
+ %h1= t('.title')
2
+
3
+ %ul
4
+ - @contact_request.attributes.each do |attribute, value|
5
+ %li
6
+ %span.key= @contact_request.class.human_attribute_name(attribute)
7
+ %span.value= value
@@ -0,0 +1,5 @@
1
+ <%= t('.title') %>
2
+
3
+ <% @contact_request.attributes.each do |attribute, value| %>
4
+ <%= @contact_request.class.human_attribute_name(attribute) %>: <%= value %>
5
+ <% end %>
@@ -0,0 +1,6 @@
1
+ = form.input :name
2
+ = form.input :email
3
+ = form.input :nickname, input_html: { style: 'display: none;' }, label_html: { style: 'display: none;' }
4
+ = form.input :phone
5
+ = form.input :message, as: :text
6
+ = form.input :accept_terms_of_service
@@ -0,0 +1,6 @@
1
+ - if resource.errors.any?
2
+ .error-explanation.alert.alert-danger
3
+ .error-heading= t('errors.template.header', count: resource.errors.count, model: resource.model_name.human)
4
+ %ul
5
+ - resource.errors.full_messages.each do |msg|
6
+ %li= msg
@@ -0,0 +1,6 @@
1
+ %h1= t('.title')
2
+
3
+ = simple_form_for(@resource) do |f|
4
+ = render 'form_errors', resource: f.object
5
+ = render 'form', form: f
6
+ = f.submit class: 'btn btn-primary'
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Ecm contact</title>
5
+ <%= stylesheet_link_tag "ecm/contact/application", media: "all" %>
6
+ <%= javascript_include_tag "ecm/contact/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <style>
6
+ /* Email styles need to be inline */
7
+ </style>
8
+ </head>
9
+
10
+ <body>
11
+ <%= yield %>
12
+ </body>
13
+ </html>
@@ -0,0 +1 @@
1
+ <%= yield %>
@@ -1,47 +1,49 @@
1
1
  de:
2
+ classes:
3
+ ecm/contact/engine: Kontakt
4
+ activerecord:
5
+ models:
6
+ ecm/contact/contact_request:
7
+ one: Kontaktanfrage
8
+ other: Kontaktanfragen
9
+ attributes:
10
+ ecm/contact/contact_request:
11
+ accept_terms_of_service: 'Hiermit erlaube ich dem Seitenbetreiber die Nutzung meiner Daten zwecks Beantwortung dieser Kontaktanfrage.'
12
+ name: Name
13
+ email: E-Mail
14
+ phone: Telefonnummer
15
+ ip_address: IP Adresse
16
+ message: Nachricht
17
+ notified_at: Benachrichtigt am
18
+ created_at: Erstellt am
19
+ updated_at: Aktualisiert am
20
+ additional_actions: Zusatzliche Aktionen
2
21
  ecm:
3
22
  contact:
4
- form:
5
- messages:
6
- delivered: "Ihre Kontaktanfrage wurde versandt."
7
- contact_request:
8
- index:
9
- page_title: Kontaktanfrage
10
- meta_description: Kontaktieren Sie uns über unser Kontaktformular
11
- title: Kontaktanfrage
12
23
  contact_requests:
13
- form:
14
- submit: Abschicken
15
- request:
16
- subject: "[%{application_name}] Neue Kontaktanfrage"
17
- views:
18
- actions:
19
- back: 'Zurück'
24
+ new:
25
+ title: "Kontaktanfrage"
26
+ contact_request_mailer:
27
+ notify:
28
+ subject: "[%{application_name}] Neue Kontaktanfrage"
29
+ title: "Neue Kontaktanfrage"
30
+ flash:
31
+ ecm:
32
+ contact:
33
+ contact_requests:
34
+ create:
35
+ notice: "Ihre Kontaktanfrage wurde versandt."
36
+ helpers:
37
+ submit:
38
+ contact_request:
39
+ create: Absenden
20
40
  routes:
21
41
  ecm_contact_engine: kontakt
22
- # ecm_contact: kontakt
23
42
  contact_requests: anfrage
24
43
  simple_form:
25
- "yes": 'Ja'
26
- "no": 'Nein'
27
- required:
28
- text: 'Pflichtfeld'
29
- mark: '*'
30
44
  placeholders:
31
45
  contact_request:
32
46
  name: "Max Mustermann"
33
47
  email: "max.mustermann@example.com"
34
- message: "Hi Dave..."
35
- phone: "+49 69 12345678"
36
- mail_form:
37
- models:
38
- ecm/contact/contact_request: Kontaktanfrage
39
- attributes:
40
- ecm/contact/contact_request:
41
- email: E-Mail
42
- name: Name
43
- message: Nachricht
44
- phone: Telefon
45
- terms_of_service: Hiermit erlaube ich dem Seitenbetreiber die Nutzung meiner Daten zwecks Beantwortung dieser Kontaktanfrage.
46
- contact_request:
47
- title: "Kontaktanfrage"
48
+ message: "Meine Nachricht"
49
+ phone: "+49 69 12345678"
@@ -1,47 +1,49 @@
1
1
  en:
2
+ classes:
3
+ ecm/contact/engine: Contact
4
+ activerecord:
5
+ models:
6
+ ecm/contact/contact_request:
7
+ one: Contact Request
8
+ other: Contact Requests
9
+ attributes:
10
+ ecm/contact/contact_request:
11
+ accept_terms_of_service: 'I hereby allow the site owner to use my personal data for the purpose of answering this request.'
12
+ name: Name
13
+ email: E-Mail
14
+ phone: Phone
15
+ ip_address: IP Address
16
+ message: Message
17
+ notified_at: Notified at
18
+ created_at: Created at
19
+ updated_at: Updated at
20
+ additional_actions: Additional Actions
2
21
  ecm:
3
22
  contact:
4
- form:
5
- messages:
6
- delivered: "Your contact request has been delivered."
7
- contact_request:
8
- index:
9
- page_title: Contact request
10
- meta_description: Contact us
11
- title: Contact request
12
23
  contact_requests:
13
- form:
14
- submit: Submit
15
- request:
16
- subject: "[%{application_name}] New contact request"
17
- views:
18
- actions:
19
- back: 'Back'
24
+ new:
25
+ title: "Contact Request"
26
+ contact_request_mailer:
27
+ notify:
28
+ subject: "[%{application_name}] New contact request"
29
+ title: "New contact request"
30
+ flash:
31
+ ecm:
32
+ contact:
33
+ contact_requests:
34
+ create:
35
+ notice: "Your contact request has been delivered."
36
+ helpers:
37
+ submit:
38
+ contact_request:
39
+ create: Submit
20
40
  routes:
21
41
  ecm_contact_engine: contact
22
- # ecm_contact: contact
23
42
  contact_requests: request
24
43
  simple_form:
25
- "yes": 'Yes'
26
- "no": 'No'
27
- required:
28
- text: 'required'
29
- mark: '*'
30
44
  placeholders:
31
45
  contact_request:
32
46
  name: "John Doe"
33
47
  email: "john.doe@example.com"
34
48
  message: "Hi Dave..."
35
- phone: "+1-541-754-3010"
36
- mail_form:
37
- models:
38
- ecm/contact/contact_request: contact request
39
- attributes:
40
- ecm/contact/contact_request:
41
- email: email
42
- name: name
43
- message: message
44
- phone: phone
45
- terms_of_service: I hereby allow the site owner to use my personal data for the purpose of answering this request.
46
- contact_request:
47
- title: contact request
49
+ phone: "+1-541-754-3010"
@@ -0,0 +1,15 @@
1
+ class CreateEcmContactContactRequests < ActiveRecord::Migration[5.1]
2
+ def change
3
+ create_table :ecm_contact_contact_requests do |t|
4
+ t.string :name
5
+ t.string :email
6
+ t.string :phone
7
+ t.string :ip_address
8
+ t.text :message
9
+ t.boolean :accept_terms_of_service
10
+ t.timestamp :notified_at
11
+
12
+ t.timestamps
13
+ end
14
+ end
15
+ end
@@ -1,6 +1,5 @@
1
1
  require 'active_support/core_ext/module/delegation'
2
2
  require 'active_support/core_ext/module/attribute_accessors'
3
- require 'active_support/hash_with_indifferent_access'
4
3
 
5
4
  module Ecm
6
5
  module Contact
@@ -8,6 +7,7 @@ module Ecm
8
7
  def configure
9
8
  yield self
10
9
  end
10
+
11
11
  mattr_accessor :input_name_css_classes do
12
12
  'form-control'
13
13
  end
@@ -2,6 +2,13 @@ module Ecm
2
2
  module Contact
3
3
  class Engine < ::Rails::Engine
4
4
  isolate_namespace Ecm::Contact
5
+
6
+ config.generators do |g|
7
+ g.test_framework :rspec, fixture: true
8
+ g.fixture_replacement :factory_girl, dir: 'spec/factories'
9
+ # g.form_builder :simple_form
10
+ # g.template_engine :haml
11
+ end
5
12
  end
6
13
  end
7
14
  end
@@ -1,5 +1,5 @@
1
1
  module Ecm
2
2
  module Contact
3
- VERSION = '4.0.2'.freeze
3
+ VERSION = '5.0.1'
4
4
  end
5
5
  end
data/lib/ecm_contact2.rb CHANGED
@@ -1,8 +1,7 @@
1
- require 'mail_form'
2
- require 'simple_form'
1
+ require "route_translator"
3
2
 
4
- require 'ecm/contact/engine'
5
- require 'ecm/contact/configuration'
3
+ require "ecm/contact/configuration"
4
+ require "ecm/contact/engine"
6
5
 
7
6
  module Ecm
8
7
  module Contact
@@ -6,15 +6,15 @@ Ecm::Contact.configure do |config|
6
6
  # Default:
7
7
  #
8
8
  # config.recipients = {
9
- # :development => %w[ info@development.example.com ],
10
- # :test => %w[ info@test.example.com ],
11
- # :production => %w[ info@production.example.com ]
9
+ # development: %w( info@development.example.com ),
10
+ # test: %w( info@test.example.com ),
11
+ # production: %w( info@production.example.com )
12
12
  # }
13
13
  #
14
14
  config.recipients = {
15
15
  development: %w( info@development.example.com ),
16
- test: %w( info@test.example.com ),
17
- production: %w( info@production.example.com )
16
+ test: %w( info@test.example.com ),
17
+ production: %w( info@production.example.com )
18
18
  }
19
19
 
20
20
  # Configure your input field css classes here.
@@ -71,9 +71,9 @@ Ecm::Contact.configure do |config|
71
71
 
72
72
  # url to redirect to after successful contact request.
73
73
  #
74
- # default: config.after_create_url = ->(controller) { controller.url_for(action: index) }
74
+ # default: config.after_create_url = ->(controller) { controller.url_for(action: :index) }
75
75
  #
76
- config.after_create_url = ->(controller) { controller.url_for(action: index) }
76
+ config.after_create_url = ->(controller) { controller.url_for(action: :index) }
77
77
 
78
78
  # Set the sender address.
79
79
  #
metadata CHANGED
@@ -1,57 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecm_contact2
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.2
4
+ version: 5.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberto Vasquez Angel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-01 00:00:00.000000000 Z
11
+ date: 2017-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '4.0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '4.0'
27
- - !ruby/object:Gem::Dependency
28
- name: mail_form
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: simple_form
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
17
+ - - "~>"
46
18
  - !ruby/object:Gem::Version
47
- version: '0'
19
+ version: 5.1.1
48
20
  type: :runtime
49
21
  prerelease: false
50
22
  version_requirements: !ruby/object:Gem::Requirement
51
23
  requirements:
52
- - - ">="
24
+ - - "~>"
53
25
  - !ruby/object:Gem::Version
54
- version: '0'
26
+ version: 5.1.1
55
27
  - !ruby/object:Gem::Dependency
56
28
  name: route_translator
57
29
  requirement: !ruby/object:Gem::Requirement
@@ -59,7 +31,7 @@ dependencies:
59
31
  - - ">="
60
32
  - !ruby/object:Gem::Version
61
33
  version: '0'
62
- type: :development
34
+ type: :runtime
63
35
  prerelease: false
64
36
  version_requirements: !ruby/object:Gem::Requirement
65
37
  requirements:
@@ -67,7 +39,7 @@ dependencies:
67
39
  - !ruby/object:Gem::Version
68
40
  version: '0'
69
41
  - !ruby/object:Gem::Dependency
70
- name: thin
42
+ name: sqlite3
71
43
  requirement: !ruby/object:Gem::Requirement
72
44
  requirements:
73
45
  - - ">="
@@ -81,7 +53,7 @@ dependencies:
81
53
  - !ruby/object:Gem::Version
82
54
  version: '0'
83
55
  - !ruby/object:Gem::Dependency
84
- name: rails-dummy
56
+ name: capybara
85
57
  requirement: !ruby/object:Gem::Requirement
86
58
  requirements:
87
59
  - - ">="
@@ -95,7 +67,7 @@ dependencies:
95
67
  - !ruby/object:Gem::Version
96
68
  version: '0'
97
69
  - !ruby/object:Gem::Dependency
98
- name: therubyracer
70
+ name: factory_girl_rails
99
71
  requirement: !ruby/object:Gem::Requirement
100
72
  requirements:
101
73
  - - ">="
@@ -109,7 +81,7 @@ dependencies:
109
81
  - !ruby/object:Gem::Version
110
82
  version: '0'
111
83
  - !ruby/object:Gem::Dependency
112
- name: less-rails
84
+ name: guard-bundler
113
85
  requirement: !ruby/object:Gem::Requirement
114
86
  requirements:
115
87
  - - ">="
@@ -123,7 +95,7 @@ dependencies:
123
95
  - !ruby/object:Gem::Version
124
96
  version: '0'
125
97
  - !ruby/object:Gem::Dependency
126
- name: twitter-bootstrap-rails
98
+ name: guard-rspec
127
99
  requirement: !ruby/object:Gem::Requirement
128
100
  requirements:
129
101
  - - ">="
@@ -137,7 +109,7 @@ dependencies:
137
109
  - !ruby/object:Gem::Version
138
110
  version: '0'
139
111
  - !ruby/object:Gem::Dependency
140
- name: sqlite3
112
+ name: i18n-debug
141
113
  requirement: !ruby/object:Gem::Requirement
142
114
  requirements:
143
115
  - - ">="
@@ -151,7 +123,7 @@ dependencies:
151
123
  - !ruby/object:Gem::Version
152
124
  version: '0'
153
125
  - !ruby/object:Gem::Dependency
154
- name: yard
126
+ name: launchy
155
127
  requirement: !ruby/object:Gem::Requirement
156
128
  requirements:
157
129
  - - ">="
@@ -165,7 +137,7 @@ dependencies:
165
137
  - !ruby/object:Gem::Version
166
138
  version: '0'
167
139
  - !ruby/object:Gem::Dependency
168
- name: capybara
140
+ name: pry-rails
169
141
  requirement: !ruby/object:Gem::Requirement
170
142
  requirements:
171
143
  - - ">="
@@ -193,21 +165,7 @@ dependencies:
193
165
  - !ruby/object:Gem::Version
194
166
  version: '0'
195
167
  - !ruby/object:Gem::Dependency
196
- name: shoulda-matchers
197
- requirement: !ruby/object:Gem::Requirement
198
- requirements:
199
- - - "~>"
200
- - !ruby/object:Gem::Version
201
- version: 2.8.0
202
- type: :development
203
- prerelease: false
204
- version_requirements: !ruby/object:Gem::Requirement
205
- requirements:
206
- - - "~>"
207
- - !ruby/object:Gem::Version
208
- version: 2.8.0
209
- - !ruby/object:Gem::Dependency
210
- name: guard-rails
168
+ name: rubocop
211
169
  requirement: !ruby/object:Gem::Requirement
212
170
  requirements:
213
171
  - - ">="
@@ -221,21 +179,7 @@ dependencies:
221
179
  - !ruby/object:Gem::Version
222
180
  version: '0'
223
181
  - !ruby/object:Gem::Dependency
224
- name: guard-rspec
225
- requirement: !ruby/object:Gem::Requirement
226
- requirements:
227
- - - ">="
228
- - !ruby/object:Gem::Version
229
- version: '0'
230
- type: :development
231
- prerelease: false
232
- version_requirements: !ruby/object:Gem::Requirement
233
- requirements:
234
- - - ">="
235
- - !ruby/object:Gem::Version
236
- version: '0'
237
- - !ruby/object:Gem::Dependency
238
- name: guard-bundler
182
+ name: shoulda-matchers
239
183
  requirement: !ruby/object:Gem::Requirement
240
184
  requirements:
241
185
  - - ">="
@@ -248,7 +192,7 @@ dependencies:
248
192
  - - ">="
249
193
  - !ruby/object:Gem::Version
250
194
  version: '0'
251
- description: Basic contact form.
195
+ description:
252
196
  email:
253
197
  - roberto@vasquez-angel.de
254
198
  executables: []
@@ -256,20 +200,35 @@ extensions: []
256
200
  extra_rdoc_files: []
257
201
  files:
258
202
  - MIT-LICENSE
259
- - README.rdoc
203
+ - README.md
260
204
  - Rakefile
261
- - app/assets/stylesheets/ecm_contact.css
205
+ - app/assets/config/ecm_contact_manifest.js
206
+ - app/assets/javascripts/ecm/contact/application.js
207
+ - app/assets/javascripts/ecm/contact/application/keep.js
208
+ - app/assets/stylesheets/ecm/contact/application.css
209
+ - app/assets/stylesheets/ecm/contact/application/keep.css
210
+ - app/controllers/ecm/contact/application_controller.rb
262
211
  - app/controllers/ecm/contact/contact_requests_controller.rb
263
- - app/helpers/ecm/contact_helper.rb
264
- - app/mail_forms/ecm/contact/contact_request.rb
265
- - app/views/ecm/contact/contact_requests/_contact_request.erb
266
- - app/views/ecm/contact/contact_requests/_form.erb
267
- - app/views/ecm/contact/contact_requests/index.html.erb
268
- - app/views/mail_form/contact.erb
269
- - config/initializers/assets.rb
212
+ - app/helpers/ecm/contact/application_helper.rb
213
+ - app/jobs/ecm/contact/application_job.rb
214
+ - app/jobs/ecm/contact/notify_new_contact_request_job.rb
215
+ - app/mailers/ecm/contact/application_mailer.rb
216
+ - app/mailers/ecm/contact/contact_request_mailer.rb
217
+ - app/models/ecm/contact/application_record.rb
218
+ - app/models/ecm/contact/contact_request.rb
219
+ - app/views/de.yml
220
+ - app/views/ecm/contact/contact_request_mailer/notify.html.haml
221
+ - app/views/ecm/contact/contact_request_mailer/notify.text.erb
222
+ - app/views/ecm/contact/contact_requests/_form.haml
223
+ - app/views/ecm/contact/contact_requests/_form_errors.haml
224
+ - app/views/ecm/contact/contact_requests/new.haml
225
+ - app/views/layouts/ecm/contact/application.html.erb
226
+ - app/views/layouts/ecm/contact/mailer.html.erb
227
+ - app/views/layouts/ecm/contact/mailer.text.erb
270
228
  - config/locales/de.yml
271
229
  - config/locales/en.yml
272
230
  - config/routes.rb
231
+ - db/migrate/20170813142704_create_ecm_contact_contact_requests.rb
273
232
  - lib/ecm/contact/configuration.rb
274
233
  - lib/ecm/contact/engine.rb
275
234
  - lib/ecm/contact/version.rb
@@ -277,10 +236,10 @@ files:
277
236
  - lib/generators/ecm/contact/install/install_generator.rb
278
237
  - lib/generators/ecm/contact/install/templates/initializer.rb
279
238
  - lib/generators/ecm/contact/install/templates/routes.source
280
- - lib/generators/ecm/contact/locales/locales_generator.rb
281
239
  - lib/tasks/ecm_contact_tasks.rake
282
240
  homepage: https://github.com/robotex82/ecm_contact2
283
- licenses: []
241
+ licenses:
242
+ - MIT
284
243
  metadata: {}
285
244
  post_install_message:
286
245
  rdoc_options: []
@@ -301,5 +260,5 @@ rubyforge_project:
301
260
  rubygems_version: 2.6.11
302
261
  signing_key:
303
262
  specification_version: 4
304
- summary: Basic contact form.
263
+ summary: Ecm Contact Module.
305
264
  test_files: []
data/README.rdoc DELETED
@@ -1,37 +0,0 @@
1
- = ECM Contact 2
2
-
3
- Easy contact form for rails 4.x.
4
-
5
- = Installation
6
-
7
- Add the gem to your bundle:
8
-
9
- # Gemfile
10
- gem 'ecm_contact2'
11
-
12
- Install your bundle:
13
-
14
- > bundle install
15
-
16
- Run the generator:
17
-
18
- > rails g ecm:contact:install
19
-
20
- This will create an initializer file in config/initializers. You should configure
21
- your recipients there.
22
-
23
- Add the routes:
24
-
25
- # config/routes.rb
26
- Ecm::Contact::Routing.routes(self)
27
-
28
- Add the locale files
29
-
30
- > rails g ecm:contact:locales
31
-
32
- = Usage
33
-
34
- = License
35
-
36
- This project rocks and uses MIT-LICENSE.
37
-
@@ -1,19 +0,0 @@
1
- #new_ecm_contact_request abbr {
2
- border-bottom: 0px;
3
- }
4
-
5
- #new_ecm_contact_request #ecm_contact_request_submit span.glyphicon {
6
- margin-right: 5px;
7
- }
8
-
9
- #new_ecm_contact_request .boolean span.error {
10
- margin-left: -20px;
11
- }
12
-
13
- #new_ecm_contact_request label {
14
- font-weight: normal;
15
- }
16
-
17
- #new_ecm_contact_request span.error {
18
- color: red;
19
- }
@@ -1,19 +0,0 @@
1
- module Ecm
2
- module ContactHelper
3
- def contact_form(options = {})
4
- options.reverse_merge(form_target_url: nil)
5
- form_target_url = options[:form_target_url]
6
-
7
- form_tag_options = {}
8
- form_tag_options[:url] = form_target_url if form_target_url.present?
9
-
10
- @contact_request = Ecm::Contact::Request.new(params[:ecm_contact_request])
11
-
12
- if params[:ecm_contact_request].present? && @contact_request.deliver
13
- render 'ecm/contact/requests/form', form_tag_options: form_tag_options, notice: I18n.t('ecm.contact.form.messages.delivered')
14
- else
15
- render 'ecm/contact/requests/form', form_tag_options: form_tag_options
16
- end
17
- end
18
- end
19
- end
@@ -1,29 +0,0 @@
1
- module Ecm
2
- module Contact
3
- class ContactRequest < MailForm::Base
4
- attribute :name
5
- attribute :email
6
- attribute :phone
7
- attribute :message
8
- attribute :terms_of_service
9
- attribute :nickname, captcha: true
10
-
11
- validates :email, format: { with: /\A([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})\z/i }, presence: true # , :message => Proc.new { I18n.t("activerecord.errors.messages.invalid") }.call }
12
- validates :message, presence: true # { :message => Proc.new { I18n.t("activerecord.errors.messages.empty") }.call }
13
- validates :name, presence: true # { :message => Proc.new { I18n.t("activerecord.errors.messages.empty") }.call }
14
- validates :terms_of_service, acceptance: true # { :message => Proc.new { I18n.t("activerecord.errors.messages.accepted") }.call }
15
-
16
- # Declare the e-mail headers. It accepts anything the mail method
17
- # in ActionMailer accepts.
18
- def headers
19
- {
20
- subject: proc { I18n.t('ecm.contact.request.subject', application_name: Rails.application.class.to_s.split('::').first) }.call,
21
- # :to => I18n.t('ecm.contact.request.recipients'),
22
- to: Ecm::Contact::Configuration.recipients[Rails.env],
23
- # from: %("#{name}" <#{email}>)
24
- from: Ecm::Contact::Configuration.sender.call(self)
25
- }
26
- end
27
- end
28
- end
29
- end
@@ -1,40 +0,0 @@
1
- <h4 style="text-decoration:underline"><%= message.subject %></h4>
2
-
3
- <% @resource.mail_attributes.each do |attribute| %>
4
- <% value = @resource.send(attribute) %>
5
- <% next if value.blank? %>
6
-
7
- <p><b><%= @resource.class.human_attribute_name(attribute) %>:</b>
8
- <%= case value
9
- when /\n/
10
- raw(simple_format(h(value)))
11
- when Time, DateTime, Date
12
- I18n.l(value)
13
- else
14
- value
15
- end
16
- %></p>
17
- <% end %>
18
-
19
- <% unless @resource.class.mail_appendable.blank? %>
20
- <br /><h4 style="text-decoration:underline"><%= I18n.t :title, :scope => [ :mail_form, :request ], :default => 'Request information' %></h4>
21
-
22
- <% @resource.class.mail_appendable.each do |attribute|
23
- value = @resource.request.send(attribute)
24
-
25
- value = if value.is_a?(Hash) && !value.empty?
26
- list = value.to_a.map{ |k,v| content_tag(:li, h("#{k}: #{v.inspect}")) }.join("\n")
27
- content_tag(:ul, raw(list), :style => "list-style:none;")
28
- elsif value.is_a?(String)
29
- value
30
- else
31
- value.inspect
32
- end
33
- %>
34
-
35
- <p><b><%= I18n.t attribute, :scope => [ :mail_form, :request ], :default => attribute.to_s.humanize %>:</b>
36
- <%= value.include?("\n") ? simple_format(value) : value %></p>
37
- <% end %>
38
- <br />
39
- <% end %>
40
-
@@ -1,23 +0,0 @@
1
- <% if notice %>
2
- <div class="alert alert-success alert-dismissible">
3
- <button type="button" class="close" data-dismiss="alert" aria-label="Close">
4
- <span aria-hidden="true">&times;</span>
5
- </button>
6
- <%= notice %>
7
- </div>
8
- <% end %>
9
- <%= simple_form_for(@contact_request) do |f| %>
10
- <%= f.input :nickname, :input_html => { :style => 'display:none' }, :label_html => { :style => 'display:none' } %>
11
- <%= f.input :name, :input_html => { :class => Ecm::Contact::Configuration.input_name_css_classes } %>
12
- <%= f.input :email, :input_html => { :class => Ecm::Contact::Configuration.input_email_css_classes } %>
13
- <%= f.input :phone, :input_html => { :class => Ecm::Contact::Configuration.input_phone_css_classes } %>
14
- <%= f.input :message, :as => :text, :input_html => { :class => Ecm::Contact::Configuration.input_message_css_classes } %>
15
- <%= f.input :terms_of_service, :as => :boolean, :required => true, :input_html => { :class => Ecm::Contact::Configuration.input_terms_of_service_css_classes } %>
16
-
17
- <div class="<%= Ecm::Contact::Configuration.form_actions_wrapper_css_classes %>">
18
- <%= button_tag(:type => 'submit', :class => 'input btn btn-primary', :id => 'ecm_contact_request_submit') do %>
19
- <span class="glyphicon glyphicon-ok" aria-hidden="true"></span>
20
- <%= t('.submit', :model => f.object.class.model_name.human) %>
21
- <% end %>
22
- </div>
23
- <% end %>
@@ -1,11 +0,0 @@
1
- <% content_for :title do %><%= I18n.t('ecm.contact.request.index.page_title') %><% end %>
2
- <% content_for :meta_description do %><%= I18n.t('ecm.contact.request.index.meta_description') %><% end %>
3
- <h1><%= Ecm::Contact::ContactRequest.model_name.human %></h1>
4
-
5
- <%= Ecm::Contact::Configuration.additional_contact_information.call(self) if Ecm::Contact::Configuration.additional_contact_information.respond_to?(:call) %>
6
-
7
- <%= render 'form' %>
8
-
9
- <div class="well page-actions">
10
- <%= link_to t('ecm.contact.views.actions.back'), main_app.root_path, class: 'btn btn-default' %>
11
- </div>
@@ -1 +0,0 @@
1
- <%= render @resource %>
@@ -1 +0,0 @@
1
- Rails.application.config.assets.precompile += %w(ecm_contact.css)
@@ -1,19 +0,0 @@
1
- module Ecm
2
- module Contact
3
- module Generators
4
- class LocalesGenerator < Rails::Generators::Base
5
- desc 'Generates the locales'
6
-
7
- source_root File.expand_path('../../../../../../config/locales', __FILE__)
8
-
9
- def generate_intializer
10
- copy_file 'ecm.contact.de.yml', 'config/locales/ecm.contact.de.yml'
11
- copy_file 'ecm.contact.en.yml', 'config/locales/ecm.contact.en.yml'
12
-
13
- copy_file 'ecm.contact.request.de.yml', 'config/locales/ecm.contact.request.de.yml'
14
- copy_file 'ecm.contact.request.en.yml', 'config/locales/ecm.contact.request.en.yml'
15
- end
16
- end
17
- end
18
- end
19
- end