radiant-mailer-extension 1.0.4 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,240 @@
1
+ # Mailer Extension for Radiant
2
+
3
+ [![Build Status](https://secure.travis-ci.org/radiant/radiant-mailer-extension.png)](http://travis-ci.org/radiant/radiant-mailer-extension)
4
+
5
+ The Mailer extension enables form mail on a page.
6
+
7
+ ## Usage
8
+
9
+ You can define email templates using pages parts (email, and/or email_html).
10
+ You configure the recipients and other Mailer settings in a "mailer" part:
11
+
12
+ subject: From the website of Whatever
13
+ from: noreply@example.com
14
+ redirect_to: /contact/thank-you
15
+ recipients:
16
+ - one@one.com
17
+ - two@two.com
18
+
19
+ The following tags are available to help you build the form:
20
+
21
+ <r:mailer:form name=""> ... </r:mailer:form>
22
+ <r:mailer:text name="" />
23
+ <r:mailer:password name="" />
24
+ <r:mailer:reset name="" />
25
+ <r:mailer:checkbox name="" />
26
+ <r:mailer:radio name="" />
27
+ <r:mailer:file name="" />
28
+ <r:mailer:radiogroup name=""> ... </r:mailer:radiogroup>
29
+ <r:mailer:select name=""> ... </r:mailer:select>
30
+ <r:mailer:date_select name=""/>
31
+ <r:mailer:textarea name=""> ... </r:mailer:textarea>
32
+ <r:mailer:option name="" />
33
+ <r:mailer:submit name="" />
34
+ <r:mailer:image name="" />
35
+ <r:mailer:submit_placeholder />
36
+
37
+ When processing the form (in email and email_html), the following tags are
38
+ available:
39
+
40
+ <r:mailer:get name="" />
41
+ <r:mailer:get_each name=""> ... </r:mailer:get_each>
42
+ <r:mailer:index />
43
+
44
+ Simple example of a form:
45
+
46
+ <r:mailer:form>
47
+ <r:mailer:hidden name="subject" value="Email from my Radiant site!" /> <br/>
48
+ Name:<br/>
49
+ <r:mailer:text name="name" /> <br/>
50
+ Message:<br/>
51
+ <r:mailer:textarea name="message" /> <br/>
52
+ <r:mailer:submit name="Send" />
53
+ </r:mailer:form>
54
+
55
+ ### Required fields
56
+
57
+ You can specify fields which must be populated or the form will be invalid and will redisplay the page with an error informing the user to populate those fields.
58
+
59
+ Simple example of a required field:
60
+
61
+ <r:mailer:form>
62
+ ...
63
+ Name:<br/>
64
+ <r:mailer:text name="name" required="true"/> <br/>
65
+ ...
66
+ <r:mailer:submit name="Send" />
67
+ </r:mailer:form>
68
+
69
+ Simple example of a required field with user-defined message:
70
+
71
+ <r:mailer:form>
72
+ ...
73
+ Name:<br/>
74
+ <r:mailer:text name="name" required="should not be blank"/> <br/>
75
+ ...
76
+ <r:mailer:submit name="Send" />
77
+ </r:mailer:form>
78
+
79
+ You can also specify fields which must be validated 'as_email' (i.e. a@b.com).
80
+
81
+ Simple example of a required field with email address validation:
82
+
83
+ <r:mailer:form>
84
+ ...
85
+ Reply-To:<br/>
86
+ <r:mailer:text name="reply_email" required="as_email"/> <br/>
87
+ ...
88
+ <r:mailer:submit name="Send" />
89
+ </r:mailer:form>
90
+
91
+ You can also specify fields which must be validated as defined regexp (i.e. /^\d{2}\.\d{2}\.\d{4}\$/ for date dd.mm.yyyy).
92
+
93
+
94
+ Simple example of a required field with regexp validation:
95
+
96
+ <r:mailer:form>
97
+ ...
98
+ Birthday:<br/>
99
+ <r:mailer:text name="birthday" required="/^\d{2}\.\d{2}\.\d{4}\$/"/> <br/>
100
+ ...
101
+ <r:mailer:submit name="Send" />
102
+ </r:mailer:form>
103
+
104
+ Finally, you can put all field validations in the "mailer" part:
105
+
106
+ subject: From the website of Whatever
107
+ from: noreply@example.com
108
+ redirect_to: /contact/thank-you
109
+ recipients:
110
+ - one@one.com
111
+ required:
112
+ name: "true"
113
+ email: as_email
114
+ message: "true"
115
+
116
+ The field names above are "name," "email," and "message." Note the quotation marks around true values. If you do your field validations this way, Mailer will ignore any validations you attempt through your radius tags. This method of validation keeps Mailer from adding hidden inputs to keep track of required fields. See the caveat below.
117
+
118
+
119
+ ### Spam blocking
120
+
121
+ #### No Links
122
+
123
+ You can specify which fields may not contain anything that looks like a link in the "mailer" part. For example:
124
+
125
+ subject: From the website of Whatever
126
+ from: noreply@example.com
127
+ redirect_to: /contact/thank-you
128
+ recipients:
129
+ - one@one.com
130
+ disallow_links:
131
+ - comments
132
+ - questions
133
+
134
+ The comments and questions fields would throw an error if the user or a spam bot entered the following phrases: "www", "&amp;", "http:", "mailto:", "bcc:", "href", "multipart", "[url", or "Content-Type:".
135
+
136
+ #### Hidden field must be blank
137
+
138
+ You can also include one field on your form that must be left blank. If anyone enters something in the field, the field throws an error. The tactic here is to hide the field from human readers, but to leave the field visible to spam bots. Here is how you would edit the "mailer" part to implement this:
139
+
140
+ subject: From the website of Whatever
141
+ from: noreply@example.com
142
+ redirect_to: /contact/thank-you
143
+ recipients:
144
+ - one@one.com
145
+ leave_blank: your_field_name
146
+
147
+ "your_field_name" is the name of the field you want to hide. It is up to you to hide the field when you construct your form. I would recommend against using a traditional hidden input field. Use style="display:none" instead.
148
+
149
+ #### Blocked Words
150
+
151
+ You can also add specific words to the mail config, which if present in any of the input fields, will throw an error. This way if you get hit by a barage of say, 'imabot@spammer.net', you just add that term to the block list. Here is how you would edit the "mailer" part to implement this:
152
+
153
+ subject: From the website of Whatever
154
+ from: noreply@mydomain.com
155
+ redirect_to: /contact/thank-you
156
+ max_filesize: 100000
157
+ recipients:
158
+ - one@one.com
159
+ - two@two.com
160
+ block_words:
161
+ - spammer
162
+ - badword
163
+ - imabot
164
+
165
+ ### File attachments
166
+
167
+ In many cases it is desirable to limit the maximum size of a file that may be uploaded. This is set as the max_filesize attribute for mailers in the mailer page part. Any file included in the form will have the limit imposed. Following is a simple example mailer part that includes a file size limit of 100,000 bytes:
168
+
169
+ subject: From the website of Whatever
170
+ from: noreply@mydomain.com
171
+ redirect_to: /contact/thank-you
172
+ max_filesize: 100000
173
+ recipients:
174
+ - one@one.com
175
+ - two@two.com
176
+
177
+ The following is a simple form that might be used to submit a file for the above configuration:
178
+
179
+ <r:mailer:form name="contact">
180
+ Type your message: <r:mailer:text name="themessage" /> <br/>
181
+ Select a file: <r:mailer:file name="thefile" /> <br/>
182
+ <r:mailer:submit value="submit"/>
183
+ </r:mailer:form>
184
+
185
+ If a user does not select a file the other form contents will still be e-mailed. The `<r:mailer:get name="foo" />` (with `<r:mailer:file name="foo" />`) will provide the uploaded file name.
186
+
187
+ If you are using email or email_html parts then the `<r:mailer:get name="" />` tag can be used to retrieve the name of the uploaded file. If no file was uploaded "" will be returned.
188
+
189
+ ### Submit placeholder
190
+
191
+ If you wish to show that activity is taking place during submission you may use the `<r:mailer:submit_placeholder />` tag in your form. This will insert a hidden div with the contents of the submit_placeholder page part. The div will be displayed when the user clicks any submit button.
192
+
193
+ ### User-provided Configuration
194
+
195
+ Sometimes, rather than explicitly configuring the recipients and such in the mailer part, you'd rather have them passed in by the person submitting the form. Mailer supports this by allowing you to specify a form field to pull the value from:
196
+
197
+ from_field: my_form_field_that_contains_the_from_email_address
198
+
199
+ Then you just have to add that field to your mailer form and you're all set.
200
+
201
+ This is supported for the from (from_field), recipients (recipients_field) and reply_to (reply_to_field) properties.
202
+
203
+ ## Enabling action_mailer
204
+
205
+ In environment.rb you'll probably need to change:
206
+
207
+ config.frameworks -= [ :action_mailer ]
208
+
209
+ to:
210
+
211
+ config.frameworks -= []
212
+
213
+ ## Updating from the older mailer extension
214
+
215
+ If you get this error "The single-table inheritance mechanism failed to locate the subclass: 'MailerPage'.", run `rake:radiant:extensions:mailer:migrate`. This will change all pages with a MailerPage classname into regular pages. Second, your 'config' page part has to be renamed to 'mailer', and the first two YAML levels should be deleted (see instructions above).
216
+
217
+ If you are getting a stack level too deep error, it may be caused by using `<r:mailer:get />` in your 'mailer' part. Use the from_field or other options to get to the email adress that was posted (see User-provided configuration).
218
+
219
+ ## Caveats
220
+
221
+ Relative urls will almost certainly not work if the mailer fails validation. Solution? Only use absolute urls.
222
+
223
+ Unless you set up the field validations in the "mailer" part, validation will be implemented via easily spoofable HTML attributes. Think of them of more like guidelines in that case.
224
+
225
+ ## Initial History
226
+
227
+ Created by: M@ McCray - mattmccray.com
228
+ Version: 0.2.1
229
+ Contact: mmccray@elucidata.net
230
+
231
+ Ported to 'mental' by: Sean Cribbs - seancribbs.com
232
+ Version: 0.1
233
+ Contact: seancribbs@gmail.com
234
+
235
+ Seriously restructured by: Nathaniel Talbott - terralien.com
236
+ Version: 0.2
237
+ Contact: nathaniel@terralien.com
238
+ Work sponsored by: Ignite Social Media, http://ignitesocialmedia.com/
239
+
240
+ ## [Contributors](https://github.com/radiant/radiant-mailer-extension/graphs/contributors)
data/Rakefile CHANGED
@@ -14,6 +14,7 @@ end
14
14
  require 'rake'
15
15
  require 'rdoc/task'
16
16
  require 'rake/testtask'
17
+ require 'bundler/gem_tasks'
17
18
 
18
19
  rspec_base = File.expand_path(RADIANT_ROOT + '/vendor/plugins/rspec/lib')
19
20
  $LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base)
@@ -1,11 +1,12 @@
1
1
  class Mail
2
- attr_reader :page, :config, :data, :leave_blank, :disallow_links, :errors
2
+ attr_reader :page, :config, :data, :leave_blank, :disallow_links, :block_words, :errors
3
3
 
4
4
  def initialize(page, config, data)
5
5
  @page, @config, @data = page, config.with_indifferent_access, data
6
6
  @required = required_fields
7
7
  @leave_blank = leave_blank_field
8
8
  @disallow_links = disallow_link_fields
9
+ @block_words = block_words
9
10
  @errors = {}
10
11
  end
11
12
 
@@ -74,7 +75,7 @@ class Mail
74
75
  end
75
76
  end
76
77
 
77
- if @disallow_links.present?
78
+ unless @disallow_links.blank?
78
79
  pattern = /www|&amp;|http:|mailto:|bcc:|href|cc:|multipart|\[url|Content-Type:/i
79
80
  @disallow_links.each do |field|
80
81
  if @data[field] =~ pattern
@@ -84,12 +85,24 @@ class Mail
84
85
  end
85
86
  end
86
87
 
87
- if @leave_blank.present?
88
+ unless @leave_blank.blank?
88
89
  unless @data[@leave_blank] == ''
89
90
  errors[@leave_blank] = "must be left blank."
90
91
  @valid = false
91
92
  end
92
93
  end
94
+
95
+ unless @block_words.blank?
96
+ @data.each do |label,value|
97
+ @block_words.each do |word|
98
+ if value.include?(word.strip)
99
+ errors[label.titleize] = "is not valid"
100
+ @valid = false
101
+ end
102
+ end
103
+ end
104
+ end
105
+
93
106
  end
94
107
 
95
108
  @valid
@@ -199,4 +212,8 @@ The following information was posted:
199
212
  def disallow_link_fields
200
213
  @config[:disallow_links] if @config.has_key?(:disallow_links)
201
214
  end
202
- end
215
+
216
+ def block_words
217
+ config[:block_words] if @config.has_key?(:block_words)
218
+ end
219
+ end
@@ -1,7 +1,9 @@
1
1
  module MailerProcess
2
2
  def self.included(base)
3
- base.class_eval {
4
- alias_method_chain :process, :mailer
3
+ base.class_eval {
4
+ unless self.instance_methods(false).include?(:process_without_mailer)
5
+ alias_method_chain :process, :mailer
6
+ end
5
7
  attr_accessor :last_mail
6
8
  }
7
9
  end
@@ -308,6 +308,18 @@ module MailerTags
308
308
  mail = tag.locals.page.last_mail || tag.globals.page.last_mail
309
309
  tag.expand if name && mail.data[name] && (eq.blank? || eq == mail.data[name])
310
310
  end
311
+
312
+ desc %{
313
+ Renders the contained block unless a named datum was submitted via a mailer
314
+ form. Used in the 'email', 'email_html' and 'mailer' parts to generate
315
+ the resulting email.
316
+ }
317
+ tag 'mailer:unless_value' do |tag|
318
+ name = tag.attr['name']
319
+ eq = tag.attr['equals']
320
+ mail = tag.locals.page.last_mail || tag.globals.page.last_mail
321
+ tag.expand unless name && mail.data[name] && (eq.blank? || eq == mail.data[name])
322
+ end
311
323
 
312
324
  def format_mailer_data(element, name)
313
325
  data = element[name]
@@ -370,7 +382,7 @@ module MailerTags
370
382
  'width' => nil}.merge(extras)
371
383
  result = attrs.sort.collect do |k,v|
372
384
  v = (tag.attr[k] || v)
373
- if k == 'class' && tag.attr['required'].present?
385
+ if k == 'class' && ! tag.attr['required'].blank?
374
386
  v = [v, 'required', tag.attr['required']].compact.join(' ')
375
387
  end
376
388
  next if v.blank?
@@ -1,8 +1,8 @@
1
1
  module RadiantMailerExtension
2
- VERSION = '1.0.4'
2
+ VERSION = '1.0.6'
3
3
  SUMMARY = %q{Form mailing for Radiant CMS}
4
4
  DESCRIPTION = %q{Provides support for email forms and generic mailing functionality.}
5
5
  URL = "https://github.com/radiant/radiant-mailer-extension"
6
- AUTHORS = ["Nathaniel Talbott", "Sean Cribbs", "Matt McCray", "Jim Gay", "John Muhl", "Benny Degezelle"]
7
- EMAIL = ["radiant@radiantcms.org"]
6
+ AUTHORS = ["Nathaniel Talbott", "Sean Cribbs", "Matt McCray", "Jim Gay", "John Muhl", "Benny Degezelle", "Andrew vonderLuft"]
7
+ EMAIL = ["radiant@radiantcms.org"]
8
8
  end
@@ -4,6 +4,13 @@ class MailerExtension < Radiant::Extension
4
4
  description RadiantMailerExtension::DESCRIPTION
5
5
  url RadiantMailerExtension::URL
6
6
 
7
+ # Backward compatibility for routes.
8
+ unless defined?(Radiant::Extension.extension_config)
9
+ define_routes do |map|
10
+ map.resources :mail, :path_prefix => "/pages/:page_id", :controller => "mail"
11
+ end
12
+ end
13
+
7
14
  def activate
8
15
  Page.class_eval do
9
16
  include MailerTags
@@ -0,0 +1,28 @@
1
+ cd ~
2
+ git clone git://github.com/radiant/radiant.git
3
+ cd ~/radiant
4
+ if [[ $RADIANT_VERSION != "master" ]]
5
+ then
6
+ git checkout -b $RADIANT_VERSION $RADIANT_VERSION
7
+ fi
8
+ if [[ $RADIANT_VERSION == "0.9.1" ]]
9
+ then
10
+ touch Gemfile
11
+ echo "source :rubygems" >> Gemfile
12
+ fi
13
+ cp -r ~/builds/*/radiant-mailer-extension vendor/extensions/mailer
14
+ gem install bundler --pre
15
+ echo gemspec >> Gemfile
16
+ bundle install
17
+
18
+ case $DB in
19
+ "mysql" )
20
+ mysql -e 'create database radiant_test;'
21
+ cp spec/ci/database.mysql.yml config/database.yml;;
22
+ "postgres" )
23
+ psql -c 'create database radiant_test;' -U postgres
24
+ cp spec/ci/database.postgresql.yml config/database.yml;;
25
+ esac
26
+
27
+ bundle exec rake db:migrate
28
+ bundle exec rake db:migrate:extensions
@@ -0,0 +1,2 @@
1
+ cd ~/radiant
2
+ bundle exec rake spec:extensions EXT=mailer
@@ -20,61 +20,70 @@ describe SiteController, "receiving a mailer request", :type => :controller do
20
20
  dataset :mailer_page
21
21
 
22
22
  before :each do
23
- Radiant::Cache.clear
23
+ # Radiant backward compatibility
24
+ begin
25
+ Radiant::Cache.clear
26
+ rescue NameError
27
+ ResponseCache.instance.clear
28
+ end
24
29
  Radiant::Config['mailer.post_to_page?'] = true
25
30
  @page = pages(:mail_form)
26
31
  @mail = mock("Mail", :send => false, :data => {}, :errors => {})
27
- Page.stub!(:find_by_path).and_return(@page)
32
+ if defined?(Page.find_by_path)
33
+ Page.stub!(:find_by_path).and_return(@page)
34
+ else
35
+ Page.stub!(:find_by_url).and_return(@page)
36
+ end
28
37
  Mail.stub!(:new).and_return(@mail)
29
38
  end
30
39
 
31
40
  it "should not process a mail form if the request was GET" do
32
41
  @page.should_receive(:process_without_mailer).with(request, response)
33
42
  Mail.should_not_receive(:new)
34
- get :show_page, :url => @page.path
43
+ get :show_page, :url => @page.url
35
44
  end
36
45
 
37
46
  it "should not process a mail form if mailer.post_to_page? is set to false" do
38
47
  Radiant::Config['mailer.post_to_page?'] = false
39
48
  @page.should_receive(:process_without_mailer).with(request, response)
40
49
  Mail.should_not_receive(:new)
41
- post :show_page, :url => @page.path
50
+ post :show_page, :url => @page.url
42
51
  end
43
52
 
44
53
  it "should not process a mail form unless there are mailer parameters" do
45
54
  @page.should_receive(:process_without_mailer).with(request, response)
46
55
  Mail.should_not_receive(:new)
47
- post :show_page, :url => @page.path
56
+ post :show_page, :url => @page.url
48
57
  end
49
58
 
50
59
  it "should process a mail form if the request was POST, posting to the page is enabled, and mailer parameters were submitted" do
51
60
  Mail.should_receive(:new).and_return(@mail)
52
61
  @page.should_receive(:process_without_mailer).with(request, response)
53
- post :show_page, :url => @page.path, :mailer => {:foo => 'bar'}
62
+ post :show_page, :url => @page.url, :mailer => {:foo => 'bar'}
54
63
  end
55
64
 
56
65
  it "should create a Mail object and assign it to the page's last_mail accessor" do
57
66
  Mail.should_receive(:new).and_return(@mail)
58
67
  @page.should_receive(:last_mail=).with(@mail).at_least(:once)
59
- post :show_page, :url => @page.path, :mailer => {:foo => 'bar'}
68
+ post :show_page, :url => @page.url, :mailer => {:foo => 'bar'}
60
69
  end
61
70
 
62
71
  it "should attempt to send the mail" do
63
72
  @mail.should_receive(:send).and_return(false)
64
- post :show_page, :url => @page.path, :mailer => {:foo => 'bar'}
73
+ post :show_page, :url => @page.url, :mailer => {:foo => 'bar'}
65
74
  end
66
75
 
67
76
  it "should clear out the mail data and errors when sending is successful" do
68
77
  @mail.should_receive(:send).and_return(true)
69
78
  @mail.data.should_receive(:delete_if)
70
79
  @mail.errors.should_receive(:delete_if)
71
- post :show_page, :url => @page.path, :mailer => {:foo => 'bar'}
80
+ post :show_page, :url => @page.url, :mailer => {:foo => 'bar'}
72
81
  end
73
82
 
74
83
  it "should redirect to the configured URL when sending is successful" do
75
84
  @page.should_receive(:mailer_config_and_page).and_return([{:redirect_to => "/foo/bar"}, @page])
76
85
  @mail.should_receive(:send).and_return(true)
77
- post :show_page, :url => @page.path, :mailer => {:foo => 'bar'}
86
+ post :show_page, :url => @page.url, :mailer => {:foo => 'bar'}
78
87
  response.redirect_url.should match(%r{/foo/bar})
79
88
  end
80
89
  end
@@ -146,7 +146,7 @@ describe Mail do
146
146
  @mail.errors['form'].should_not be_blank
147
147
  end
148
148
 
149
- it "should be invalid when the recipients contains invalid email adresses" do
149
+ it "should be invalid when the recipients contains invalid email addresses" do
150
150
  @mail.config[:recipients] = ['sean AT radiant DOT com']
151
151
  @mail.should_not be_valid
152
152
  @mail.errors['form'].should_not be_blank
@@ -294,7 +294,16 @@ describe Mail do
294
294
  @mail.errors['comments'].should_not be_blank
295
295
  @mail.errors['comments'].should == 'must not contain the following text: "www", "&amp;amp;", "http:", "mailto:", "bcc:", "href", "multipart", "[url", or "Content-Type:"'
296
296
  end
297
- end
297
+ end
298
+
299
+ it "should be invalid when a field contains blocked words" do
300
+ ['spammer','badword','imabot'].each do |message|
301
+ @mail = Mail.new(@page, {:recipients => ['foo@bar.com'], :from => 'foo@baz.com', :block_words => ['spammer','badword','imabot']}, 'comments' => message)
302
+ @mail.should_not be_valid
303
+ @mail.errors['comments'.titleize].should_not be_blank
304
+ @mail.errors['comments'.titleize].should == 'is not valid'
305
+ end
306
+ end
298
307
 
299
308
  it "should not send the mail if invalid" do
300
309
  @mail.should_receive(:valid?).and_return(false)
@@ -12,9 +12,11 @@ end
12
12
  require "#{RADIANT_ROOT}/spec/spec_helper"
13
13
 
14
14
  Dataset::Resolver.default << (File.dirname(__FILE__) + "/datasets")
15
-
16
- if File.directory?(File.dirname(__FILE__) + "/matchers")
17
- Dir[File.dirname(__FILE__) + "/matchers/*.rb"].each {|file| require file }
15
+ # Include any datasets from loaded extensions
16
+ Radiant::Extension.descendants.each do |extension|
17
+ if File.directory?(extension.root + "/spec/datasets")
18
+ Dataset::Resolver.default << (extension.root + "/spec/datasets")
19
+ end
18
20
  end
19
21
 
20
22
  require 'action_controller'
metadata CHANGED
@@ -1,28 +1,39 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: radiant-mailer-extension
3
- version: !ruby/object:Gem::Version
4
- version: 1.0.4
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
5
  prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 6
10
+ version: 1.0.6
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Nathaniel Talbott
9
14
  - Sean Cribbs
10
15
  - Matt McCray
11
16
  - Jim Gay
12
17
  - John Muhl
13
18
  - Benny Degezelle
19
+ - Andrew vonderLuft
14
20
  autorequire:
15
21
  bindir: bin
16
22
  cert_chain: []
17
- date: 2012-03-04 00:00:00.000000000 Z
23
+
24
+ date: 2014-07-15 00:00:00 Z
18
25
  dependencies: []
26
+
19
27
  description: Provides support for email forms and generic mailing functionality.
20
- email:
28
+ email:
21
29
  - radiant@radiantcms.org
22
30
  executables: []
31
+
23
32
  extensions: []
33
+
24
34
  extra_rdoc_files: []
25
- files:
35
+
36
+ files:
26
37
  - app/controllers/mail_controller.rb
27
38
  - app/models/mail.rb
28
39
  - app/models/mailer.rb
@@ -45,7 +56,9 @@ files:
45
56
  - mailer_extension.rb
46
57
  - radiant-mailer-extension.gemspec
47
58
  - Rakefile
48
- - README.rdoc
59
+ - README.md
60
+ - spec/ci/before_script
61
+ - spec/ci/script
49
62
  - spec/controllers/mail_controller_spec.rb
50
63
  - spec/datasets/mailer_page_dataset.rb
51
64
  - spec/lib/mailer_process_spec.rb
@@ -56,29 +69,40 @@ files:
56
69
  - spec/spec_helper.rb
57
70
  homepage: https://github.com/radiant/radiant-mailer-extension
58
71
  licenses: []
72
+
59
73
  post_install_message:
60
74
  rdoc_options: []
61
- require_paths:
75
+
76
+ require_paths:
62
77
  - lib
63
- required_ruby_version: !ruby/object:Gem::Requirement
78
+ required_ruby_version: !ruby/object:Gem::Requirement
64
79
  none: false
65
- requirements:
66
- - - ! '>='
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ hash: 3
84
+ segments:
85
+ - 0
86
+ version: "0"
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
88
  none: false
71
- requirements:
72
- - - ! '>='
73
- - !ruby/object:Gem::Version
74
- version: '0'
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ hash: 3
93
+ segments:
94
+ - 0
95
+ version: "0"
75
96
  requirements: []
97
+
76
98
  rubyforge_project:
77
- rubygems_version: 1.8.11
99
+ rubygems_version: 1.8.24
78
100
  signing_key:
79
101
  specification_version: 3
80
102
  summary: Form mailing for Radiant CMS
81
- test_files:
103
+ test_files:
104
+ - spec/ci/before_script
105
+ - spec/ci/script
82
106
  - spec/controllers/mail_controller_spec.rb
83
107
  - spec/datasets/mailer_page_dataset.rb
84
108
  - spec/lib/mailer_process_spec.rb
@@ -1,225 +0,0 @@
1
- = Mailer Extension for Radiant
2
-
3
- The Mailer extension enables form mail on a page.
4
-
5
- == Usage
6
-
7
- You can define email templates using pages parts (email, and/or email_html).
8
- You configure the recipients and other Mailer settings in a "mailer" part:
9
-
10
- subject: From the website of Whatever
11
- from: noreply@example.com
12
- redirect_to: /contact/thank-you
13
- recipients:
14
- - one@one.com
15
- - two@two.com
16
-
17
- The following tags are available to help you build the form:
18
-
19
- <r:mailer:form name=""> ... </r:mailer:form>
20
- <r:mailer:text name="" />
21
- <r:mailer:password name="" />
22
- <r:mailer:reset name="" />
23
- <r:mailer:checkbox name="" />
24
- <r:mailer:radio name="" />
25
- <r:mailer:file name="" />
26
- <r:mailer:radiogroup name=""> ... </r:mailer:radiogroup>
27
- <r:mailer:select name=""> ... </r:mailer:select>
28
- <r:mailer:date_select name=""/>
29
- <r:mailer:textarea name=""> ... </r:mailer:textarea>
30
- <r:mailer:option name="" />
31
- <r:mailer:submit name="" />
32
- <r:mailer:image name="" />
33
- <r:mailer:submit_placeholder />
34
-
35
- When processing the form (in email and email_html), the following tags are
36
- available:
37
-
38
- <r:mailer:get name="" />
39
- <r:mailer:get_each name=""> ... </r:mailer:get_each>
40
- <r:mailer:index />
41
-
42
- Simple example of a form:
43
-
44
- <r:mailer:form>
45
- <r:mailer:hidden name="subject" value="Email from my Radiant site!" /> <br/>
46
- Name:<br/>
47
- <r:mailer:text name="name" /> <br/>
48
- Message:<br/>
49
- <r:mailer:textarea name="message" /> <br/>
50
- <r:mailer:submit name="Send" />
51
- </r:mailer:form>
52
-
53
- === Required fields
54
-
55
- You can specify fields which must be populated or the form will be invalid and will redisplay the page with an error informing the user to populate those fields.
56
-
57
- Simple example of a required field:
58
-
59
- <r:mailer:form>
60
- ...
61
- Name:<br/>
62
- <r:mailer:text name="name" required="true"/> <br/>
63
- ...
64
- <r:mailer:submit name="Send" />
65
- </r:mailer:form>
66
-
67
- Simple example of a required field with user-defined message:
68
-
69
- <r:mailer:form>
70
- ...
71
- Name:<br/>
72
- <r:mailer:text name="name" required="should not be blank"/> <br/>
73
- ...
74
- <r:mailer:submit name="Send" />
75
- </r:mailer:form>
76
-
77
- You can also specify fields which must be validated 'as_email' (i.e. a@b.com).
78
-
79
- Simple example of a required field with email address validation:
80
-
81
- <r:mailer:form>
82
- ...
83
- Reply-To:<br/>
84
- <r:mailer:text name="reply_email" required="as_email"/> <br/>
85
- ...
86
- <r:mailer:submit name="Send" />
87
- </r:mailer:form>
88
-
89
- You can also specify fields which must be validated as defined regexp (i.e. /^\d{2}\.\d{2}\.\d{4}\$/ for date dd.mm.yyyy).
90
-
91
-
92
- Simple example of a required field with regexp validation:
93
-
94
- <r:mailer:form>
95
- ...
96
- Birthday:<br/>
97
- <r:mailer:text name="birthday" required="/^\d{2}\.\d{2}\.\d{4}\$/"/> <br/>
98
- ...
99
- <r:mailer:submit name="Send" />
100
- </r:mailer:form>
101
-
102
- Finally, you can put all field validations in the "mailer" part:
103
-
104
- subject: From the website of Whatever
105
- from: noreply@example.com
106
- redirect_to: /contact/thank-you
107
- recipients:
108
- - one@one.com
109
- required:
110
- name: "true"
111
- email: as_email
112
- message: "true"
113
-
114
- The field names above are "name," "email," and "message." Note the quotation marks around true values. If you do your field validations this way, Mailer will ignore any validations you attempt through your radius tags. This method of validation keeps Mailer from adding hidden inputs to keep track of required fields. See the caveat below.
115
-
116
-
117
- === Spam blocking
118
-
119
- You can specify which fields may not contain anything that looks like a link in the "mailer" part. For example:
120
-
121
- subject: From the website of Whatever
122
- from: noreply@example.com
123
- redirect_to: /contact/thank-you
124
- recipients:
125
- - one@one.com
126
- disallow_links:
127
- - comments
128
- - questions
129
-
130
- The comments and questions fields would throw an error if the user or a spam bot entered the following phrases: "www", "&amp;", "http:", "mailto:", "bcc:", "href", "multipart", "[url", or "Content-Type:".
131
-
132
-
133
- You can also include one field on your form that must be left blank. If anyone enters something in the field, the field throws an error. The tactic here is to hide the field from human readers, but to leave the field visible to spam bots. Here is how you would edit the "mailer" part to implement this:
134
-
135
- subject: From the website of Whatever
136
- from: noreply@example.com
137
- redirect_to: /contact/thank-you
138
- recipients:
139
- - one@one.com
140
- leave_blank: your_field_name
141
-
142
- "your_field_name" is the name of the field you want to hide. It is up to you to hide the field when you construct your form. I would recommend against using a traditional hidden input field. Use style="display:none" instead.
143
-
144
-
145
- === File attachments
146
-
147
- In many cases it is desirable to limit the maximum size of a file that may be uploaded. This is set as the max_filesize attribute for mailers in the mailer page part. Any file included in the form will have the limit imposed. Following is a simple example mailer part that includes a file size limit of 100,000 bytes:
148
-
149
- subject: From the website of Whatever
150
- from: noreply@mydomain.com
151
- redirect_to: /contact/thank-you
152
- max_filesize: 100000
153
- recipients:
154
- - one@one.com
155
- - two@two.com
156
-
157
- The following is a simple form that might be used to submit a file for the above configuration:
158
-
159
- <r:mailer:form name="contact">
160
- Type your message: <r:mailer:text name="themessage" /> <br/>
161
- Select a file: <r:mailer:file name="thefile" /> <br/>
162
- <r:mailer:submit value="submit"/>
163
- </r:mailer:form>
164
-
165
- If a user does not select a file the other form contents will still be e-mailed. The <r:mailer:get name="foo" /> (with <r:mailer:file name="foo" />) will provide the uploaded file name.
166
-
167
- If you are using email or email_html parts then the <r:mailer:get name="" /> tag can be used to retrieve the name of the uploaded file. If no file was uploaded "" will be returned.
168
-
169
- === Submit placeholder
170
-
171
- If you wish to show that activity is taking place during submission you may use the <r:mailer:submit_placeholder /> tag in your form. This will insert a hidden div with the contents of the submit_placeholder page part. The div will be displayed when the user clicks any submit button.
172
-
173
- === User-provided Configuration
174
-
175
- Sometimes, rather than explicitly configuring the recipients and such in the mailer part, you'd rather have them passed in by the person submitting the form. Mailer supports this by allowing you to specify a form field to pull the value from:
176
-
177
- from_field: my_form_field_that_contains_the_from_email_address
178
-
179
- Then you just have to add that field to your mailer form and you're all set.
180
-
181
- This is supported for the from (from_field), recipients (recipients_field) and reply_to (reply_to_field) properties.
182
-
183
- == Enabling action_mailer
184
-
185
- In environment.rb you'll probably need to change:
186
-
187
- config.frameworks -= [ :action_mailer ]
188
-
189
- to:
190
-
191
- config.frameworks -= []
192
-
193
- == Updating from the older mailer extension
194
-
195
- If you get this error "The single-table inheritance mechanism failed to locate the subclass: 'MailerPage'.", run 'rake:radiant:extensions:mailer:migrate'. This will change all pages with a MailerPage classname into regular pages.
196
- Second, your 'config' page part has to be renamed to 'mailer', and the first two YAML levels should be deleted (see instructions above).
197
-
198
- If you are getting a stack level too deep error, it may be caused by using <r:mailer:get /> in your 'mailer' part.
199
- Use the from_field or other options to get to the email adress that was posted (see User-provided configuration).
200
-
201
- == Caveats
202
-
203
- Relative urls will almost certainly not work if the mailer fails validation. Solution? Only use absolute urls.
204
-
205
- Unless you set up the field validations in the "mailer" part, validation will be implemented via easily spoofable HTML attributes. Think of them of more like guidelines in that case.
206
-
207
- == History
208
-
209
- Created by: M@ McCray - mattmccray.com
210
- Version: 0.2.1
211
- Contact: mmccray@elucidata.net
212
-
213
- Ported to 'mental' by: Sean Cribbs - seancribbs.com
214
- Version: 0.1
215
- Contact: seancribbs@gmail.com
216
-
217
- Seriously restructured by: Nathaniel Talbott - terralien.com
218
- Version: 0.2
219
- Contact: nathaniel@terralien.com
220
- Work sponsored by: Ignite Social Media, http://ignitesocialmedia.com/
221
-
222
-
223
- == Todo
224
-
225
- * Tests