contact_us 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 ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in contact_us.gemspec
4
+ gemspec
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,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -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,5 @@
1
+ module ContactUs::ContactsHelper
2
+ def clear_div
3
+ %Q{<div style="clear: both; height: 0px; line-height: 0px;" class="clear">&nbsp;</div>}.html_safe
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ class ContactUs::ContactMailer < ActionMailer::Base
2
+ def contact_email(contact)
3
+ @message = contact.message
4
+
5
+ mail(:to => "contact@YOUR-SITE.com",
6
+ :subject => "Contact Us message from #{contact.email}",
7
+ :from => contact.email)
8
+ end
9
+ 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
@@ -0,0 +1,3 @@
1
+ <p><%= @message %><p>
2
+ <p>-------------------------------------</p>
3
+ <p>Sent by BurlingtonWebApps.com contact form.</p>
@@ -0,0 +1,6 @@
1
+ <h2>Contact Us</h2>
2
+ <%= semantic_form_for @contact, :url => contacts_path do |f| %>
3
+ <%= f.input :email %>
4
+ <%= f.input :message, :as => :text %>
5
+ <%= f.commit_button "Submit", :button_html => { :title => 'Submit' } %>
6
+ <% end %>
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
data/config/routes.rb ADDED
@@ -0,0 +1,6 @@
1
+ Rails.application.routes.draw do
2
+ resources :contacts,
3
+ :controller => 'contact_us/contacts',
4
+ :only => [:new, :create]
5
+ match 'contact_us' => 'contact_us/contacts#new'
6
+ end
@@ -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
@@ -0,0 +1,7 @@
1
+ require "contact_us"
2
+ require "rails"
3
+
4
+ module ContactUs
5
+ class Engine < Rails::Engine
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module ContactUs
2
+ VERSION = "0.0.1"
3
+ end
data/lib/contact_us.rb ADDED
@@ -0,0 +1,3 @@
1
+ module ContactUs
2
+ require 'contact_us/engine'
3
+ end
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
+