contact_us 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/MIT-LICENSE +20 -0
- data/README.md +30 -0
- data/Rakefile +2 -0
- data/app/controllers/contact_us/contacts_controller.rb +17 -0
- data/app/helpers/contact_us/contacts_helper.rb +5 -0
- data/app/mailers/contact_us/contact_mailer.rb +9 -0
- data/app/models/contact_us/contact.rb +29 -0
- data/app/views/contact_us/contact_mailer/contact.html.erb +3 -0
- data/app/views/contact_us/contacts/new.html.erb +6 -0
- data/config/locales/en.yml +5 -0
- data/config/routes.rb +6 -0
- data/contact_us.gemspec +21 -0
- data/lib/contact_us/engine.rb +7 -0
- data/lib/contact_us/version.rb +3 -0
- data/lib/contact_us.rb +3 -0
- metadata +84 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Jeff Dutil
|
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.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# Contact Us
|
2
|
+
|
3
|
+
A Rails 3 Engine providing a basic contact form. I used Formtastic to keep things simple, and to hook into your apps custom Formtastic stylesheets.
|
4
|
+
|
5
|
+
REQUIREMENTS
|
6
|
+
------------
|
7
|
+
Contact Us requires the Formtastic Gem. Read more about Formtastic @ https://github.com/justinfrench/formtastic
|
8
|
+
|
9
|
+
INSTALL
|
10
|
+
-------
|
11
|
+
In your `Gemfile`, add the following dependencies:
|
12
|
+
gem 'formtastic'
|
13
|
+
gem 'contact_us'
|
14
|
+
Run:
|
15
|
+
$ bundle install
|
16
|
+
|
17
|
+
CONFIGURATION
|
18
|
+
-------------
|
19
|
+
|
20
|
+
# Usage
|
21
|
+
|
22
|
+
# TODO
|
23
|
+
|
24
|
+
* config option for contact email
|
25
|
+
* install generator to copy views
|
26
|
+
* finish readme documentation
|
27
|
+
* 100% test coverage
|
28
|
+
* i18n
|
29
|
+
|
30
|
+
Copyright (c) 2011 Jeff Dutil, released under the MIT license.
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
class ContactUs::ContactsController < ApplicationController
|
2
|
+
|
3
|
+
def new
|
4
|
+
@contact = ContactUs::Contact.new(:id=>1)
|
5
|
+
end
|
6
|
+
|
7
|
+
def create
|
8
|
+
@contact = ContactUs::Contact.new(params[:contact_us_contact])
|
9
|
+
|
10
|
+
if @contact.save
|
11
|
+
redirect_to('/', :notice => "Contact email was successfully sent.")
|
12
|
+
else
|
13
|
+
flash[:error] = "You must enter both fields."
|
14
|
+
render :new
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class ContactUs::Contact
|
2
|
+
include ActiveModel::Validations
|
3
|
+
|
4
|
+
validates_presence_of :email, :message
|
5
|
+
|
6
|
+
# to deal with form, you must have an id attribute
|
7
|
+
attr_accessor :id, :email, :message
|
8
|
+
|
9
|
+
def initialize(attributes = {})
|
10
|
+
attributes.each do |key, value|
|
11
|
+
self.send("#{key}=", value)
|
12
|
+
end
|
13
|
+
@attributes = attributes
|
14
|
+
end
|
15
|
+
|
16
|
+
def read_attribute_for_validation(key)
|
17
|
+
@attributes[key]
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_key; end
|
21
|
+
|
22
|
+
def save
|
23
|
+
if self.valid?
|
24
|
+
ContactMailer.contact_email(self).deliver
|
25
|
+
return true
|
26
|
+
end
|
27
|
+
return false
|
28
|
+
end
|
29
|
+
end
|
data/config/routes.rb
ADDED
data/contact_us.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "contact_us/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "contact_us"
|
7
|
+
s.version = ContactUs::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Jeff Dutil"]
|
10
|
+
s.email = ["JDutil@BurlingtonWebApps.com"]
|
11
|
+
s.homepage = "https://github.com/jdutil/contact_us"
|
12
|
+
s.summary = %q{Gem providing simple Contact Us functionality with a Rails 3 Engine.}
|
13
|
+
s.description = %q{A Rails 3 Engine providing a basic contact form. I used Formtastic to keep things simple, and to hook into your apps custom Formtastic stylesheets.}
|
14
|
+
|
15
|
+
s.rubyforge_project = "contact_us"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
end
|
data/lib/contact_us.rb
ADDED
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: contact_us
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Jeff Dutil
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-05-03 00:00:00 -04:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: A Rails 3 Engine providing a basic contact form. I used Formtastic to keep things simple, and to hook into your apps custom Formtastic stylesheets.
|
23
|
+
email:
|
24
|
+
- JDutil@BurlingtonWebApps.com
|
25
|
+
executables: []
|
26
|
+
|
27
|
+
extensions: []
|
28
|
+
|
29
|
+
extra_rdoc_files: []
|
30
|
+
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- Gemfile
|
34
|
+
- MIT-LICENSE
|
35
|
+
- README.md
|
36
|
+
- Rakefile
|
37
|
+
- app/controllers/contact_us/contacts_controller.rb
|
38
|
+
- app/helpers/contact_us/contacts_helper.rb
|
39
|
+
- app/mailers/contact_us/contact_mailer.rb
|
40
|
+
- app/models/contact_us/contact.rb
|
41
|
+
- app/views/contact_us/contact_mailer/contact.html.erb
|
42
|
+
- app/views/contact_us/contacts/new.html.erb
|
43
|
+
- config/locales/en.yml
|
44
|
+
- config/routes.rb
|
45
|
+
- contact_us.gemspec
|
46
|
+
- lib/contact_us.rb
|
47
|
+
- lib/contact_us/engine.rb
|
48
|
+
- lib/contact_us/version.rb
|
49
|
+
has_rdoc: true
|
50
|
+
homepage: https://github.com/jdutil/contact_us
|
51
|
+
licenses: []
|
52
|
+
|
53
|
+
post_install_message:
|
54
|
+
rdoc_options: []
|
55
|
+
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
hash: 3
|
64
|
+
segments:
|
65
|
+
- 0
|
66
|
+
version: "0"
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
hash: 3
|
73
|
+
segments:
|
74
|
+
- 0
|
75
|
+
version: "0"
|
76
|
+
requirements: []
|
77
|
+
|
78
|
+
rubyforge_project: contact_us
|
79
|
+
rubygems_version: 1.5.0
|
80
|
+
signing_key:
|
81
|
+
specification_version: 3
|
82
|
+
summary: Gem providing simple Contact Us functionality with a Rails 3 Engine.
|
83
|
+
test_files: []
|
84
|
+
|