contactus 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +36 -0
- data/Rakefile +30 -0
- data/app/controllers/contactus/application_controller.rb +5 -0
- data/app/controllers/contactus/contact_forms_controller.rb +31 -0
- data/app/models/contactus/contact_form.rb +43 -0
- data/app/views/contactus/contact_forms/create.html.haml +2 -0
- data/app/views/contactus/contact_forms/new.html.haml +11 -0
- data/config/locales/es.yml +31 -0
- data/config/routes.rb +9 -0
- data/lib/contactus.rb +21 -0
- data/lib/contactus/engine.rb +17 -0
- data/lib/contactus/tasks/install.rb +35 -0
- data/lib/contactus/version.rb +3 -0
- data/lib/tasks/hola_tasks.rake +10 -0
- data/lib/templates/contactus.rb +17 -0
- data/spec/acceptance/contactus/contact_forms_spec.rb +44 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/welcome_controller.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +17 -0
- data/spec/dummy/app/views/welcome/index.html.haml +0 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +23 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +32 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +36 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/contactus.rb +14 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/schema.rb +16 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +33341 -0
- data/spec/dummy/log/test.log +7165 -0
- data/spec/dummy/public/404.html +58 -0
- data/spec/dummy/public/422.html +58 -0
- data/spec/dummy/public/500.html +57 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/2dfab99b7c59e9348262d762b6812d5e +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/396416ac5502a70f4a605dbfa52bcf57 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/4ea2fca734744bdca2af1f2681057f0e +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/6c76b57c176c88c8608b0c573d9e4d73 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/7dbe77fde0bcb62545797187d586459a +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/fb3c798521567a09f64a61244642805b +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/factories/contact_form.rb +9 -0
- data/spec/models/contactus/contact_form_spec.rb +86 -0
- data/spec/spec_helper.rb +14 -0
- metadata +317 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3213c8e94234c29cb803843ccb8da865c6d3e39b
|
4
|
+
data.tar.gz: a53bfaf1530e4cbc21891206bd05ab8871fbc6f5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8d0a46381c07ace550f26f4036e06812034a1c2b3170180c16f3692087003a3bb9b35d836165fbd5df6ead8b74411f1104ac4668b23e9f757e57d336c374cd09
|
7
|
+
data.tar.gz: 5fff18731845e27020ebe2cf00fbbba615c2e853ed8cf3db440950721f31833ff7580920da555aca2b2ee5c7972924c11fe97363fb3292e0d302e3a04df49b34
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2013 YOURNAME
|
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,36 @@
|
|
1
|
+
= Contactus
|
2
|
+
|
3
|
+
Contactus is a simple Ruby on Rails gem that generate a contact form for your site.
|
4
|
+
|
5
|
+
Note: This game is still in development, thanks your patience :P
|
6
|
+
|
7
|
+
== How to use this gem
|
8
|
+
|
9
|
+
Add the gem to your Gemfile
|
10
|
+
|
11
|
+
gem 'contactus'
|
12
|
+
|
13
|
+
Install the gem:
|
14
|
+
|
15
|
+
$ bundler
|
16
|
+
$ bundle exec rake contactus:install
|
17
|
+
|
18
|
+
Go to your site
|
19
|
+
|
20
|
+
$ http://0.0.0.0:3000/contact
|
21
|
+
|
22
|
+
== Customization
|
23
|
+
|
24
|
+
There will be a initializer file called contactus.rb, where you can configure the next config variables:
|
25
|
+
|
26
|
+
# Configure the e-mail address which should receive the email
|
27
|
+
config.mailer_to = "contact@example.com"
|
28
|
+
|
29
|
+
# Configure the e-mail address which should receive the cc email
|
30
|
+
#config.mailer_cc = "contact@example.com"
|
31
|
+
|
32
|
+
# Configure extra fields
|
33
|
+
#config.extra_fields = %w(city phone)
|
34
|
+
|
35
|
+
# Configure extra required fields
|
36
|
+
#config.required_extra_fields = %w(country address)
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'Contactus'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
Bundler::GemHelper.install_tasks
|
23
|
+
|
24
|
+
require 'rspec/core'
|
25
|
+
require 'rspec/core/rake_task'
|
26
|
+
|
27
|
+
desc "Run all specs in spec directory (excluding plugin specs)"
|
28
|
+
RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
|
29
|
+
|
30
|
+
task :default => :spec
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Contactus
|
2
|
+
|
3
|
+
class ContactFormsController < ApplicationController
|
4
|
+
|
5
|
+
def new
|
6
|
+
@contact_form = ContactForm.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def create
|
10
|
+
begin
|
11
|
+
@contact_form = ContactForm.new(params[:contactus_contact_form])
|
12
|
+
@contact_form.request = request
|
13
|
+
|
14
|
+
if !@contact_form.deliver
|
15
|
+
if @contact_form.spam?
|
16
|
+
flash[:error] = I18n.t('.contactus.contact_forms.spam')
|
17
|
+
redirect_to root_path
|
18
|
+
else
|
19
|
+
render :new
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
rescue ScriptError
|
24
|
+
flash[:error] = I18n.t('.contactus.contact_forms.spam')
|
25
|
+
redirect_to root_path
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Contactus
|
2
|
+
|
3
|
+
class Contactus::ContactForm < MailForm::Base
|
4
|
+
attribute :name, :validate => true
|
5
|
+
attribute :email, :validate => /\A([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})\z/i
|
6
|
+
attribute :message, :validate => true
|
7
|
+
attribute :nickname, :captcha => true
|
8
|
+
|
9
|
+
append :remote_ip, :user_agent, :session
|
10
|
+
|
11
|
+
if Contactus.extra_fields
|
12
|
+
Contactus.extra_fields.each do |field|
|
13
|
+
self.class_eval do; attribute field.to_sym; end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
if Contactus.required_extra_fields
|
18
|
+
Contactus.required_extra_fields.each do |field|
|
19
|
+
self.class_eval do; attribute field.to_sym, :validate => true; end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def headers
|
24
|
+
default_header.merge(cc_header)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def default_header
|
30
|
+
{
|
31
|
+
:subject => I18n.t('.contactus.contact_forms.subject'),
|
32
|
+
:to => Contactus.mailer_to,
|
33
|
+
:from => %("#{name}" <#{email}>)
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
def cc_header
|
38
|
+
(Contactus.mailer_cc)? { :cc => Contactus.mailer_cc } : {}
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
= simple_form_for @contact_form do |f|
|
2
|
+
|
3
|
+
= f.input :name, :autofocus => true, :required => true
|
4
|
+
= f.input :city
|
5
|
+
= f.input :email, :required => true
|
6
|
+
= f.input :message, :as => :text, :required => true
|
7
|
+
|
8
|
+
.hidden
|
9
|
+
= f.input :nickname, :hint => t('.captcha_field', default: 'Leave this field blank!')
|
10
|
+
|
11
|
+
= f.button :submit, t('.send', default: 'Send')
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
es:
|
4
|
+
mail_form:
|
5
|
+
models:
|
6
|
+
contactus/contact_form:
|
7
|
+
one: "Contacto"
|
8
|
+
other: 'Contactos'
|
9
|
+
|
10
|
+
attributes:
|
11
|
+
contactus/contact_form:
|
12
|
+
name: "Nombres y Apellidos"
|
13
|
+
email: 'Correo electrónico'
|
14
|
+
message: "Comentarios"
|
15
|
+
|
16
|
+
request:
|
17
|
+
title: "Información técnica sobre el usuario"
|
18
|
+
remote_ip: "Dirección IP"
|
19
|
+
user_agent: "Navegador"
|
20
|
+
|
21
|
+
|
22
|
+
contactus:
|
23
|
+
contact_forms:
|
24
|
+
success: 'Gracias por escribirnos, pronto nos pondremos en contacto contigo.'
|
25
|
+
spam: 'Lo sentimos, este mensaje aparece como spam y no se entregó.'
|
26
|
+
subject: 'Alguien se a puesto en contacto.'
|
27
|
+
|
28
|
+
new:
|
29
|
+
send: 'Enviar'
|
30
|
+
captcha_field: 'Deje este campo en blanco'
|
31
|
+
|
data/config/routes.rb
ADDED
data/lib/contactus.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "contactus/engine"
|
2
|
+
|
3
|
+
module Contactus
|
4
|
+
|
5
|
+
# Address to send the email.
|
6
|
+
mattr_accessor :mailer_to
|
7
|
+
|
8
|
+
# Address to send the cc email.
|
9
|
+
mattr_accessor :mailer_cc
|
10
|
+
|
11
|
+
# Extra fields
|
12
|
+
mattr_accessor :extra_fields
|
13
|
+
|
14
|
+
# Required Extra fields
|
15
|
+
mattr_accessor :required_extra_fields
|
16
|
+
|
17
|
+
def self.setup
|
18
|
+
yield self
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'mail_form'
|
2
|
+
require 'haml-rails'
|
3
|
+
require 'simple_form'
|
4
|
+
require 'rails-i18n'
|
5
|
+
|
6
|
+
module Contactus
|
7
|
+
class Engine < ::Rails::Engine
|
8
|
+
|
9
|
+
config.generators do |g|
|
10
|
+
g.test_framework :rspec, fixture: false
|
11
|
+
g.fixture_replacement :factory_girl, dir: 'spec/factories'
|
12
|
+
g.assets false
|
13
|
+
g.helper false
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Contactus
|
4
|
+
module Tasks
|
5
|
+
class Install
|
6
|
+
class << self
|
7
|
+
|
8
|
+
def run
|
9
|
+
copy_initializer_file
|
10
|
+
puts "Done!"
|
11
|
+
end
|
12
|
+
|
13
|
+
def copy_initializer_file
|
14
|
+
print "Copying initializer file...\n"
|
15
|
+
app_path = Rails.root.join("config/initializers")
|
16
|
+
copier.copy_file File.join(gem_path, 'lib/templates/contactus.rb'), File.join(app_path, 'contactus.rb')
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def gem_path
|
22
|
+
File.expand_path('../../..', File.dirname(__FILE__))
|
23
|
+
end
|
24
|
+
|
25
|
+
def copier
|
26
|
+
unless @copier
|
27
|
+
Rails::Generators::Base.source_root(gem_path)
|
28
|
+
@copier = Rails::Generators::Base.new
|
29
|
+
end
|
30
|
+
@copier
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Use this hook to configure contact mailer.
|
2
|
+
|
3
|
+
Contactus.setup do |config|
|
4
|
+
|
5
|
+
# Configure the e-mail address which should receive the email
|
6
|
+
config.mailer_to = "contact@example.com"
|
7
|
+
|
8
|
+
# Configure the e-mail address which should receive the cc email
|
9
|
+
#config.mailer_cc = "contact@example.com"
|
10
|
+
|
11
|
+
# Configure extra fields
|
12
|
+
#config.extra_fields = %w(city phone)
|
13
|
+
|
14
|
+
# Configure extra required fields
|
15
|
+
#config.required_extra_fields = %w(country address)
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
feature 'Contact Form', %q{
|
6
|
+
As a user
|
7
|
+
I can send a message using the contact form
|
8
|
+
} do
|
9
|
+
|
10
|
+
before do
|
11
|
+
Contactus.mailer_to = "webmaster@example.com"
|
12
|
+
visit "/contact"
|
13
|
+
end
|
14
|
+
|
15
|
+
scenario 'without mandatory fields' do
|
16
|
+
click_button 'Enviar'
|
17
|
+
|
18
|
+
page.should have_content "Nombres y Apellidosno puede estar en blanco"
|
19
|
+
page.should have_content "Correo electrónicono puede estar en blanco"
|
20
|
+
page.should have_content "Comentariosno puede estar en blanco"
|
21
|
+
end
|
22
|
+
|
23
|
+
scenario 'with mandatory fields' do
|
24
|
+
fill_in "Nombres y Apellidos", with: 'Bill Hicks'
|
25
|
+
fill_in "Correo electrónico", with: 'beelzebozo@example.com'
|
26
|
+
fill_in "Comentarios", with: "If you think you’re free, try going somewhere without fucking money, okay?"
|
27
|
+
|
28
|
+
click_button 'Enviar'
|
29
|
+
|
30
|
+
page.should have_content "Gracias por escribirnos, pronto nos pondremos en contacto contigo."
|
31
|
+
end
|
32
|
+
|
33
|
+
scenario 'spam email' do
|
34
|
+
fill_in "Nombres y Apellidos", with: 'Bill Hicks'
|
35
|
+
fill_in "Correo electrónico", with: 'beelzebozo@example.com'
|
36
|
+
fill_in "Comentarios", with: "If you think you’re free, try going somewhere without fucking money, okay?"
|
37
|
+
fill_in "Nickname", with: "Hey there"
|
38
|
+
|
39
|
+
click_button 'Enviar'
|
40
|
+
|
41
|
+
page.should have_content "Lo sentimos, este mensaje aparece como spam y no se entregó."
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
== README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
25
|
+
|
26
|
+
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
28
|
+
<tt>rake doc:app</tt>.
|
data/spec/dummy/Rakefile
ADDED