comfortable_mexican_sofa 1.4.18 → 1.4.19
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/VERSION +1 -1
- data/app/models/cms/page.rb +8 -1
- data/comfortable_mexican_sofa.gemspec +2 -2
- data/lib/comfortable_mexican_sofa/tag.rb +11 -7
- data/test/unit/tag_test.rb +48 -0
- metadata +9 -9
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.4.
|
|
1
|
+
1.4.19
|
data/app/models/cms/page.rb
CHANGED
|
@@ -100,7 +100,14 @@ class Cms::Page < ActiveRecord::Base
|
|
|
100
100
|
@content = nil if force_reload
|
|
101
101
|
@content ||= begin
|
|
102
102
|
self.tags = [] # resetting
|
|
103
|
-
|
|
103
|
+
if layout
|
|
104
|
+
ComfortableMexicanSofa::Tag.process_content(
|
|
105
|
+
self,
|
|
106
|
+
ComfortableMexicanSofa::Tag.sanitize_irb(layout.merged_content)
|
|
107
|
+
)
|
|
108
|
+
else
|
|
109
|
+
''
|
|
110
|
+
end
|
|
104
111
|
end
|
|
105
112
|
end
|
|
106
113
|
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = %q{comfortable_mexican_sofa}
|
|
8
|
-
s.version = "1.4.
|
|
8
|
+
s.version = "1.4.19"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Oleg Khabarov", "The Working Group Inc"]
|
|
12
|
-
s.date = %q{2011-09-
|
|
12
|
+
s.date = %q{2011-09-22}
|
|
13
13
|
s.description = %q{}
|
|
14
14
|
s.email = %q{oleg@theworkinggroup.ca}
|
|
15
15
|
s.extra_rdoc_files = [
|
|
@@ -67,13 +67,8 @@ module ComfortableMexicanSofa::Tag
|
|
|
67
67
|
# Content that is used during page rendering. Outputting existing content
|
|
68
68
|
# as a default.
|
|
69
69
|
def render
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
![ComfortableMexicanSofa::Tag::Partial, ComfortableMexicanSofa::Tag::Helper].member?(self.class)
|
|
73
|
-
content.to_s.gsub('<%', '<%').gsub('%>', '%>')
|
|
74
|
-
else
|
|
75
|
-
content.to_s
|
|
76
|
-
end
|
|
70
|
+
ignore = [ComfortableMexicanSofa::Tag::Partial, ComfortableMexicanSofa::Tag::Helper].member?(self.class)
|
|
71
|
+
ComfortableMexicanSofa::Tag.sanitize_irb(content, ignore)
|
|
77
72
|
end
|
|
78
73
|
|
|
79
74
|
# Find or initialize Cms::Block object
|
|
@@ -131,6 +126,15 @@ private
|
|
|
131
126
|
end.join('')
|
|
132
127
|
end
|
|
133
128
|
|
|
129
|
+
# Cleaning content from possible irb stuff. Partial and Helper tags are OK.
|
|
130
|
+
def self.sanitize_irb(content, ignore = false)
|
|
131
|
+
if ComfortableMexicanSofa.config.allow_irb || ignore
|
|
132
|
+
content.to_s
|
|
133
|
+
else
|
|
134
|
+
content.to_s.gsub('<%', '<%').gsub('%>', '%>')
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
134
138
|
def self.included(tag)
|
|
135
139
|
tag.send(:include, ComfortableMexicanSofa::Tag::InstanceMethods)
|
|
136
140
|
tag.send(:extend, ComfortableMexicanSofa::Tag::ClassMethods)
|
data/test/unit/tag_test.rb
CHANGED
|
@@ -220,4 +220,52 @@ class TagTest < ActiveSupport::TestCase
|
|
|
220
220
|
assert !tag.is_cms_block?
|
|
221
221
|
end
|
|
222
222
|
|
|
223
|
+
def test_content_with_irb_disabled
|
|
224
|
+
assert_equal false, ComfortableMexicanSofa.config.allow_irb
|
|
225
|
+
|
|
226
|
+
site = cms_sites(:default)
|
|
227
|
+
layout = site.layouts.create!(
|
|
228
|
+
:slug => 'no-irb-layout',
|
|
229
|
+
:content => '<% 1 + 1 %> {{cms:page:content}} <%= 1 + 1 %>'
|
|
230
|
+
)
|
|
231
|
+
snippet = site.snippets.create!(
|
|
232
|
+
:slug => 'no-irb-snippet',
|
|
233
|
+
:content => '<% 2 + 2 %> snippet <%= 2 + 2 %>'
|
|
234
|
+
)
|
|
235
|
+
page = site.pages.create!(
|
|
236
|
+
:slug => 'no-irb-page',
|
|
237
|
+
:parent_id => cms_pages(:default).id,
|
|
238
|
+
:layout_id => layout.id,
|
|
239
|
+
:blocks_attributes => [
|
|
240
|
+
{ :label => 'content',
|
|
241
|
+
:content => 'text {{ cms:snippet:no-irb-snippet }} {{ cms:partial:path/to }} {{ cms:helper:method }} text' }
|
|
242
|
+
]
|
|
243
|
+
)
|
|
244
|
+
assert_equal "<% 1 + 1 %> text <% 2 + 2 %> snippet <%= 2 + 2 %> <%= render :partial => 'path/to' %> <%= method() %> text <%= 1 + 1 %>", page.content
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
def test_content_with_irb_enabled
|
|
248
|
+
ComfortableMexicanSofa.config.allow_irb = true
|
|
249
|
+
|
|
250
|
+
site = cms_sites(:default)
|
|
251
|
+
layout = site.layouts.create!(
|
|
252
|
+
:slug => 'irb-layout',
|
|
253
|
+
:content => '<% 1 + 1 %> {{cms:page:content}} <%= 1 + 1 %>'
|
|
254
|
+
)
|
|
255
|
+
snippet = site.snippets.create!(
|
|
256
|
+
:slug => 'irb-snippet',
|
|
257
|
+
:content => '<% 2 + 2 %> snippet <%= 2 + 2 %>'
|
|
258
|
+
)
|
|
259
|
+
page = site.pages.create!(
|
|
260
|
+
:slug => 'irb-page',
|
|
261
|
+
:parent_id => cms_pages(:default).id,
|
|
262
|
+
:layout_id => layout.id,
|
|
263
|
+
:blocks_attributes => [
|
|
264
|
+
{ :label => 'content',
|
|
265
|
+
:content => 'text {{ cms:snippet:irb-snippet }} {{ cms:partial:path/to }} {{ cms:helper:method }} text' }
|
|
266
|
+
]
|
|
267
|
+
)
|
|
268
|
+
assert_equal "<% 1 + 1 %> text <% 2 + 2 %> snippet <%= 2 + 2 %> <%= render :partial => 'path/to' %> <%= method() %> text <%= 1 + 1 %>", page.content
|
|
269
|
+
end
|
|
270
|
+
|
|
223
271
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: comfortable_mexican_sofa
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.4.
|
|
4
|
+
version: 1.4.19
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -10,12 +10,12 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2011-09-
|
|
13
|
+
date: 2011-09-22 00:00:00.000000000 -04:00
|
|
14
14
|
default_executable:
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|
|
17
17
|
name: rails
|
|
18
|
-
requirement: &
|
|
18
|
+
requirement: &70343682601860 !ruby/object:Gem::Requirement
|
|
19
19
|
none: false
|
|
20
20
|
requirements:
|
|
21
21
|
- - ! '>='
|
|
@@ -23,10 +23,10 @@ dependencies:
|
|
|
23
23
|
version: 3.0.0
|
|
24
24
|
type: :runtime
|
|
25
25
|
prerelease: false
|
|
26
|
-
version_requirements: *
|
|
26
|
+
version_requirements: *70343682601860
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: active_link_to
|
|
29
|
-
requirement: &
|
|
29
|
+
requirement: &70343682597740 !ruby/object:Gem::Requirement
|
|
30
30
|
none: false
|
|
31
31
|
requirements:
|
|
32
32
|
- - ! '>='
|
|
@@ -34,10 +34,10 @@ dependencies:
|
|
|
34
34
|
version: 1.0.0
|
|
35
35
|
type: :runtime
|
|
36
36
|
prerelease: false
|
|
37
|
-
version_requirements: *
|
|
37
|
+
version_requirements: *70343682597740
|
|
38
38
|
- !ruby/object:Gem::Dependency
|
|
39
39
|
name: paperclip
|
|
40
|
-
requirement: &
|
|
40
|
+
requirement: &70343682597140 !ruby/object:Gem::Requirement
|
|
41
41
|
none: false
|
|
42
42
|
requirements:
|
|
43
43
|
- - ! '>='
|
|
@@ -45,7 +45,7 @@ dependencies:
|
|
|
45
45
|
version: 2.3.14
|
|
46
46
|
type: :runtime
|
|
47
47
|
prerelease: false
|
|
48
|
-
version_requirements: *
|
|
48
|
+
version_requirements: *70343682597140
|
|
49
49
|
description: ''
|
|
50
50
|
email: oleg@theworkinggroup.ca
|
|
51
51
|
executables: []
|
|
@@ -349,7 +349,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
349
349
|
version: '0'
|
|
350
350
|
segments:
|
|
351
351
|
- 0
|
|
352
|
-
hash:
|
|
352
|
+
hash: 467182363861644455
|
|
353
353
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
354
354
|
none: false
|
|
355
355
|
requirements:
|