contact_form 0.0.1
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.
- data/.gitignore +7 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +100 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +43 -0
- data/Rakefile +40 -0
- data/app/assets/images/contact_form/.gitkeep +0 -0
- data/app/assets/javascripts/contact_form/application.js +15 -0
- data/app/assets/javascripts/contact_form/custom_contact_form.js +0 -0
- data/app/assets/stylesheets/contact_form/application.css +13 -0
- data/app/assets/stylesheets/contact_form/custom_contact_form.scss.css +1 -0
- data/app/assets/stylesheets/contact_form/forms.scss.css +69 -0
- data/app/controllers/contact_form/application_controller.rb +4 -0
- data/app/controllers/contact_form/forms_controller.rb +28 -0
- data/app/helpers/contact_form/application_helper.rb +16 -0
- data/app/mailers/contact_form/form_mailer.rb +17 -0
- data/app/models/contact_form/form.rb +25 -0
- data/app/validators/email_validator.rb +15 -0
- data/app/views/contact_form/form_mailer/auto_reply.html.erb +9 -0
- data/app/views/contact_form/form_mailer/new_contact.html.erb +16 -0
- data/app/views/contact_form/forms/new.html.erb +22 -0
- data/app/views/layouts/contact_form/application.html.erb +16 -0
- data/config/locales/contact_form.de.yml +24 -0
- data/config/locales/contact_form.en.yml +24 -0
- data/config/routes.rb +6 -0
- data/contact_form.gemspec +26 -0
- data/lib/contact_form.rb +4 -0
- data/lib/contact_form/engine.rb +5 -0
- data/lib/contact_form/version.rb +3 -0
- data/lib/generators/contact_form/all/all_generator.rb +21 -0
- data/lib/generators/contact_form/controllers/controllers_generator.rb +18 -0
- data/lib/generators/contact_form/install/install_generator.rb +23 -0
- data/lib/generators/contact_form/install/templates/contact_form.de.yml +24 -0
- data/lib/generators/contact_form/install/templates/contact_form.en.yml +24 -0
- data/lib/generators/contact_form/install/templates/contact_form.rb +1 -0
- data/lib/generators/contact_form/install/templates/contact_form.yml +3 -0
- data/lib/generators/contact_form/mailers/mailers_generator.rb +18 -0
- data/lib/generators/contact_form/models/models_generator.rb +18 -0
- data/lib/generators/contact_form/views/views_generator.rb +18 -0
- data/lib/tasks/contact_form_tasks.rake +4 -0
- data/script/rails +8 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/mailers/.gitkeep +0 -0
- data/test/dummy/app/models/.gitkeep +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +59 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/contact_form.yml +3 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/contact_form.rb +1 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/contact_form.de.yml +24 -0
- data/test/dummy/config/locales/contact_form.en.yml +24 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/lib/assets/.gitkeep +0 -0
- data/test/dummy/log/.gitkeep +0 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/test_helper.rb +15 -0
- metadata +204 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
# Declare your gem's dependencies in contact_form.gemspec.
|
4
|
+
# Bundler will treat runtime dependencies like base dependencies, and
|
5
|
+
# development dependencies will be added by default to the :development group.
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
# jquery-rails is used by the dummy application
|
9
|
+
gem "jquery-rails"
|
10
|
+
|
11
|
+
# Declare any dependencies that are still in development here instead of in
|
12
|
+
# your gemspec. These might include edge Rails or gems from your path or
|
13
|
+
# Git. Remember to move these dependencies to your gemspec before releasing
|
14
|
+
# your gem to rubygems.org.
|
15
|
+
|
16
|
+
# To use debugger
|
17
|
+
# gem 'debugger'
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
contact_form (0.0.1)
|
5
|
+
i18n
|
6
|
+
jquery-rails
|
7
|
+
mail
|
8
|
+
rails (~> 3.2.8)
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: http://rubygems.org/
|
12
|
+
specs:
|
13
|
+
actionmailer (3.2.8)
|
14
|
+
actionpack (= 3.2.8)
|
15
|
+
mail (~> 2.4.4)
|
16
|
+
actionpack (3.2.8)
|
17
|
+
activemodel (= 3.2.8)
|
18
|
+
activesupport (= 3.2.8)
|
19
|
+
builder (~> 3.0.0)
|
20
|
+
erubis (~> 2.7.0)
|
21
|
+
journey (~> 1.0.4)
|
22
|
+
rack (~> 1.4.0)
|
23
|
+
rack-cache (~> 1.2)
|
24
|
+
rack-test (~> 0.6.1)
|
25
|
+
sprockets (~> 2.1.3)
|
26
|
+
activemodel (3.2.8)
|
27
|
+
activesupport (= 3.2.8)
|
28
|
+
builder (~> 3.0.0)
|
29
|
+
activerecord (3.2.8)
|
30
|
+
activemodel (= 3.2.8)
|
31
|
+
activesupport (= 3.2.8)
|
32
|
+
arel (~> 3.0.2)
|
33
|
+
tzinfo (~> 0.3.29)
|
34
|
+
activeresource (3.2.8)
|
35
|
+
activemodel (= 3.2.8)
|
36
|
+
activesupport (= 3.2.8)
|
37
|
+
activesupport (3.2.8)
|
38
|
+
i18n (~> 0.6)
|
39
|
+
multi_json (~> 1.0)
|
40
|
+
arel (3.0.2)
|
41
|
+
builder (3.0.0)
|
42
|
+
erubis (2.7.0)
|
43
|
+
hike (1.2.1)
|
44
|
+
i18n (0.6.0)
|
45
|
+
journey (1.0.4)
|
46
|
+
jquery-rails (2.1.1)
|
47
|
+
railties (>= 3.1.0, < 5.0)
|
48
|
+
thor (~> 0.14)
|
49
|
+
json (1.7.5)
|
50
|
+
mail (2.4.4)
|
51
|
+
i18n (>= 0.4.0)
|
52
|
+
mime-types (~> 1.16)
|
53
|
+
treetop (~> 1.4.8)
|
54
|
+
mime-types (1.19)
|
55
|
+
multi_json (1.3.6)
|
56
|
+
polyglot (0.3.3)
|
57
|
+
rack (1.4.1)
|
58
|
+
rack-cache (1.2)
|
59
|
+
rack (>= 0.4)
|
60
|
+
rack-ssl (1.3.2)
|
61
|
+
rack
|
62
|
+
rack-test (0.6.1)
|
63
|
+
rack (>= 1.0)
|
64
|
+
rails (3.2.8)
|
65
|
+
actionmailer (= 3.2.8)
|
66
|
+
actionpack (= 3.2.8)
|
67
|
+
activerecord (= 3.2.8)
|
68
|
+
activeresource (= 3.2.8)
|
69
|
+
activesupport (= 3.2.8)
|
70
|
+
bundler (~> 1.0)
|
71
|
+
railties (= 3.2.8)
|
72
|
+
railties (3.2.8)
|
73
|
+
actionpack (= 3.2.8)
|
74
|
+
activesupport (= 3.2.8)
|
75
|
+
rack-ssl (~> 1.3.2)
|
76
|
+
rake (>= 0.8.7)
|
77
|
+
rdoc (~> 3.4)
|
78
|
+
thor (>= 0.14.6, < 2.0)
|
79
|
+
rake (0.9.2.2)
|
80
|
+
rdoc (3.12)
|
81
|
+
json (~> 1.4)
|
82
|
+
sprockets (2.1.3)
|
83
|
+
hike (~> 1.2)
|
84
|
+
rack (~> 1.0)
|
85
|
+
tilt (~> 1.1, != 1.3.0)
|
86
|
+
sqlite3 (1.3.6)
|
87
|
+
thor (0.16.0)
|
88
|
+
tilt (1.3.3)
|
89
|
+
treetop (1.4.10)
|
90
|
+
polyglot
|
91
|
+
polyglot (>= 0.3.1)
|
92
|
+
tzinfo (0.3.33)
|
93
|
+
|
94
|
+
PLATFORMS
|
95
|
+
ruby
|
96
|
+
|
97
|
+
DEPENDENCIES
|
98
|
+
contact_form!
|
99
|
+
jquery-rails
|
100
|
+
sqlite3
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012 Matthias Frick
|
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.rdoc
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
=== ContactForm
|
2
|
+
|
3
|
+
This gem contains a little contact form. It is build with a mountable engine.
|
4
|
+
|
5
|
+
=== Quick Start
|
6
|
+
|
7
|
+
gem install contact_form
|
8
|
+
|
9
|
+
Or add it to your Gemfile:
|
10
|
+
|
11
|
+
gem "contact_form"
|
12
|
+
|
13
|
+
Run the generator to generate an initializer file, a config yml file and locale files
|
14
|
+
|
15
|
+
rails g contact_form:install
|
16
|
+
|
17
|
+
You can easily customize all files. The generated file under "/config" contains the mailer recipients, you can change them the way you want. The generated files under "/config/locales" contains i18n keys which can also be changed.
|
18
|
+
|
19
|
+
After you run the generator you can mount the engine in your routes.rb
|
20
|
+
|
21
|
+
mount ContactForm::Engine => "/contact_form"
|
22
|
+
|
23
|
+
Visit
|
24
|
+
|
25
|
+
localhost:3000/contact_form
|
26
|
+
|
27
|
+
and you'll see the result!
|
28
|
+
|
29
|
+
=== Generators
|
30
|
+
|
31
|
+
There are following generators available for customizing your contact form:
|
32
|
+
|
33
|
+
rails g contact_form:views # generates view files
|
34
|
+
rails g contact_form:models # generates model files
|
35
|
+
rails g contact_form:controllers # generates controller files
|
36
|
+
rails g contact_form:mailers # generates mailer files
|
37
|
+
|
38
|
+
Or simple generate all files
|
39
|
+
|
40
|
+
rails g contact_form:all # generates all files
|
41
|
+
|
42
|
+
|
43
|
+
Copyright (c) 2012 Matthias Frick, released under the 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 = 'ContactForm'
|
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
|
File without changes
|
@@ -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 .
|
File without changes
|
@@ -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 @@
|
|
1
|
+
/* put custom css here */
|
@@ -0,0 +1,69 @@
|
|
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
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require_dependency "contact_form/application_controller"
|
2
|
+
|
3
|
+
module ContactForm
|
4
|
+
class FormsController < ApplicationController
|
5
|
+
|
6
|
+
def new
|
7
|
+
@form = Form.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def create
|
11
|
+
@form = Form.new(params[:form])
|
12
|
+
if @form.valid?
|
13
|
+
FormMailer.new_contact(@form).deliver
|
14
|
+
FormMailer.auto_reply(@form).deliver
|
15
|
+
redirect_to after_create_contact_path, notice: I18n.t(".contact_form.controllers.forms_controller.success")
|
16
|
+
else
|
17
|
+
render "new"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def after_create_contact_path
|
24
|
+
root_path
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,16 @@
|
|
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
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
module ContactForm
|
3
|
+
class FormMailer < ActionMailer::Base
|
4
|
+
default from: CONTACT_FORM_CONFIG["form_mailer"]["default_from"]
|
5
|
+
|
6
|
+
def auto_reply(form)
|
7
|
+
@form = form
|
8
|
+
mail(to: form.email, subject: I18n.t(".contact_form.mailers.form_mailer.auto_reply_subject"))
|
9
|
+
end
|
10
|
+
|
11
|
+
def new_contact(form)
|
12
|
+
@form = form
|
13
|
+
mail(to: CONTACT_FORM_CONFIG["form_mailer"]["new_contact_to"], subject: I18n.t(".contact_form.mailers.form_mailer.new_contact_subject"))
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module ContactForm
|
2
|
+
class Form
|
3
|
+
|
4
|
+
include ActiveModel::Validations
|
5
|
+
include ActiveModel::Conversion
|
6
|
+
extend ActiveModel::Naming
|
7
|
+
|
8
|
+
attr_accessor :name, :email, :message
|
9
|
+
|
10
|
+
validates :name, presence: true
|
11
|
+
validates :email, presence: true, email: true
|
12
|
+
validates :message, presence: true
|
13
|
+
|
14
|
+
def initialize(attributes = {})
|
15
|
+
attributes.each do |name, value|
|
16
|
+
send("#{name}=", value)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def persisted?
|
21
|
+
false
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|