contact_us 0.3.0 → 0.4.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +31 -16
- data/app/controllers/contact_us/contacts_controller.rb +13 -1
- data/app/views/contact_us/contacts/new.html.erb +36 -6
- data/app/views/contact_us/contacts/new_formtastic.html.erb +8 -0
- data/app/views/contact_us/contacts/new_simple_form.html.erb +8 -0
- data/config/locales/contact_us.de.yml +5 -1
- data/config/locales/contact_us.en.yml +5 -1
- data/config/locales/contact_us.es.yml +5 -1
- data/config/locales/contact_us.it.yml +5 -1
- data/config/locales/contact_us.pt-BR.yml +5 -1
- data/config/locales/contact_us.zh.yml +5 -1
- data/lib/contact_us/version.rb +1 -1
- data/lib/contact_us.rb +3 -0
- data/lib/templates/contact_us.rb +5 -0
- data/spec/dummy/config/locales/contact_us.de.yml +5 -1
- data/spec/dummy/config/locales/contact_us.es.yml +5 -1
- data/spec/dummy/config/locales/contact_us.it.yml +5 -1
- data/spec/dummy/config/locales/contact_us.pt-BR.yml +5 -1
- data/spec/dummy/config/locales/contact_us.zh.yml +5 -1
- data/spec/dummy/log/test.log +4983 -0
- data/spec/integration/contact_us_lint_spec.rb +1 -1
- metadata +25 -10
data/README.md
CHANGED
@@ -12,18 +12,18 @@ There is also a demo application showing how the ContactUs form works:
|
|
12
12
|
|
13
13
|
## REQUIREMENTS
|
14
14
|
|
15
|
-
Contact Us requires
|
15
|
+
Contact Us requires:
|
16
16
|
|
17
|
-
|
18
|
-
|
17
|
+
* Ruby >= 1.8.7 (will soon only support > 1.9.2)
|
18
|
+
* Rails >= 3.0.0
|
19
19
|
|
20
|
-
|
20
|
+
It is also recommended to use Formtastic or SimpleForm (see configuration) in order to hook into your apps custom form builders.
|
21
21
|
|
22
22
|
## INSTALLATION
|
23
23
|
|
24
24
|
In your `Gemfile`, add the following dependencies:
|
25
25
|
|
26
|
-
gem 'contact_us', '~> 0.
|
26
|
+
gem 'contact_us', '~> 0.4.0.beta'
|
27
27
|
|
28
28
|
From `Rails.root` run:
|
29
29
|
|
@@ -43,6 +43,30 @@ You may also specify an email address for the notification emails from field:
|
|
43
43
|
|
44
44
|
config.mailer_from = "dontreply@yourdomain.com"
|
45
45
|
|
46
|
+
## CONFIGURATION
|
47
|
+
|
48
|
+
The generator copies the view files to `app/views/contact_us`, and you can customize them to suit your needs. If you would like to add a name or subject field to the form you may simply
|
49
|
+
set the options to true within the contact_us initializer located at `config/initializers/contact_us.rb`:
|
50
|
+
|
51
|
+
config.require_name = true
|
52
|
+
config.require_subject = true
|
53
|
+
|
54
|
+
You may also update your locales under `config/locales/contact_us.en.yml` or create your own. Please feel free to submit your own locales so that other users will hopefully find this gem more useful.
|
55
|
+
|
56
|
+
### Formtastic
|
57
|
+
|
58
|
+
In order to use a Formtastic compatible template to hook into your custom form styles configure `config/initializers/contact_us.rb`:
|
59
|
+
|
60
|
+
config.form_gem = 'formtastic'
|
61
|
+
|
62
|
+
* By default the HTML should match that produced by Formtastic, but to ensure it is up to date you should set Formtastic.
|
63
|
+
|
64
|
+
### SimpleForm
|
65
|
+
|
66
|
+
In order to use a SimpleForm compatible template to hook into your custom form styles configure `config/initializers/contact_us.rb`:
|
67
|
+
|
68
|
+
config.form_gem = 'simple_form'
|
69
|
+
|
46
70
|
## UPGRADING
|
47
71
|
|
48
72
|
When upgrading from 0.1.x to 0.2.x you should rerun the install generator to install the new settings, views, and locale updates:
|
@@ -54,16 +78,6 @@ Or you may run the generators for each specific component you would like to upda
|
|
54
78
|
$ bundle exec rake contact_us:copy_locales
|
55
79
|
$ bundle exec rake contact_us:copy_views
|
56
80
|
|
57
|
-
## CONFIGURATION
|
58
|
-
|
59
|
-
The generator copies the view files to `app/views/contact_us`, and you can customize them to suit your needs. If you would like to add a name or subject field to the form you may simply
|
60
|
-
set the options to true within the contact_us initializer located at `config/initializers/contact_us.rb`:
|
61
|
-
|
62
|
-
config.require_name = true
|
63
|
-
config.require_subject = true
|
64
|
-
|
65
|
-
You may also update your locales under `config/locales/contact_us.en.yml` or create your own. Please feel free to submit your own locales so that other users will hopefully find this gem more useful.
|
66
|
-
|
67
81
|
## USAGE
|
68
82
|
|
69
83
|
Visit your website and navigate to `/contact-us` to see the form in action.
|
@@ -97,6 +111,7 @@ Here are some ways *you* can contribute:
|
|
97
111
|
|
98
112
|
## TODO
|
99
113
|
|
100
|
-
* Add new language translations
|
114
|
+
* Add new language translations.
|
115
|
+
* Stop copying views/locales by default.
|
101
116
|
|
102
117
|
Copyright (c) 2011 Jeff Dutil, released under the [MIT license](https://github.com/jdutil/contact_us/tree/master/MIT-LICENSE).
|
@@ -7,12 +7,24 @@ class ContactUs::ContactsController < ApplicationController
|
|
7
7
|
redirect_to('/', :notice => t('contact_us.notices.success'))
|
8
8
|
else
|
9
9
|
flash[:error] = t('contact_us.notices.error')
|
10
|
-
|
10
|
+
render_new_page
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
def new
|
15
15
|
@contact = ContactUs::Contact.new
|
16
|
+
render_new_page
|
16
17
|
end
|
17
18
|
|
19
|
+
protected
|
20
|
+
|
21
|
+
def render_new_page
|
22
|
+
case ContactUs.form_gem
|
23
|
+
when 'formtastic' then render 'new_formtastic'
|
24
|
+
when 'simple_form' then render 'new_simple_form'
|
25
|
+
else
|
26
|
+
render 'new'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
18
30
|
end
|
@@ -1,8 +1,38 @@
|
|
1
1
|
<h2><%= t('.contact_us') %></h2>
|
2
|
-
<%=
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
<%= form_for @contact, :url => contacts_path, :html => {:class => 'formtastic'} do |f| %>
|
3
|
+
<% if ContactUs.require_name %>
|
4
|
+
<li class='string required' id='contact_us_contact_name_input'>
|
5
|
+
<%= f.label :name, (t('.name') + content_tag(:abbr, '*', :class => 'required')).html_safe %>
|
6
|
+
<%= f.text_field :name %>
|
7
|
+
<% if f.object.errors[:name].present? %>
|
8
|
+
<p class='inline-error'><%= f.object.errors[:name].join(' and ') %></p>
|
9
|
+
<% end %>
|
10
|
+
</li>
|
11
|
+
<% end %>
|
12
|
+
<li class='string required' id='contact_us_contact_email_input'>
|
13
|
+
<%= f.label :email, (t('.email') + content_tag(:abbr, '*', :class => 'required')).html_safe %>
|
14
|
+
<%= f.text_field :email %>
|
15
|
+
<% if f.object.errors[:email].present? %>
|
16
|
+
<p class='inline-error'><%= f.object.errors[:email].join(' and ') %></p>
|
17
|
+
<% end %>
|
18
|
+
</li>
|
19
|
+
<% if ContactUs.require_subject %>
|
20
|
+
<li class='string required' id='contact_us_contact_subject_input'>
|
21
|
+
<%= f.label :subject, (t('.subject') + content_tag(:abbr, '*', :class => 'required')).html_safe %>
|
22
|
+
<%= f.text_field :subject %>
|
23
|
+
<% if f.object.errors[:subject].present? %>
|
24
|
+
<p class='inline-error'><%= f.object.errors[:subject].join(' and ') %></p>
|
25
|
+
<% end %>
|
26
|
+
</li>
|
27
|
+
<% end %>
|
28
|
+
<li class='text required' id='contact_us_contact_message_input'>
|
29
|
+
<%= f.label :message, (t('.message') + content_tag(:abbr, '*', :class => 'required')).html_safe %>
|
30
|
+
<%= f.text_area :message %>
|
31
|
+
<% if f.object.errors[:message].present? %>
|
32
|
+
<p class='inline-error'><%= f.object.errors[:message].join(' and ') %></p>
|
33
|
+
<% end %>
|
34
|
+
</li>
|
35
|
+
<li class='commit'>
|
36
|
+
<%= f.submit :submit, :alt => t('.submit'), :class => 'submit create', :label => t('.submit'), :title => t('.submit') %>
|
37
|
+
</li>
|
8
38
|
<% end %>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<h2><%= t('.contact_us') %></h2>
|
2
|
+
<%= semantic_form_for @contact, :url => contacts_path do |f| %>
|
3
|
+
<%= f.input :name, :label => t('.name') if ContactUs.require_name %>
|
4
|
+
<%= f.input :email, :label => t('.email') %>
|
5
|
+
<%= f.input :subject, :label => t('.subject') if ContactUs.require_subject %>
|
6
|
+
<%= f.input :message, :as => :text, :label => t('.message') %>
|
7
|
+
<%= f.action :submit, :label => t('.submit'), :button_html => { :alt => t('.submit'), :id => 'contact_us_contact_submit', :title => t('.submit') } %>
|
8
|
+
<% end %>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<h2><%= t('.contact_us') %></h2>
|
2
|
+
<%= simple_form_for @contact, :url => contacts_path do |f| %>
|
3
|
+
<%= f.input :name, :label => t('.name') if ContactUs.require_name %>
|
4
|
+
<%= f.input :email, :label => t('.email') %>
|
5
|
+
<%= f.input :subject, :label => t('.subject') if ContactUs.require_subject %>
|
6
|
+
<%= f.input :message, :as => :text, :label => t('.message') %>
|
7
|
+
<%= f.button :submit, :label => t('.submit'), :button_html => { :alt => t('.submit'), :id => 'contact_us_contact_submit', :title => t('.submit') } %>
|
8
|
+
<% end %>
|
@@ -9,13 +9,17 @@ de:
|
|
9
9
|
sent_by_name: "Sent by %{name} from %{email}"
|
10
10
|
subject: "Contact Us message from %{email}"
|
11
11
|
contacts:
|
12
|
-
new:
|
12
|
+
new: &new
|
13
13
|
contact_us: "Kontaktiere Uns"
|
14
14
|
email: "Email"
|
15
15
|
message: "Nachricht"
|
16
16
|
name: "Name"
|
17
17
|
subject: "Subject"
|
18
18
|
submit: "Abschicken"
|
19
|
+
new_formtastic:
|
20
|
+
<<: *new
|
21
|
+
new_simple_form:
|
22
|
+
<<: *new
|
19
23
|
notices:
|
20
24
|
error: "Beide Felder müssen ausgefüllt werden."
|
21
25
|
success: "Die Nachricht wurde erfolgreich versendet."
|
@@ -9,13 +9,17 @@ en:
|
|
9
9
|
sent_by_name: "Sent by %{name} from %{email}"
|
10
10
|
subject: "Contact Us message from %{email}"
|
11
11
|
contacts:
|
12
|
-
new:
|
12
|
+
new: &new
|
13
13
|
contact_us: "Contact Us"
|
14
14
|
email: "Email"
|
15
15
|
message: "Message"
|
16
16
|
name: "Name"
|
17
17
|
subject: "Subject"
|
18
18
|
submit: "Submit"
|
19
|
+
new_formtastic:
|
20
|
+
<<: *new
|
21
|
+
new_simple_form:
|
22
|
+
<<: *new
|
19
23
|
notices:
|
20
24
|
error: "You must enter both fields."
|
21
25
|
success: "Contact email was successfully sent."
|
@@ -9,13 +9,17 @@ es:
|
|
9
9
|
sent_by_name: "Sent by %{name} from %{email}"
|
10
10
|
subject: "Contact Us message from %{email}"
|
11
11
|
contacts:
|
12
|
-
new:
|
12
|
+
new: &new
|
13
13
|
contact_us: "Contactanos"
|
14
14
|
email: "Email"
|
15
15
|
message: "Mensaje"
|
16
16
|
name: "Name"
|
17
17
|
subject: "Subject"
|
18
18
|
submit: "Enviar"
|
19
|
+
new_formtastic:
|
20
|
+
<<: *new
|
21
|
+
new_simple_form:
|
22
|
+
<<: *new
|
19
23
|
notices:
|
20
24
|
error: "Debes de ingresar ambos campos."
|
21
25
|
success: "El correo electrónico de contacto fue enviado con éxito."
|
@@ -9,13 +9,17 @@ it:
|
|
9
9
|
sent_by_name: "Sent by %{name} from %{email}"
|
10
10
|
subject: "Contact Us message from %{email}"
|
11
11
|
contacts:
|
12
|
-
new:
|
12
|
+
new: &new
|
13
13
|
contact_us: "Contattaci"
|
14
14
|
email: "Email"
|
15
15
|
message: "Messaggio"
|
16
16
|
name: "Name"
|
17
17
|
subject: "Subject"
|
18
18
|
submit: "Inviare"
|
19
|
+
new_formtastic:
|
20
|
+
<<: *new
|
21
|
+
new_simple_form:
|
22
|
+
<<: *new
|
19
23
|
notices:
|
20
24
|
error: "Devi inserire entrambi i campi."
|
21
25
|
success: "La mail di contatto è stata inviata."
|
@@ -9,13 +9,17 @@ pt-BR:
|
|
9
9
|
sent_by_name: "Sent by %{name} from %{email}"
|
10
10
|
subject: "Contact Us message from %{email}"
|
11
11
|
contacts:
|
12
|
-
new:
|
12
|
+
new: &new
|
13
13
|
contact_us: "Contate-nos"
|
14
14
|
email: "Email"
|
15
15
|
message: "Messagem"
|
16
16
|
name: "Name"
|
17
17
|
subject: "Subject"
|
18
18
|
submit: "Enviar"
|
19
|
+
new_formtastic:
|
20
|
+
<<: *new
|
21
|
+
new_simple_form:
|
22
|
+
<<: *new
|
19
23
|
notices:
|
20
24
|
error: "Você deve preencher os campos."
|
21
25
|
success: "Email de contato foi enviado com sucesso."
|
@@ -9,13 +9,17 @@ zh:
|
|
9
9
|
sent_by_name: "Sent by %{name} from %{email}"
|
10
10
|
subject: "Contact Us message from %{email}"
|
11
11
|
contacts:
|
12
|
-
new:
|
12
|
+
new: &new
|
13
13
|
contact_us: "联系我们"
|
14
14
|
email: "邮箱"
|
15
15
|
message: "消息"
|
16
16
|
name: "Name"
|
17
17
|
subject: "Subject"
|
18
18
|
submit: "发送"
|
19
|
+
new_formtastic:
|
20
|
+
<<: *new
|
21
|
+
new_simple_form:
|
22
|
+
<<: *new
|
19
23
|
notices:
|
20
24
|
error: "请正确输入邮箱与信息。"
|
21
25
|
success: "邮件已成功发送。"
|
data/lib/contact_us/version.rb
CHANGED
data/lib/contact_us.rb
CHANGED
@@ -13,6 +13,9 @@ module ContactUs
|
|
13
13
|
# Enable or Disable subject field.
|
14
14
|
mattr_accessor :require_subject
|
15
15
|
|
16
|
+
# Formtastic or SimpleForm
|
17
|
+
mattr_accessor :form_gem
|
18
|
+
|
16
19
|
# Default way to setup ContactUs. Run rake contact_us:install to create
|
17
20
|
# a fresh initializer with all configuration values.
|
18
21
|
def self.setup
|
data/lib/templates/contact_us.rb
CHANGED
@@ -9,13 +9,17 @@ de:
|
|
9
9
|
sent_by_name: "Sent by %{name} from %{email}"
|
10
10
|
subject: "Contact Us message from %{email}"
|
11
11
|
contacts:
|
12
|
-
new:
|
12
|
+
new: &new
|
13
13
|
contact_us: "Kontaktiere Uns"
|
14
14
|
email: "Email"
|
15
15
|
message: "Nachricht"
|
16
16
|
name: "Name"
|
17
17
|
subject: "Subject"
|
18
18
|
submit: "Abschicken"
|
19
|
+
new_formtastic:
|
20
|
+
<<: *new
|
21
|
+
new_simple_form:
|
22
|
+
<<: *new
|
19
23
|
notices:
|
20
24
|
error: "Beide Felder müssen ausgefüllt werden."
|
21
25
|
success: "Die Nachricht wurde erfolgreich versendet."
|
@@ -9,13 +9,17 @@ es:
|
|
9
9
|
sent_by_name: "Sent by %{name} from %{email}"
|
10
10
|
subject: "Contact Us message from %{email}"
|
11
11
|
contacts:
|
12
|
-
new:
|
12
|
+
new: &new
|
13
13
|
contact_us: "Contactanos"
|
14
14
|
email: "Email"
|
15
15
|
message: "Mensaje"
|
16
16
|
name: "Name"
|
17
17
|
subject: "Subject"
|
18
18
|
submit: "Enviar"
|
19
|
+
new_formtastic:
|
20
|
+
<<: *new
|
21
|
+
new_simple_form:
|
22
|
+
<<: *new
|
19
23
|
notices:
|
20
24
|
error: "Debes de ingresar ambos campos."
|
21
25
|
success: "El correo electrónico de contacto fue enviado con éxito."
|
@@ -9,13 +9,17 @@ it:
|
|
9
9
|
sent_by_name: "Sent by %{name} from %{email}"
|
10
10
|
subject: "Contact Us message from %{email}"
|
11
11
|
contacts:
|
12
|
-
new:
|
12
|
+
new: &new
|
13
13
|
contact_us: "Contattaci"
|
14
14
|
email: "Email"
|
15
15
|
message: "Messaggio"
|
16
16
|
name: "Name"
|
17
17
|
subject: "Subject"
|
18
18
|
submit: "Inviare"
|
19
|
+
new_formtastic:
|
20
|
+
<<: *new
|
21
|
+
new_simple_form:
|
22
|
+
<<: *new
|
19
23
|
notices:
|
20
24
|
error: "Devi inserire entrambi i campi."
|
21
25
|
success: "La mail di contatto è stata inviata."
|
@@ -9,13 +9,17 @@ pt-BR:
|
|
9
9
|
sent_by_name: "Sent by %{name} from %{email}"
|
10
10
|
subject: "Contact Us message from %{email}"
|
11
11
|
contacts:
|
12
|
-
new:
|
12
|
+
new: &new
|
13
13
|
contact_us: "Contate-nos"
|
14
14
|
email: "Email"
|
15
15
|
message: "Messagem"
|
16
16
|
name: "Name"
|
17
17
|
subject: "Subject"
|
18
18
|
submit: "Enviar"
|
19
|
+
new_formtastic:
|
20
|
+
<<: *new
|
21
|
+
new_simple_form:
|
22
|
+
<<: *new
|
19
23
|
notices:
|
20
24
|
error: "Você deve preencher os campos."
|
21
25
|
success: "Email de contato foi enviado com sucesso."
|
@@ -9,13 +9,17 @@ zh:
|
|
9
9
|
sent_by_name: "Sent by %{name} from %{email}"
|
10
10
|
subject: "Contact Us message from %{email}"
|
11
11
|
contacts:
|
12
|
-
new:
|
12
|
+
new: &new
|
13
13
|
contact_us: "联系我们"
|
14
14
|
email: "邮箱"
|
15
15
|
message: "消息"
|
16
16
|
name: "Name"
|
17
17
|
subject: "Subject"
|
18
18
|
submit: "发送"
|
19
|
+
new_formtastic:
|
20
|
+
<<: *new
|
21
|
+
new_simple_form:
|
22
|
+
<<: *new
|
19
23
|
notices:
|
20
24
|
error: "请正确输入邮箱与信息。"
|
21
25
|
success: "邮件已成功发送。"
|