contact_us 0.0.1 → 0.0.2

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/README.md CHANGED
@@ -2,29 +2,35 @@
2
2
 
3
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
4
 
5
- REQUIREMENTS
6
- ------------
5
+ ## REQUIREMENTS
6
+
7
7
  Contact Us requires the Formtastic Gem. Read more about Formtastic @ https://github.com/justinfrench/formtastic
8
8
 
9
- INSTALL
10
- -------
9
+ ## INSTALLATION
10
+
11
11
  In your `Gemfile`, add the following dependencies:
12
+
12
13
  gem 'formtastic'
13
14
  gem 'contact_us'
14
- Run:
15
+
16
+ From `Rails.root` run:
17
+
15
18
  $ bundle install
19
+ $ rake contact_us:install
20
+
21
+ Modify the installed initializer's mailer to settings to use your own email address.
22
+
23
+ ## CONFIGURATION
24
+
25
+ The installation generator creates the `contact_us.rb` initializer within your apps `config/initializers` directory.
16
26
 
17
- CONFIGURATION
18
- -------------
27
+ Modify the mailer to setting to be where you would like to send the contact form emails.
19
28
 
20
- # Usage
29
+ The generator has also copied the view files to `app/views/contact_us`, and you can customize them to suit your needs.
21
30
 
22
- # TODO
31
+ ## TODO
23
32
 
24
- * config option for contact email
25
- * install generator to copy views
26
- * finish readme documentation
27
33
  * 100% test coverage
28
34
  * i18n
29
35
 
30
- Copyright (c) 2011 Jeff Dutil, released under the MIT license.
36
+ Copyright (c) 2011 Jeff Dutil, released under the MIT license.
@@ -1,5 +1,2 @@
1
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
2
  end
@@ -1,9 +1,9 @@
1
1
  class ContactUs::ContactMailer < ActionMailer::Base
2
2
  def contact_email(contact)
3
3
  @message = contact.message
4
-
5
- mail(:to => "contact@YOUR-SITE.com",
4
+
5
+ mail :from => contact.email,
6
6
  :subject => "Contact Us message from #{contact.email}",
7
- :from => contact.email)
7
+ :to => ContactUs.mailer_to
8
8
  end
9
9
  end
@@ -0,0 +1,3 @@
1
+ <p><%= @message %><p>
2
+ <p>---------------------</p>
3
+ <p>Sent by contact form.</p>
@@ -0,0 +1,4 @@
1
+ <%= @message %>
2
+
3
+ -------------------------------------
4
+ Sent by contact form.
@@ -2,4 +2,5 @@
2
2
  # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
3
 
4
4
  en:
5
- hello: "Hello world"
5
+ contact_us:
6
+ sent_by: "Sent by "
@@ -1,3 +1,13 @@
1
1
  module ContactUs
2
2
  require 'contact_us/engine'
3
+
4
+ # Address which sends Devise e-mails.
5
+ mattr_accessor :mailer_to
6
+
7
+ # Default way to setup ContactUs. Run rake contact_us:install to create
8
+ # a fresh initializer with all configuration values.
9
+ def self.setup
10
+ yield self
11
+ end
12
+
3
13
  end
@@ -1,3 +1,3 @@
1
1
  module ContactUs
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,59 @@
1
+ require 'rails/generators'
2
+
3
+ namespace :contact_us do
4
+ desc "Install ContactUs"
5
+ task :install do
6
+ gem_path = __FILE__
7
+ gem_path = gem_path.split("/")
8
+
9
+ gem_path = gem_path[0..-4]
10
+ gem_path = gem_path.join("/")
11
+
12
+ Rails::Generators::Base.source_root(gem_path)
13
+ copier = Rails::Generators::Base.new
14
+
15
+ unless File.exists?(Rails.root.join("config/initializers/contact_us.rb"))
16
+ print "Now copying initializer!\n"
17
+
18
+ locales_path = gem_path + "/lib/templates/*"
19
+ app_path = Rails.root.join("config/initializers")
20
+ unless File.directory?(app_path)
21
+ app_path.mkdir
22
+ end
23
+ Dir.glob(locales_path).each do |file|
24
+ copier.copy_file file, File.join(app_path, File.basename(file))
25
+ end
26
+ end
27
+
28
+ print "Now copying locales files!\n"
29
+
30
+ locales_path = gem_path + "/config/locales/*.yml"
31
+ app_path = Rails.root.join("config/locales")
32
+ unless File.directory?(app_path)
33
+ app_path.mkdir
34
+ end
35
+ Dir.glob(locales_path).each do |file|
36
+ copier.copy_file file, File.join(app_path, File.basename(file))
37
+ end
38
+
39
+ print "Now copying view files for customization!\n"
40
+
41
+ locales_path = gem_path + "/app/views/contact_us/contact_mailer/*"
42
+ app_path = Rails.root.join("app/views/contact_us/contact_mailer")
43
+ unless File.directory?(app_path)
44
+ app_path.mkdir
45
+ end
46
+ Dir.glob(locales_path).each do |file|
47
+ copier.copy_file file, File.join(app_path, File.basename(file))
48
+ end
49
+
50
+ locales_path = gem_path + "/app/views/contact_us/contacts/*"
51
+ app_path = Rails.root.join("app/views/contact_us/contacts")
52
+ unless File.directory?(app_path)
53
+ app_path.mkdir
54
+ end
55
+ Dir.glob(locales_path).each do |file|
56
+ copier.copy_file file, File.join(app_path, File.basename(file))
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,6 @@
1
+ # Use this hook to configure contact mailer.
2
+ ContactUs.setup do |config|
3
+ # ==> Mailer Configuration
4
+ # Configure the e-mail address which will be shown in ContactMailer.
5
+ config.mailer_to = "contact@please-change-me.com"
6
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contact_us
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jeff Dutil
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-03 00:00:00 -04:00
18
+ date: 2011-05-04 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -38,14 +38,17 @@ files:
38
38
  - app/helpers/contact_us/contacts_helper.rb
39
39
  - app/mailers/contact_us/contact_mailer.rb
40
40
  - app/models/contact_us/contact.rb
41
- - app/views/contact_us/contact_mailer/contact.html.erb
41
+ - app/views/contact_us/contact_mailer/contact_email.text.html.erb
42
+ - app/views/contact_us/contact_mailer/contact_email.text.plain.erb
42
43
  - app/views/contact_us/contacts/new.html.erb
43
- - config/locales/en.yml
44
+ - config/locales/contact_us.en.yml
44
45
  - config/routes.rb
45
46
  - contact_us.gemspec
46
47
  - lib/contact_us.rb
47
48
  - lib/contact_us/engine.rb
48
49
  - lib/contact_us/version.rb
50
+ - lib/tasks/install.rake
51
+ - lib/templates/contact_us.rb
49
52
  has_rdoc: true
50
53
  homepage: https://github.com/jdutil/contact_us
51
54
  licenses: []
@@ -1,3 +0,0 @@
1
- <p><%= @message %><p>
2
- <p>-------------------------------------</p>
3
- <p>Sent by BurlingtonWebApps.com contact form.</p>