comfortable_mexican_sofa 1.2.6 → 1.2.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/VERSION +1 -1
- data/comfortable_mexican_sofa.gemspec +6 -2
- data/lib/comfortable_mexican_sofa/tag.rb +6 -1
- data/lib/comfortable_mexican_sofa/tags/asset.rb +25 -0
- data/lib/comfortable_mexican_sofa/tags/helper.rb +1 -1
- data/lib/comfortable_mexican_sofa/tags/partial.rb +1 -1
- data/lib/comfortable_mexican_sofa/tags/upload.rb +24 -0
- data/test/unit/tags/asset_test.rb +56 -0
- data/test/unit/tags/helper_test.rb +2 -2
- data/test/unit/tags/upload_test.rb +67 -0
- metadata +7 -3
data/README.md
CHANGED
@@ -82,7 +82,7 @@ Here's a number of tag variations:
|
|
82
82
|
{{ cms:partial:path/to/partial }} # same as <%= render :partial => 'path/to/partial' %>
|
83
83
|
{{ cms:partial:path/to/partial:a:b }} # same as <%= render :partial => 'path/to/partial',
|
84
84
|
# :locals => { :param_1 => 'a', :param_1 => 'b' } %>
|
85
|
-
|
85
|
+
|
86
86
|
Multiple Sites
|
87
87
|
--------------
|
88
88
|
Sofa is able to manage multiple sites from the same application. For instance: 'site-a.example.com' and 'site-b.example.com' will have distinct set of layouts, pages, snippets, etc. To enable multi-site functionality make sure you have this setting in the initializer: `config.enable_multiple_sites = true`.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.7
|
@@ -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.2.
|
8
|
+
s.version = "1.2.7"
|
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-06-
|
12
|
+
s.date = %q{2011-06-04}
|
13
13
|
s.description = %q{}
|
14
14
|
s.email = %q{oleg@theworkinggroup.ca}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -178,6 +178,7 @@ Gem::Specification.new do |s|
|
|
178
178
|
"lib/comfortable_mexican_sofa/is_mirrored.rb",
|
179
179
|
"lib/comfortable_mexican_sofa/rails_extensions.rb",
|
180
180
|
"lib/comfortable_mexican_sofa/tag.rb",
|
181
|
+
"lib/comfortable_mexican_sofa/tags/asset.rb",
|
181
182
|
"lib/comfortable_mexican_sofa/tags/field_datetime.rb",
|
182
183
|
"lib/comfortable_mexican_sofa/tags/field_integer.rb",
|
183
184
|
"lib/comfortable_mexican_sofa/tags/field_string.rb",
|
@@ -190,6 +191,7 @@ Gem::Specification.new do |s|
|
|
190
191
|
"lib/comfortable_mexican_sofa/tags/page_text.rb",
|
191
192
|
"lib/comfortable_mexican_sofa/tags/partial.rb",
|
192
193
|
"lib/comfortable_mexican_sofa/tags/snippet.rb",
|
194
|
+
"lib/comfortable_mexican_sofa/tags/upload.rb",
|
193
195
|
"lib/comfortable_mexican_sofa/version.rb",
|
194
196
|
"lib/comfortable_mexican_sofa/view_hooks.rb",
|
195
197
|
"lib/comfortable_mexican_sofa/view_methods.rb",
|
@@ -238,6 +240,7 @@ Gem::Specification.new do |s|
|
|
238
240
|
"test/unit/models/upload_test.rb",
|
239
241
|
"test/unit/revisions_test.rb",
|
240
242
|
"test/unit/tag_test.rb",
|
243
|
+
"test/unit/tags/asset_test.rb",
|
241
244
|
"test/unit/tags/field_datetime_test.rb",
|
242
245
|
"test/unit/tags/field_integer_test.rb",
|
243
246
|
"test/unit/tags/field_string_test.rb",
|
@@ -250,6 +253,7 @@ Gem::Specification.new do |s|
|
|
250
253
|
"test/unit/tags/page_text_test.rb",
|
251
254
|
"test/unit/tags/partial_test.rb",
|
252
255
|
"test/unit/tags/snippet_test.rb",
|
256
|
+
"test/unit/tags/upload_test.rb",
|
253
257
|
"test/unit/view_methods_test.rb"
|
254
258
|
]
|
255
259
|
s.homepage = %q{http://github.com/twg/comfortable-mexican-sofa}
|
@@ -30,7 +30,7 @@ module ComfortableMexicanSofa::Tag
|
|
30
30
|
tag = self.new
|
31
31
|
tag.page = page
|
32
32
|
tag.label = match[1]
|
33
|
-
tag.params = match[2]
|
33
|
+
tag.params = match[2].to_s.split(':')
|
34
34
|
tag
|
35
35
|
end
|
36
36
|
end
|
@@ -84,6 +84,11 @@ module ComfortableMexicanSofa::Tag
|
|
84
84
|
page.site.snippets.detect{|s| s.slug == self.label.to_s} || page.site.snippets.build(:slug => self.label.to_s)
|
85
85
|
end
|
86
86
|
|
87
|
+
# Initializing Cms::Upload object
|
88
|
+
def upload
|
89
|
+
page.site.uploads.detect{|s| s.file_file_name == self.label.to_s}
|
90
|
+
end
|
91
|
+
|
87
92
|
# Checks if this tag is using Cms::Block
|
88
93
|
def is_cms_block?
|
89
94
|
%w(page field).member?(self.class.to_s.demodulize.underscore.split(/_/).first)
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class ComfortableMexicanSofa::Tag::Asset
|
2
|
+
include ComfortableMexicanSofa::Tag
|
3
|
+
|
4
|
+
def self.regex_tag_signature(label = nil)
|
5
|
+
label ||= /[\w\-]+/
|
6
|
+
/\{\{\s*cms:asset:(#{label}):?(.*?)\s*\}\}/
|
7
|
+
end
|
8
|
+
|
9
|
+
def content
|
10
|
+
return unless (layout = Cms::Layout.find_by_slug(label))
|
11
|
+
type = params[0]
|
12
|
+
format = params[1]
|
13
|
+
|
14
|
+
case type
|
15
|
+
when 'css'
|
16
|
+
out = "#{ComfortableMexicanSofa.config.content_route_prefix}/cms-css/#{label}.css"
|
17
|
+
out = "<link href='#{out}' media='screen' rel='stylesheet' type='text/css' />" if format == 'html_tag'
|
18
|
+
out
|
19
|
+
when 'js'
|
20
|
+
out = "#{ComfortableMexicanSofa.config.content_route_prefix}/cms-js/#{label}.js"
|
21
|
+
out = "<script src='#{out}' type='text/javascript'></script>" if format == 'html_tag'
|
22
|
+
out
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -7,7 +7,7 @@ class ComfortableMexicanSofa::Tag::Partial
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def content
|
10
|
-
ps = params.
|
10
|
+
ps = params.collect_with_index{|p, i| ":param_#{i+1} => '#{p}'"}.join(', ')
|
11
11
|
"<%= render :partial => '#{label}'#{ps.blank?? nil : ", :locals => {#{ps}}"} %>"
|
12
12
|
end
|
13
13
|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class ComfortableMexicanSofa::Tag::Upload
|
2
|
+
include ComfortableMexicanSofa::Tag
|
3
|
+
|
4
|
+
def self.regex_tag_signature(label = nil)
|
5
|
+
label ||= /[\w\-\.]+/
|
6
|
+
/\{\{\s*cms:upload:(#{label}):?(.*?)\s*\}\}/
|
7
|
+
end
|
8
|
+
|
9
|
+
def content
|
10
|
+
return unless upload
|
11
|
+
|
12
|
+
format = params[0]
|
13
|
+
text = params[1] || label
|
14
|
+
|
15
|
+
case format
|
16
|
+
when 'link'
|
17
|
+
"<a href='#{upload.file.url}' target='_blank'>#{text}</a>"
|
18
|
+
when 'image'
|
19
|
+
"<img src='#{upload.file.url}' alt='#{text}' />"
|
20
|
+
else
|
21
|
+
upload.file.url
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require File.expand_path('../../test_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
class AssetTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
def test_initialize_tag
|
6
|
+
assert tag = ComfortableMexicanSofa::Tag::Asset.initialize_tag(
|
7
|
+
cms_pages(:default), '{{ cms:asset:default:css:html_tag }}'
|
8
|
+
)
|
9
|
+
assert_equal 'default', tag.label
|
10
|
+
assert_equal ['css', 'html_tag'], tag.params
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_initialize_tag_failure
|
14
|
+
[
|
15
|
+
'{{cms:asset}}',
|
16
|
+
'{{cms:not_asset:method_name}}',
|
17
|
+
'{not_a_tag}'
|
18
|
+
].each do |tag_signature|
|
19
|
+
assert_nil ComfortableMexicanSofa::Tag::Asset.initialize_tag(
|
20
|
+
cms_pages(:default), tag_signature
|
21
|
+
)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_render_no_params
|
26
|
+
tag = ComfortableMexicanSofa::Tag::Asset.initialize_tag(
|
27
|
+
cms_pages(:default), '{{ cms:asset:default }}'
|
28
|
+
)
|
29
|
+
assert_equal '', tag.render
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_render_for_css
|
33
|
+
tag = ComfortableMexicanSofa::Tag::Asset.initialize_tag(
|
34
|
+
cms_pages(:default), '{{ cms:asset:default:css }}'
|
35
|
+
)
|
36
|
+
assert_equal '/cms-css/default.css', tag.render
|
37
|
+
|
38
|
+
tag = ComfortableMexicanSofa::Tag::Asset.initialize_tag(
|
39
|
+
cms_pages(:default), '{{ cms:asset:default:css:html_tag }}'
|
40
|
+
)
|
41
|
+
assert_equal "<link href='/cms-css/default.css' media='screen' rel='stylesheet' type='text/css' />", tag.render
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_render_for_js
|
45
|
+
tag = ComfortableMexicanSofa::Tag::Asset.initialize_tag(
|
46
|
+
cms_pages(:default), '{{ cms:asset:default:js }}'
|
47
|
+
)
|
48
|
+
assert_equal '/cms-js/default.js', tag.render
|
49
|
+
|
50
|
+
tag = ComfortableMexicanSofa::Tag::Asset.initialize_tag(
|
51
|
+
cms_pages(:default), '{{ cms:asset:default:js:html_tag }}'
|
52
|
+
)
|
53
|
+
assert_equal "<script src='/cms-js/default.js' type='text/javascript'></script>", tag.render
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -17,8 +17,8 @@ class HelperTest < ActiveSupport::TestCase
|
|
17
17
|
assert tag = ComfortableMexicanSofa::Tag::Helper.initialize_tag(
|
18
18
|
cms_pages(:default), '{{ cms:helper:method_name:param1:param2 }}'
|
19
19
|
)
|
20
|
-
|
21
|
-
|
20
|
+
assert_equal 'method_name', tag.label
|
21
|
+
assert_equal ['param1', 'param2'], tag.params
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_initialize_tag_failure
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require File.expand_path('../../test_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
class UploadTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
def test_initialize_tag
|
6
|
+
assert tag = ComfortableMexicanSofa::Tag::Upload.initialize_tag(
|
7
|
+
cms_pages(:default), '{{ cms:upload:sample.jpg:image:alt text }}'
|
8
|
+
)
|
9
|
+
assert_equal cms_uploads(:default), tag.upload
|
10
|
+
assert_equal 'sample.jpg', tag.label
|
11
|
+
assert_equal ['image', 'alt text'], tag.params
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_initialize_tag_failure
|
15
|
+
[
|
16
|
+
'{{cms:upload}}',
|
17
|
+
'{{cms:not_upload:label}}',
|
18
|
+
'{not_a_tag}'
|
19
|
+
].each do |tag_signature|
|
20
|
+
assert_nil ComfortableMexicanSofa::Tag::Upload.initialize_tag(
|
21
|
+
cms_pages(:default), tag_signature
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_render_for_invalid
|
27
|
+
tag = ComfortableMexicanSofa::Tag::Upload.initialize_tag(
|
28
|
+
cms_pages(:default), '{{cms:upload:invalid.jpg}}'
|
29
|
+
)
|
30
|
+
assert_nil tag.upload
|
31
|
+
assert_equal '', tag.render
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_render
|
35
|
+
upload = cms_uploads(:default)
|
36
|
+
assert tag = ComfortableMexicanSofa::Tag::Upload.initialize_tag(
|
37
|
+
cms_pages(:default), '{{ cms:upload:sample.jpg }}'
|
38
|
+
)
|
39
|
+
assert_equal upload.file.url, tag.render
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_render_for_link
|
43
|
+
upload = cms_uploads(:default)
|
44
|
+
assert tag = ComfortableMexicanSofa::Tag::Upload.initialize_tag(
|
45
|
+
cms_pages(:default), '{{ cms:upload:sample.jpg:link }}'
|
46
|
+
)
|
47
|
+
assert_equal "<a href='#{upload.file.url}' target='_blank'>sample.jpg</a>", tag.render
|
48
|
+
|
49
|
+
assert tag = ComfortableMexicanSofa::Tag::Upload.initialize_tag(
|
50
|
+
cms_pages(:default), '{{ cms:upload:sample.jpg:link:link text }}'
|
51
|
+
)
|
52
|
+
assert_equal "<a href='#{upload.file.url}' target='_blank'>link text</a>", tag.render
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_render_for_image
|
56
|
+
upload = cms_uploads(:default)
|
57
|
+
assert tag = ComfortableMexicanSofa::Tag::Upload.initialize_tag(
|
58
|
+
cms_pages(:default), '{{ cms:upload:sample.jpg:image }}'
|
59
|
+
)
|
60
|
+
assert_equal "<img src='#{upload.file.url}' alt='sample.jpg' />", tag.render
|
61
|
+
|
62
|
+
assert tag = ComfortableMexicanSofa::Tag::Upload.initialize_tag(
|
63
|
+
cms_pages(:default), '{{ cms:upload:sample.jpg:image:alt text }}'
|
64
|
+
)
|
65
|
+
assert_equal "<img src='#{upload.file.url}' alt='alt text' />", tag.render
|
66
|
+
end
|
67
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: comfortable_mexican_sofa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.2.
|
5
|
+
version: 1.2.7
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Oleg Khabarov
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2011-06-
|
14
|
+
date: 2011-06-04 00:00:00 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|
@@ -228,6 +228,7 @@ files:
|
|
228
228
|
- lib/comfortable_mexican_sofa/is_mirrored.rb
|
229
229
|
- lib/comfortable_mexican_sofa/rails_extensions.rb
|
230
230
|
- lib/comfortable_mexican_sofa/tag.rb
|
231
|
+
- lib/comfortable_mexican_sofa/tags/asset.rb
|
231
232
|
- lib/comfortable_mexican_sofa/tags/field_datetime.rb
|
232
233
|
- lib/comfortable_mexican_sofa/tags/field_integer.rb
|
233
234
|
- lib/comfortable_mexican_sofa/tags/field_string.rb
|
@@ -240,6 +241,7 @@ files:
|
|
240
241
|
- lib/comfortable_mexican_sofa/tags/page_text.rb
|
241
242
|
- lib/comfortable_mexican_sofa/tags/partial.rb
|
242
243
|
- lib/comfortable_mexican_sofa/tags/snippet.rb
|
244
|
+
- lib/comfortable_mexican_sofa/tags/upload.rb
|
243
245
|
- lib/comfortable_mexican_sofa/version.rb
|
244
246
|
- lib/comfortable_mexican_sofa/view_hooks.rb
|
245
247
|
- lib/comfortable_mexican_sofa/view_methods.rb
|
@@ -288,6 +290,7 @@ files:
|
|
288
290
|
- test/unit/models/upload_test.rb
|
289
291
|
- test/unit/revisions_test.rb
|
290
292
|
- test/unit/tag_test.rb
|
293
|
+
- test/unit/tags/asset_test.rb
|
291
294
|
- test/unit/tags/field_datetime_test.rb
|
292
295
|
- test/unit/tags/field_integer_test.rb
|
293
296
|
- test/unit/tags/field_string_test.rb
|
@@ -300,6 +303,7 @@ files:
|
|
300
303
|
- test/unit/tags/page_text_test.rb
|
301
304
|
- test/unit/tags/partial_test.rb
|
302
305
|
- test/unit/tags/snippet_test.rb
|
306
|
+
- test/unit/tags/upload_test.rb
|
303
307
|
- test/unit/view_methods_test.rb
|
304
308
|
homepage: http://github.com/twg/comfortable-mexican-sofa
|
305
309
|
licenses: []
|
@@ -314,7 +318,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
314
318
|
requirements:
|
315
319
|
- - ">="
|
316
320
|
- !ruby/object:Gem::Version
|
317
|
-
hash: -
|
321
|
+
hash: -45372711509925619
|
318
322
|
segments:
|
319
323
|
- 0
|
320
324
|
version: "0"
|