radiant-forms-extension 3.2.8 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/.bundle/config ADDED
@@ -0,0 +1,2 @@
1
+ ---
2
+ BUNDLE_DISABLE_SHARED_GEMS: "1"
data/README.md CHANGED
@@ -62,9 +62,9 @@ Using forms 'DRY's up the process of creating and reusing forms across a site (w
62
62
 
63
63
  ### Content
64
64
 
65
- <h2>Contact from <r:form:read name='contact[name]' /></h2>
65
+ <h2>Contact from <r:get name='contact[name]' /></h2>
66
66
 
67
- <p>You can get back to them on <r:form:read name='contact[email]' /></p>
67
+ <p>You can get back to them on <r:get name='contact[email]' /></p>
68
68
 
69
69
  <p>Cheers, <br /> <strong>Cool Mailer</strong></p>
70
70
 
@@ -194,4 +194,4 @@ A showcase of how to use addons, allows you to send emails directly from the pag
194
194
  config.gem 'ruby-debug', :version => '0.10.3'
195
195
  config.gem 'webrat', :version => '0.7.1'
196
196
  config.gem 'rr', :version => '0.10.11'
197
- end
197
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.2.8
1
+ 3.3.0
@@ -12,52 +12,28 @@ class FormsController < ApplicationController
12
12
  end
13
13
 
14
14
  def update
15
- set_page
16
- set_form
17
- set_response
18
- set_configuration
19
-
20
- execute_extensions
21
-
22
- begin
23
- @response.save!
24
- redirect_to @form.redirect_to.present? ? @form.redirect_to : @page.url
25
- rescue
26
- "Form '#{@form.title}' could not be submitted."
27
- end
28
- end
29
-
30
- protected
31
-
32
- def set_page
33
15
  @page = Page.find(params[:page_id]) rescue Page.first
34
16
  @page.data = params
35
17
  @page.request = OpenStruct.new({
36
18
  :referrer => request.referer,
37
19
  :session => session # Creating a pretend response object
38
20
  })
39
- end
40
-
41
- def set_form
21
+
42
22
  @form = Form.find(params[:id])
43
23
  @form.page = @page
44
- end
45
-
46
- def set_response
24
+
25
+ # We need a response object
47
26
  @response = find_or_create_response
27
+ # Put the submitted data into the response object
48
28
  @response.result = Forms::Config.deep_symbolize_keys(params)
49
- end
50
-
51
- def set_configuration
29
+
52
30
  begin
53
31
  # Grab the form configuration data
54
32
  @form[:extensions] = Forms::Config.convert(@form.config)
55
33
  rescue
56
34
  raise "Form '#{@form.title}' has not been configured"
57
35
  end
58
- end
59
-
60
- def execute_extensions
36
+
61
37
  @results = {}
62
38
  # Iterate through each configured extension
63
39
  @form[:extensions].each do |name, config|
@@ -31,53 +31,64 @@ class FormMail
31
31
  end
32
32
 
33
33
  def from
34
- begin
35
- Forms::Tags::Responses.retrieve(@data, @config[:field][:from])
36
- rescue
37
- @config[:from]
34
+ from = nil
35
+ unless @config[:field].nil? or !@config[:field][:from].blank?
36
+ from = Forms::Tags::Responses.retrieve(@data, @config[:field][:from])
37
+ else
38
+ from = @config[:from]
38
39
  end
40
+ from
39
41
  end
40
42
 
41
43
  def recipients
42
- begin
43
- Forms::Tags::Responses.retrieve(@data, @config[:field][:to])
44
- rescue
45
- @config[:to]
44
+ to = nil
45
+ unless @config[:field].nil? or !@config[:field][:to].blank?
46
+ to = Forms::Tags::Responses.retrieve(@data, @config[:field][:to])
47
+ else
48
+ to = @config[:to]
46
49
  end
50
+ to
47
51
  end
48
52
 
49
53
  def reply_to
50
- begin
51
- Forms::Tags::Responses.retrieve(@data, @config[:field][:reply_to])
52
- rescue
53
- @config[:reply_to]
54
+ reply_to = nil
55
+ unless @config[:field].nil? or !@config[:field][:reply_to].blank?
56
+ reply_to = Forms::Tags::Responses.retrieve(@data, @config[:field][:reply_to])
57
+ else
58
+ reply_to = @config[:reply_to]
54
59
  end
60
+ reply_to
55
61
  end
56
62
 
57
63
  def sender
58
- begin
59
- Forms::Tags::Responses.retrieve(@data, @config[:field][:sender])
60
- rescue
61
- @config[:sender]
64
+ sender = nil
65
+ unless @config[:field].nil? or !@config[:field][:sender].blank?
66
+ sender = Forms::Tags::Responses.retrieve(@data, @config[:field][:sender])
67
+ else
68
+ sender = @config[:sender]
62
69
  end
70
+ sender
63
71
  end
64
72
 
65
73
  def subject
66
- begin
67
- Forms::Tags::Responses.retrieve(@data, @config[:field][:subject])
68
- rescue
69
- @config[:subject]
74
+ subject = nil
75
+ unless @config[:field].nil? or !@config[:field][:subject].blank?
76
+ subject = Forms::Tags::Responses.retrieve(@data, @config[:field][:subject])
77
+ else
78
+ subject = @config[:subject]
70
79
  end
80
+ subject
71
81
  end
72
82
 
73
83
  def body
74
84
  # This parses the content of the form
75
85
  @parser = Radius::Parser.new(PageContext.new(@page), :tag_prefix => 'r')
76
86
  if @config[:body]
77
- @parser.parse(@form.send(@config[:body]))
87
+ @body = @parser.parse(@form.send(@config[:body]))
78
88
  else
79
- @parser.parse(@form.content)
89
+ @body = @parser.parse(@form.content)
80
90
  end
91
+ @body
81
92
  end
82
93
 
83
94
  def cc
@@ -10,14 +10,20 @@ module Forms
10
10
  end
11
11
 
12
12
  def find_response
13
+ response = nil
14
+
13
15
  begin
14
16
  response = Response.find(request.session[:form_response])
15
17
  rescue
16
18
  response = nil
17
19
  end
20
+
21
+ response
18
22
  end
19
23
 
20
24
  def find_or_create_response
25
+ response = nil
26
+
21
27
  if find_response
22
28
  response = find_response
23
29
  else
@@ -68,28 +68,6 @@ module Forms
68
68
  %(<input type="#{type}" value="#{value}" #{Forms::Tags::Helpers.attributes(tag)} />)
69
69
  end
70
70
  end
71
-
72
- %w(textarea).each do |type|
73
- desc %{
74
- Render a @<#{type}>...</#{type}>@ tag to be used in a form
75
- <pre><code><r:form:#{type} name="object[key]" /></code></pre>
76
-
77
- **Required**
78
- * *name* the name of the data to be sent
79
-
80
- **Optional**
81
- * *class* css class names
82
- * *placeholder* default text, which is cleared when clicked
83
- * *maxlength* the maximum amount of characters
84
- }
85
- tag "form:#{type}" do |tag|
86
- Forms::Tags::Helpers.require!(tag,"form:#{type}",'name')
87
-
88
- tag.attr['type'] = type
89
-
90
- %(<#{type} #{Forms::Tags::Helpers.attributes(tag)}>#{tag.expand}</#{type}>)
91
- end
92
- end
93
71
 
94
72
  desc %{
95
73
  Renders a @<select>...</select>@ tag to be used in a form
@@ -338,10 +316,6 @@ module Forms
338
316
  nil
339
317
  end
340
318
 
341
- tag 'param' do |tag|
342
- tag.locals.page.params[tag.attr['name']]
343
- end
344
-
345
319
  end
346
320
  end
347
321
  end
@@ -5,17 +5,18 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{radiant-forms-extension}
8
- s.version = "3.2.8"
8
+ s.version = "3.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["dirkkelly"]
12
- s.date = %q{2010-12-20}
12
+ s.date = %q{2010-12-14}
13
13
  s.description = %q{Send data from a page to a form handler, extendable with addons}
14
14
  s.email = %q{dirk.kelly@squaretalent.com}
15
15
  s.extra_rdoc_files = [
16
16
  "README.md"
17
17
  ]
18
18
  s.files = [
19
+ ".bundle/config",
19
20
  "README.md",
20
21
  "Rakefile",
21
22
  "VERSION",
@@ -64,7 +65,6 @@ Gem::Specification.new do |s|
64
65
  "lib/forms/tags/core.rb",
65
66
  "lib/forms/tags/helpers.rb",
66
67
  "lib/forms/tags/responses.rb",
67
- "lib/radiant-forms-extension.rb",
68
68
  "lib/tasks/forms_extension_tasks.rake",
69
69
  "public/images/admin/extensions/form/form.png",
70
70
  "public/stylesheets/sass/admin/extensions/forms/edit.sass",
@@ -11,7 +11,6 @@ describe Forms::Tags::Core do
11
11
  'form',
12
12
  'form:label',
13
13
  'form:text',
14
- 'form:textarea',
15
14
  'form:password',
16
15
  'form:reset',
17
16
  'form:checkbox',
@@ -36,7 +35,6 @@ describe Forms::Tags::Core do
36
35
  'response:if_get',
37
36
  'response:unless_get',
38
37
 
39
- 'param',
40
38
  'index',
41
39
  'reset'
42
40
  ].sort
@@ -96,25 +94,6 @@ describe Forms::Tags::Core do
96
94
  end
97
95
 
98
96
  end
99
-
100
- %w(textarea).each do |type|
101
-
102
- describe "<r:form:#{type}>" do
103
-
104
- it 'should render the correct HTML' do
105
- tag = %{<r:form:#{type} name="test[field]" />}
106
- expected = %{<#{type} name="test[field]" class="#{type}" id="test_field"></#{type}>}
107
- @page.should render(tag).as(expected)
108
- end
109
-
110
- it 'should require the name attribute' do
111
- tag = %{<r:form:#{type} />}
112
- @page.should_not render(tag)
113
- end
114
-
115
- end
116
-
117
- end
118
97
 
119
98
  describe '<r:form:select>' do
120
99
 
@@ -154,7 +133,7 @@ describe Forms::Tags::Core do
154
133
  it 'should require the name attribute' do
155
134
  tag = %{<r:form:radios />}
156
135
  @page.should_not render(tag)
157
- end
136
+ end
158
137
 
159
138
  end
160
139
 
@@ -168,21 +147,6 @@ describe Forms::Tags::Core do
168
147
 
169
148
  end
170
149
 
171
- context 'param' do
172
-
173
- before :each do
174
- @page = pages(:home)
175
- stub(@page).params { { 'test' => 'param'} }
176
- end
177
-
178
- it 'should return the requested param' do
179
- tag = %{<r:param name='test' />}
180
- exp = %{param}
181
- @page.should render(tag).as(exp)
182
- end
183
-
184
- end
185
-
186
150
  context 'response' do
187
151
 
188
152
  context 'conditionals' do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radiant-forms-extension
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 3
8
- - 2
9
- - 8
10
- version: 3.2.8
8
+ - 3
9
+ - 0
10
+ version: 3.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - dirkkelly
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-20 00:00:00 +08:00
18
+ date: 2010-12-14 00:00:00 +08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -43,6 +43,7 @@ extensions: []
43
43
  extra_rdoc_files:
44
44
  - README.md
45
45
  files:
46
+ - .bundle/config
46
47
  - README.md
47
48
  - Rakefile
48
49
  - VERSION
@@ -91,7 +92,6 @@ files:
91
92
  - lib/forms/tags/core.rb
92
93
  - lib/forms/tags/helpers.rb
93
94
  - lib/forms/tags/responses.rb
94
- - lib/radiant-forms-extension.rb
95
95
  - lib/tasks/forms_extension_tasks.rake
96
96
  - public/images/admin/extensions/form/form.png
97
97
  - public/stylesheets/sass/admin/extensions/forms/edit.sass
@@ -1 +0,0 @@
1
- # Nothing to see here