Permalink
Browse files

Rename SimpleForm to MailForm and push to new fork.

  • Loading branch information...
1 parent 8cb9c9c commit af71933faa1dd374370029952153f89284f0d4a6 @josevalim josevalim committed Dec 24, 2009
View
@@ -1,3 +1,7 @@
+* Version 1.0
+
+* Rename to mail_form and launch Rails 2.3 branch.
+
* Version 0.4
* Added support to template
View
@@ -1,9 +1,9 @@
-== Simple Form
+== MailForm
-Simple Form is a ready to go contact form. Just the following lines are needed
-to have a contact form (including the e-mail):
+MailForm allows you to send an e-mail straight from a form. For instance,
+if you want to make a contact form just the following lines are needed (including the e-mail):
- class ContactForm < SimpleForm
+ class ContactForm < MailForm
subject "My Contact Form"
recipients "your.email@your.domain.com"
sender{|c| %{"#{c.name}" <#{c.email}>} }
@@ -22,40 +22,40 @@ Then you start a script/console and type:
c.deliver
Check your inbox and the e-mail will be there, with the sent fields (assuming
-that you configured your smtp properly).
+that you configured your delivery method properly).
-SimpleForm also support attachments, I18n, error messages like in ActiveRecord
+MailForm also support attachments, I18n, error messages like in ActiveRecord
(so it works with custom FormBuilders) and can also send the user request information
-in the contact mail.
+in the mail.
It's tested and compatible with Rails 2.2.x and Rails 2.3.x.
== Installation
-Install Simple Form is very easy. It is stored in Gemcutter, so just run the following:
+Install MailForm is very easy. It is stored in Gemcutter, so just run the following:
- gem sources -a http://gemcutter.org
- sudo gem install simple_form
+ sudo gem install mail_form
If you want it as plugin, just do:
- script/plugin install git://github.com/josevalim/simple_form.git
+ script/plugin install git://github.com/plataformatec/mail_form.git
== Request
-SimpleForm makes easy to append user information to the contact mail. You just
+MailForm makes easy to append user information to the contact mail. You just
have to do:
- class ContactForm < SimpleForm
+ class ContactForm < MailForm
append :remote_ip, :user_agent, :session
# ...
end
And in your controller:
- @contact_form = ContactForm.new(params[:contact_form], request)
+ @contact_form = ContactForm.new(params[:contact_form])
+ @contact_form.request = request
-And the remote ip, user agent and session will be sent in the e-mail in a
+The remote ip, user agent and session will be sent in the e-mail in a
request information session. You can give to append any method that the
request object responds to.
@@ -83,12 +83,12 @@ Options:
Examples:
- class ContactForm < SimpleForm
+ class ContactForm < MailForm
attributes :name, :validate => true
attributes :email, :validate => /[^@]+@[^\.]+\.[\w\.\-]+/
attributes :message
attributes :screenshot, :attachment => true, :validate => :screenshot_required?
- attributes :nickname, :captcha => true
+ attributes :nickname, :captcha => true
def screenshot_required?
# ...
@@ -106,15 +106,15 @@ Examples:
c.errors.full_messages #=> [ "Name can't be blank", "Email is invalid" ]
c = ContactForm.new(:name => 'José', :email => 'your@email.com')
- # save is an alias to deliver to allow it to work with InheritedResources
+ # save is an alias to deliver
c.save #=> true
==== subject(string_or_symbol_or_block)
Declares the subject of the contact email. It can be a string or a proc or a symbol.
When a symbol is given, it will call a method on the form object with the same
-name as the symbol. As a proc, it receives a simple form instance. It defaults
+name as the symbol. As a proc, it receives a mail form instance. It defaults
to the class human name.
subject "My Contact Form"
@@ -125,36 +125,36 @@ to the class human name.
Declares contact email sender. It can be a string or a proc or a symbol.
When a symbol is given, it will call a method on the form object with the same
-name as the symbol. As a proc, it receives a simple form instance. By default is:
+name as the symbol. As a proc, it receives a mail form instance. By default is:
- sender{ |c| c.email }
+ sender { |c| c.email }
-This requires that your SimpleForm object have an email attribute.
+This requires that your MailForm object have an email attribute.
==== recipients(string_or_array_or_symbol_or_block)
Who will receive the e-mail. Can be a string or array or a symbol or a proc.
When a symbol is given, it will call a method on the form object with the same
-name as the symbol. As a proc, it receives a simple form instance.
+name as the symbol. As a proc, it receives a mail form instance.
Both the proc and the symbol must return a string or an array. By default is nil.
==== template(string_or_symbol_or_proc)
Allow you to set the template that is going to rendered. This allows you to have
-several simple_form instances, using different templates.
+several MailForm instances, using different templates.
==== headers(hash)
Additional headers to your e-mail.
== I18n
-All models, attributes and messages in SimpleForm can be used with localized.
+All models, attributes and messages in MailForm can be used with localized.
Below is an I18n example file:
- simple_form:
+ mail_form:
models:
contact_form: "Your site contact form"
attributes:
@@ -170,15 +170,17 @@ Below is an I18n example file:
remote_ip: "IP Address"
user_agent: "Browser"
-== Contributors
+== Maintainers
* José Valim - http://github.com/josevalim
* Carlos Antonio - http://github.com/carlosantoniodasilva
+
+== Contributors
+
* Andrew Timberlake - http://github.com/andrewtimberlake
== Bugs and Feedback
-If you discover any bugs, please send an e-mail to contact@plataformatec.com.be
-If you just want to give some positive feedback or drop a line, that's fine too!
+If you discover any bug, please use github issues tracker.
-Copyright (c) 2009 Plataforma Tec http://blog.plataformatec.com.br/
+Copyright (c) 2009 Plataforma Tec http://blog.plataformatec.com.br/
View
@@ -1,18 +1,18 @@
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
-require File.join(File.dirname(__FILE__), "lib", "simple_form", "version")
+require File.join(File.dirname(__FILE__), "lib", "mail_form", "version")
-desc 'Run tests for SimpleForm.'
+desc 'Run tests for MailForm.'
Rake::TestTask.new(:test) do |t|
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
-desc 'Generate documentation for SimpleForm.'
+desc 'Generate documentation for MailForm.'
Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
- rdoc.title = 'SimpleForm'
+ rdoc.title = 'MailForm'
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('README')
rdoc.rdoc_files.include('MIT-LICENSE')
@@ -22,12 +22,12 @@ end
begin
require 'jeweler'
Jeweler::Tasks.new do |s|
- s.name = "simple_form"
- s.version = SimpleForm::VERSION
- s.summary = "Simple easy contact form for Rails with I18n, validations, attachments and request information."
+ s.name = "mail_form"
+ s.version = MailForm::VERSION
+ s.summary = "Send e-mail straight from forms in Rails with I18n, validations, attachments and request information."
s.email = "contact@plataformatec.com.br"
- s.homepage = "http://github.com/josevalim/simple_form"
- s.description = "Simple easy contact form for Rails with I18n, validations, attachments and request information."
+ s.homepage = "http://github.com/plataformatec/mail_form"
+ s.description = "Send e-mail straight from forms in Rails with I18n, validations, attachments and request information."
s.authors = ['José Valim', 'Carlos Antônio']
s.files = FileList["[A-Z]*", "{lib,views}/**/*"]
end
@@ -1,11 +1,10 @@
-dir = File.dirname(__FILE__)
-require File.join(dir, 'simple_form', 'base')
-require File.join(dir, 'simple_form', 'dsl')
-require File.join(dir, 'simple_form', 'errors')
-require File.join(dir, 'simple_form', 'notifier')
+require 'mail_form/base'
+require 'mail_form/dsl'
+require 'mail_form/errors'
+require 'mail_form/notifier'
-class SimpleForm
- extend SimpleForm::DSL
+class MailForm
+ extend MailForm::DSL
ACCESSORS = [ :form_attributes, :form_validatable, :form_subject,
:form_attachments, :form_recipients, :form_sender,
@@ -30,4 +29,4 @@ class SimpleForm
template 'contact'
end
-SimpleForm::Notifier.template_root = File.join(dir, '..', 'views')
+MailForm::Notifier.template_root = File.join(File.dirname(__FILE__), '..', 'views')
@@ -1,4 +1,4 @@
-class SimpleForm
+class MailForm
attr_accessor :request
# Initialize assigning the parameters given as hash (just as in ActiveRecord).
@@ -85,7 +85,7 @@ def id
#
def deliver(run_validations=true)
if !run_validations || (self.not_spam? && self.valid?)
- SimpleForm::Notifier.deliver_contact(self)
+ MailForm::Notifier.deliver_contact(self)
return true
else
return false
@@ -96,31 +96,31 @@ def deliver(run_validations=true)
# Add a human attribute name interface on top of I18n. If email is received as
# attribute, it will look for a translated name on:
#
- # simple_form:
+ # mail_form:
# attributes:
# email: E-mail
#
def self.human_attribute_name(attribute, options={})
- I18n.translate("attributes.#{attribute}", options.merge(:default => attribute.to_s.humanize, :scope => [:simple_form]))
+ I18n.translate("attributes.#{attribute}", options.merge(:default => attribute.to_s.humanize, :scope => [:mail_form]))
end
# Add a human name interface on top of I18n. If you have a model named
- # SimpleForm, it will search for the localized name on:
+ # MailForm, it will search for the localized name on:
#
- # simple_form:
+ # mail_form:
# models:
# contact_form: Contact form
#
def self.human_name(options={})
underscored = self.name.demodulize.underscore
- I18n.translate("models.#{underscored}", options.merge(:default => underscored.humanize, :scope => [:simple_form]))
+ I18n.translate("models.#{underscored}", options.merge(:default => underscored.humanize, :scope => [:mail_form]))
end
# Return the errors in this form. The object returned as the same API as the
# ActiveRecord one.
#
def errors
- @errors ||= SimpleForm::Errors.new(self)
+ @errors ||= MailForm::Errors.new(self)
end
end
@@ -1,4 +1,4 @@
-class SimpleForm
+class MailForm
module DSL
protected
@@ -23,7 +23,7 @@ module DSL
#
# == Examples
#
- # class ContactForm < SimpleForm
+ # class ContactForm < MailForm
# attributes :name, :validate => true
# attributes :email, :validate => /^([^@]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
# attributes :message
@@ -68,7 +68,7 @@ def attribute(*accessors)
#
# == Examples
#
- # class ContactForm < SimpleForm
+ # class ContactForm < MailForm
# subject "My Contact Form"
# end
#
@@ -84,11 +84,11 @@ def subject(duck=nil, &block)
#
# sender{ |c| c.email }
#
- # This requires that your SimpleForm object have an email attribute.
+ # This requires that your MailForm object have an email attribute.
#
# == Examples
#
- # class ContactForm < SimpleForm
+ # class ContactForm < MailForm
# # Change sender to include also the name
# sender { |c| %{"#{c.name}" <#{c.email}>} }
# end
@@ -108,7 +108,7 @@ def sender(duck=nil, &block)
#
# == Examples
#
- # class ContactForm < SimpleForm
+ # class ContactForm < MailForm
# recipients [ "first.manager@domain.com", "second.manager@domain.com" ]
# end
#
@@ -121,7 +121,7 @@ def recipients(duck=nil, &block)
#
# == Examples
#
- # class ContactForm < SimpleForm
+ # class ContactForm < MailForm
# headers { :content_type => 'text/html' }
# end
#
@@ -140,8 +140,8 @@ def headers(hash)
#
# == Examples
#
- # class ContactForm < SimpleForm
- # # look for a template in views/simple_form/notifier/my_template.erb
+ # class ContactForm < MailForm
+ # # look for a template in views/mail_form/notifier/my_template.erb
# template 'my_template'
# end
#
@@ -159,7 +159,7 @@ def template(new_template)
#
# == Examples
#
- # class ContactForm < SimpleForm
+ # class ContactForm < MailForm
# append :remote_ip, :user_agent, :session, :cookies
# end
#
Oops, something went wrong.

0 comments on commit af71933

Please sign in to comment.