contact_form 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +4 -3
- data/app/controllers/contact_form/forms_controller.rb +8 -10
- data/app/validators/email_validator.rb +1 -1
- data/config/locales/contact_form.de.yml +4 -1
- data/config/locales/contact_form.en.yml +4 -1
- data/config/routes.rb +1 -1
- data/contact_form-0.0.1.gem +0 -0
- data/lib/contact_form/version.rb +2 -2
- data/lib/generators/contact_form/install/templates/contact_form.de.yml +4 -1
- data/lib/generators/contact_form/install/templates/contact_form.en.yml +4 -1
- data/test/dummy/app/controllers/application_controller.rb +1 -1
- data/test/dummy/app/controllers/welcome_controller.rb +6 -0
- data/test/dummy/app/helpers/application_helper.rb +13 -1
- data/test/dummy/app/views/layouts/application.html.erb +1 -0
- data/test/dummy/app/views/welcome/show.html.erb +5 -0
- data/test/dummy/config/routes.rb +2 -0
- metadata +5 -12
- data/app/assets/images/contact_form/.gitkeep +0 -0
- data/app/assets/javascripts/contact_form/application.js +0 -15
- data/app/assets/javascripts/contact_form/custom_contact_form.js +0 -0
- data/app/assets/stylesheets/contact_form/application.css +0 -13
- data/app/assets/stylesheets/contact_form/custom_contact_form.scss.css +0 -1
- data/app/assets/stylesheets/contact_form/forms.scss.css +0 -69
- data/app/controllers/contact_form/application_controller.rb +0 -4
- data/app/helpers/contact_form/application_helper.rb +0 -16
- data/app/views/layouts/contact_form/application.html.erb +0 -16
- data/lib/tasks/contact_form_tasks.rake +0 -4
data/README.rdoc
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
=== ContactForm
|
2
2
|
|
3
3
|
This gem contains a little contact form. It is build with a mountable engine.
|
4
|
+
It is simple and just sends two emails. Nothing gets saved to the database. The first email is to the website administrator and the second email is an auto reply to the user.
|
4
5
|
|
5
6
|
=== Quick Start
|
6
7
|
|
@@ -18,13 +19,13 @@ You can easily customize all files. The generated file under "/config" contains
|
|
18
19
|
|
19
20
|
After you run the generator you can mount the engine in your routes.rb
|
20
21
|
|
21
|
-
mount ContactForm::Engine => "/contact_form"
|
22
|
+
mount ContactForm::Engine => "/contact_form", :as => :contact_form
|
22
23
|
|
23
24
|
Visit
|
24
25
|
|
25
|
-
localhost:3000/contact_form
|
26
|
+
http://localhost:3000/contact_form
|
26
27
|
|
27
|
-
and you'll see the result!
|
28
|
+
and you'll see the result! You can override this route in your route file.
|
28
29
|
|
29
30
|
=== Generators
|
30
31
|
|
@@ -1,21 +1,19 @@
|
|
1
|
-
require_dependency "contact_form/application_controller"
|
2
|
-
|
3
1
|
module ContactForm
|
4
|
-
class FormsController < ApplicationController
|
2
|
+
class FormsController < ::ApplicationController
|
5
3
|
|
6
4
|
def new
|
7
|
-
|
5
|
+
@form = Form.new
|
8
6
|
end
|
9
7
|
|
10
8
|
def create
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
@form = Form.new(params[:form])
|
10
|
+
if @form.valid?
|
11
|
+
FormMailer.new_contact(@form).deliver
|
14
12
|
FormMailer.auto_reply(@form).deliver
|
15
13
|
redirect_to after_create_contact_path, notice: I18n.t(".contact_form.controllers.forms_controller.success")
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
else
|
15
|
+
render "new"
|
16
|
+
end
|
19
17
|
end
|
20
18
|
|
21
19
|
private
|
@@ -10,6 +10,6 @@ class EmailValidator < ActiveModel::EachValidator
|
|
10
10
|
rescue Exception => e
|
11
11
|
r = false
|
12
12
|
end
|
13
|
-
record.errors[attribute] << (options[:message] || "
|
13
|
+
record.errors[attribute] << (options[:message] || I18n.t(".contact_form.email_validator.error_message")) unless r
|
14
14
|
end
|
15
15
|
end
|
data/config/routes.rb
CHANGED
Binary file
|
data/lib/contact_form/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module ContactForm
|
2
|
-
VERSION = "0.0.
|
3
|
-
end
|
2
|
+
VERSION = "0.0.2"
|
3
|
+
end
|
@@ -1,2 +1,14 @@
|
|
1
1
|
module ApplicationHelper
|
2
|
-
|
2
|
+
|
3
|
+
def flash_errors_and_notices
|
4
|
+
output = ""
|
5
|
+
if flash[:notice]
|
6
|
+
output += "<div class='notice'>#{flash[:notice]}</div>"
|
7
|
+
end
|
8
|
+
if flash[:error]
|
9
|
+
output += "<div class='error'>#{flash[:error]}</div>"
|
10
|
+
end
|
11
|
+
raw output
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
data/test/dummy/config/routes.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contact_form
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -104,25 +104,17 @@ files:
|
|
104
104
|
- MIT-LICENSE
|
105
105
|
- README.rdoc
|
106
106
|
- Rakefile
|
107
|
-
- app/assets/images/contact_form/.gitkeep
|
108
|
-
- app/assets/javascripts/contact_form/application.js
|
109
|
-
- app/assets/javascripts/contact_form/custom_contact_form.js
|
110
|
-
- app/assets/stylesheets/contact_form/application.css
|
111
|
-
- app/assets/stylesheets/contact_form/custom_contact_form.scss.css
|
112
|
-
- app/assets/stylesheets/contact_form/forms.scss.css
|
113
|
-
- app/controllers/contact_form/application_controller.rb
|
114
107
|
- app/controllers/contact_form/forms_controller.rb
|
115
|
-
- app/helpers/contact_form/application_helper.rb
|
116
108
|
- app/mailers/contact_form/form_mailer.rb
|
117
109
|
- app/models/contact_form/form.rb
|
118
110
|
- app/validators/email_validator.rb
|
119
111
|
- app/views/contact_form/form_mailer/auto_reply.html.erb
|
120
112
|
- app/views/contact_form/form_mailer/new_contact.html.erb
|
121
113
|
- app/views/contact_form/forms/new.html.erb
|
122
|
-
- app/views/layouts/contact_form/application.html.erb
|
123
114
|
- config/locales/contact_form.de.yml
|
124
115
|
- config/locales/contact_form.en.yml
|
125
116
|
- config/routes.rb
|
117
|
+
- contact_form-0.0.1.gem
|
126
118
|
- contact_form.gemspec
|
127
119
|
- lib/contact_form.rb
|
128
120
|
- lib/contact_form/engine.rb
|
@@ -137,17 +129,18 @@ files:
|
|
137
129
|
- lib/generators/contact_form/mailers/mailers_generator.rb
|
138
130
|
- lib/generators/contact_form/models/models_generator.rb
|
139
131
|
- lib/generators/contact_form/views/views_generator.rb
|
140
|
-
- lib/tasks/contact_form_tasks.rake
|
141
132
|
- script/rails
|
142
133
|
- test/dummy/README.rdoc
|
143
134
|
- test/dummy/Rakefile
|
144
135
|
- test/dummy/app/assets/javascripts/application.js
|
145
136
|
- test/dummy/app/assets/stylesheets/application.css
|
146
137
|
- test/dummy/app/controllers/application_controller.rb
|
138
|
+
- test/dummy/app/controllers/welcome_controller.rb
|
147
139
|
- test/dummy/app/helpers/application_helper.rb
|
148
140
|
- test/dummy/app/mailers/.gitkeep
|
149
141
|
- test/dummy/app/models/.gitkeep
|
150
142
|
- test/dummy/app/views/layouts/application.html.erb
|
143
|
+
- test/dummy/app/views/welcome/show.html.erb
|
151
144
|
- test/dummy/config.ru
|
152
145
|
- test/dummy/config/application.rb
|
153
146
|
- test/dummy/config/boot.rb
|
@@ -200,5 +193,5 @@ rubyforge_project: contact_form
|
|
200
193
|
rubygems_version: 1.8.24
|
201
194
|
signing_key:
|
202
195
|
specification_version: 3
|
203
|
-
summary: contact_form-0.0.
|
196
|
+
summary: contact_form-0.0.2
|
204
197
|
test_files: []
|
File without changes
|
@@ -1,15 +0,0 @@
|
|
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 .
|
File without changes
|
@@ -1,13 +0,0 @@
|
|
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
|
-
*/
|
@@ -1 +0,0 @@
|
|
1
|
-
/* put custom css here */
|
@@ -1,69 +0,0 @@
|
|
1
|
-
body {
|
2
|
-
background-color: #fff;
|
3
|
-
color: #333;
|
4
|
-
font-family: verdana, arial, helvetica, sans-serif;
|
5
|
-
font-size: 13px;
|
6
|
-
line-height: 18px;
|
7
|
-
}
|
8
|
-
|
9
|
-
p, ol, ul, td {
|
10
|
-
font-family: verdana, arial, helvetica, sans-serif;
|
11
|
-
font-size: 13px;
|
12
|
-
line-height: 18px;
|
13
|
-
}
|
14
|
-
|
15
|
-
pre {
|
16
|
-
background-color: #eee;
|
17
|
-
padding: 10px;
|
18
|
-
font-size: 11px;
|
19
|
-
}
|
20
|
-
|
21
|
-
a {
|
22
|
-
color: #000;
|
23
|
-
&:visited {
|
24
|
-
color: #666;
|
25
|
-
}
|
26
|
-
&:hover {
|
27
|
-
color: #fff;
|
28
|
-
background-color: #000;
|
29
|
-
}
|
30
|
-
}
|
31
|
-
|
32
|
-
div {
|
33
|
-
&.field, &.actions {
|
34
|
-
margin-bottom: 10px;
|
35
|
-
}
|
36
|
-
}
|
37
|
-
|
38
|
-
#notice {
|
39
|
-
color: green;
|
40
|
-
}
|
41
|
-
|
42
|
-
.field_with_errors {
|
43
|
-
padding: 2px;
|
44
|
-
background-color: red;
|
45
|
-
display: table;
|
46
|
-
}
|
47
|
-
|
48
|
-
#error_explanation {
|
49
|
-
width: 450px;
|
50
|
-
border: 2px solid red;
|
51
|
-
padding: 7px;
|
52
|
-
padding-bottom: 0;
|
53
|
-
margin-bottom: 20px;
|
54
|
-
background-color: #f0f0f0;
|
55
|
-
h2 {
|
56
|
-
text-align: left;
|
57
|
-
font-weight: bold;
|
58
|
-
padding: 5px 5px 5px 15px;
|
59
|
-
font-size: 12px;
|
60
|
-
margin: -7px;
|
61
|
-
margin-bottom: 0px;
|
62
|
-
background-color: #c00;
|
63
|
-
color: #fff;
|
64
|
-
}
|
65
|
-
ul li {
|
66
|
-
font-size: 12px;
|
67
|
-
list-style: square;
|
68
|
-
}
|
69
|
-
}
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module ContactForm
|
2
|
-
module ApplicationHelper
|
3
|
-
|
4
|
-
def flash_errors_and_notices
|
5
|
-
output = ""
|
6
|
-
if flash[:notice]
|
7
|
-
output += "<div class='notice'>#{flash[:notice]}</div>"
|
8
|
-
end
|
9
|
-
if flash[:error]
|
10
|
-
output += "<div class='error'>#{flash[:error]}</div>"
|
11
|
-
end
|
12
|
-
raw output
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
16
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>ContactForm</title>
|
5
|
-
<%= stylesheet_link_tag "contact_form/application", :media => "all" %>
|
6
|
-
<%= javascript_include_tag "contact_form/application" %>
|
7
|
-
<%= csrf_meta_tags %>
|
8
|
-
</head>
|
9
|
-
<body>
|
10
|
-
|
11
|
-
<%= flash_errors_and_notices %>
|
12
|
-
|
13
|
-
<%= yield %>
|
14
|
-
|
15
|
-
</body>
|
16
|
-
</html>
|