comfortable_mexican_sofa 1.0.51 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +8 -18
- data/Rakefile +1 -4
- data/VERSION +1 -1
- data/app/controllers/cms_admin/base_controller.rb +8 -9
- data/app/controllers/cms_admin/layouts_controller.rb +5 -5
- data/app/controllers/cms_admin/pages_controller.rb +14 -14
- data/app/controllers/cms_admin/sites_controller.rb +4 -4
- data/app/controllers/cms_admin/snippets_controller.rb +4 -4
- data/app/controllers/cms_admin/uploads_controller.rb +2 -2
- data/app/controllers/cms_content_controller.rb +21 -8
- data/app/models/cms/block.rb +13 -0
- data/app/models/{cms_layout.rb → cms/layout.rb} +16 -44
- data/app/models/{cms_page.rb → cms/page.rb} +26 -57
- data/app/models/{cms_site.rb → cms/site.rb} +8 -6
- data/app/models/cms/snippet.rb +36 -0
- data/app/models/{cms_upload.rb → cms/upload.rb} +5 -3
- data/app/views/cms_admin/layouts/_form.html.erb +2 -2
- data/app/views/cms_admin/pages/_form.html.erb +5 -5
- data/app/views/cms_admin/pages/_form_blocks.html.erb +3 -3
- data/app/views/cms_admin/uploads/_index.html.erb +1 -1
- data/app/views/layouts/cms_admin.html.erb +2 -38
- data/app/views/layouts/cms_admin/_body.html.erb +17 -0
- data/app/views/layouts/cms_admin/_center.html.erb +6 -0
- data/app/views/layouts/cms_admin/_head.html.erb +11 -0
- data/app/views/layouts/cms_admin/_left.html.erb +7 -0
- data/app/views/layouts/cms_admin/_right.html.erb +1 -0
- data/comfortable_mexican_sofa.gemspec +94 -96
- data/config/environments/development.rb +1 -1
- data/config/environments/production.rb +1 -1
- data/config/environments/test.rb +1 -1
- data/config/initializers/comfortable_mexican_sofa.rb +10 -12
- data/db/cms_fixtures/example.com/layouts/default/_default.yml +1 -0
- data/db/cms_fixtures/example.com/layouts/default/content.html +5 -0
- data/db/cms_fixtures/example.com/layouts/default/css.css +1 -0
- data/db/cms_fixtures/example.com/layouts/default/js.js +1 -0
- data/db/cms_fixtures/example.com/layouts/default/nested/_nested.yml +1 -0
- data/db/cms_fixtures/example.com/layouts/default/nested/content.html +2 -0
- data/db/cms_fixtures/example.com/layouts/default/nested/css.css +1 -0
- data/db/cms_fixtures/example.com/layouts/default/nested/js.js +1 -0
- data/db/cms_fixtures/example.com/pages/index/_index.yml +2 -0
- data/db/cms_fixtures/example.com/pages/index/child/_child.yml +2 -0
- data/db/cms_fixtures/example.com/pages/index/child/left.html +1 -0
- data/db/cms_fixtures/example.com/pages/index/child/right.html +1 -0
- data/db/cms_fixtures/example.com/pages/index/content.html +2 -0
- data/db/cms_fixtures/example.com/snippets/default/_default.yml +1 -0
- data/db/cms_fixtures/example.com/snippets/default/content.html +1 -0
- data/db/migrate/01_create_cms.rb +11 -11
- data/db/migrate/upgrades/02_upgrade_to_1_1_0.rb +19 -0
- data/lib/comfortable_mexican_sofa.rb +6 -13
- data/lib/comfortable_mexican_sofa/configuration.rb +21 -20
- data/lib/comfortable_mexican_sofa/controller_methods.rb +3 -4
- data/lib/comfortable_mexican_sofa/engine.rb +1 -1
- data/lib/comfortable_mexican_sofa/fixtures.rb +155 -0
- data/lib/comfortable_mexican_sofa/form_builder.rb +7 -15
- data/lib/comfortable_mexican_sofa/{cms_tag.rb → tag.rb} +42 -23
- data/lib/comfortable_mexican_sofa/{cms_tag → tags}/field_datetime.rb +4 -5
- data/lib/comfortable_mexican_sofa/{cms_tag → tags}/field_integer.rb +4 -5
- data/lib/comfortable_mexican_sofa/{cms_tag → tags}/field_string.rb +4 -5
- data/lib/comfortable_mexican_sofa/{cms_tag → tags}/field_text.rb +4 -5
- data/lib/comfortable_mexican_sofa/{cms_tag → tags}/helper.rb +2 -5
- data/lib/comfortable_mexican_sofa/{cms_tag → tags}/page_datetime.rb +4 -5
- data/lib/comfortable_mexican_sofa/{cms_tag → tags}/page_integer.rb +4 -5
- data/lib/comfortable_mexican_sofa/{cms_tag → tags}/page_rich_text.rb +4 -5
- data/lib/comfortable_mexican_sofa/{cms_tag → tags}/page_string.rb +4 -5
- data/lib/comfortable_mexican_sofa/{cms_tag → tags}/page_text.rb +4 -5
- data/lib/comfortable_mexican_sofa/{cms_tag → tags}/partial.rb +2 -5
- data/lib/comfortable_mexican_sofa/tags/snippet.rb +13 -0
- data/lib/comfortable_mexican_sofa/view_methods.rb +4 -3
- data/lib/generators/cms_generator.rb +1 -1
- data/lib/tasks/comfortable_mexican_sofa.rake +12 -272
- data/public/javascripts/comfortable_mexican_sofa/cms.js +1 -1
- data/test/fixtures/{cms_blocks.yml → cms/blocks.yml} +2 -2
- data/test/fixtures/{cms_layouts.yml → cms/layouts.yml} +3 -3
- data/test/fixtures/{cms_pages.yml → cms/pages.yml} +4 -4
- data/test/fixtures/{cms_sites.yml → cms/sites.yml} +0 -0
- data/test/fixtures/{cms_snippets.yml → cms/snippets.yml} +1 -1
- data/test/fixtures/{cms_uploads.yml → cms/uploads.yml} +1 -1
- data/test/functional/cms_admin/layouts_controller_test.rb +6 -6
- data/test/functional/cms_admin/pages_controller_test.rb +64 -64
- data/test/functional/cms_admin/sites_controller_test.rb +5 -5
- data/test/functional/cms_admin/snippets_controller_test.rb +6 -6
- data/test/functional/cms_admin/uploads_controller_test.rb +4 -4
- data/test/functional/cms_content_controller_test.rb +27 -11
- data/test/integration/fixtures_test.rb +43 -0
- data/test/integration/sites_test.rb +23 -13
- data/test/test_helper.rb +9 -8
- data/test/unit/{cms_configuration_test.rb → configuration_test.rb} +5 -3
- data/test/unit/fixtures_test.rb +198 -0
- data/test/unit/models/block_test.rb +33 -0
- data/test/unit/models/layout_test.rb +129 -0
- data/test/unit/models/page_test.rb +199 -0
- data/test/unit/models/site_test.rb +41 -0
- data/test/unit/models/snippet_test.rb +32 -0
- data/test/unit/models/upload_test.rb +32 -0
- data/test/unit/{cms_tag_test.rb → tag_test.rb} +61 -44
- data/test/unit/tags/field_datetime_test.rb +44 -0
- data/test/unit/tags/field_integer_test.rb +43 -0
- data/test/unit/tags/field_string_test.rb +46 -0
- data/test/unit/tags/field_text_test.rb +42 -0
- data/test/unit/{cms_tags → tags}/helper_test.rb +18 -6
- data/test/unit/tags/page_datetime_test.rb +44 -0
- data/test/unit/tags/page_integer_test.rb +43 -0
- data/test/unit/tags/page_rich_text.rb +43 -0
- data/test/unit/{cms_tags → tags}/page_string_test.rb +15 -5
- data/test/unit/tags/page_text_test.rb +46 -0
- data/test/unit/{cms_tags → tags}/partial_test.rb +24 -8
- data/test/unit/tags/snippet_test.rb +45 -0
- data/test/unit/view_methods_test.rb +2 -2
- metadata +95 -121
- data/app/models/cms_block.rb +0 -28
- data/app/models/cms_snippet.rb +0 -69
- data/db/cms_seeds/example.local/layouts/default.yml +0 -8
- data/db/cms_seeds/example.local/layouts/nested.yml +0 -6
- data/db/cms_seeds/example.local/pages/child.yml +0 -10
- data/db/cms_seeds/example.local/pages/child/subchild.yml +0 -14
- data/db/cms_seeds/example.local/pages/index.yml +0 -11
- data/db/cms_seeds/example.local/snippets/example.yml +0 -4
- data/lib/comfortable_mexican_sofa/cms_tag/snippet.rb +0 -18
- data/test/cms_seeds/test.host/layouts/broken.yml +0 -1
- data/test/cms_seeds/test.host/layouts/default.yml +0 -3
- data/test/cms_seeds/test.host/layouts/nested.yml +0 -4
- data/test/cms_seeds/test.host/pages/broken.yml +0 -1
- data/test/cms_seeds/test.host/pages/child.yml +0 -10
- data/test/cms_seeds/test.host/pages/child/subchild.yml +0 -10
- data/test/cms_seeds/test.host/pages/index.yml +0 -10
- data/test/cms_seeds/test.host/snippets/broken.yml +0 -1
- data/test/cms_seeds/test.host/snippets/default.yml +0 -3
- data/test/integration/rake_tasks_test.rb +0 -65
- data/test/integration/render_cms_seed_test.rb +0 -34
- data/test/unit/cms_block_test.rb +0 -43
- data/test/unit/cms_layout_test.rb +0 -179
- data/test/unit/cms_page_test.rb +0 -257
- data/test/unit/cms_site_test.rb +0 -41
- data/test/unit/cms_snippet_test.rb +0 -77
- data/test/unit/cms_tags/field_datetime_test.rb +0 -34
- data/test/unit/cms_tags/field_integer_test.rb +0 -33
- data/test/unit/cms_tags/field_string_test.rb +0 -34
- data/test/unit/cms_tags/field_text_test.rb +0 -32
- data/test/unit/cms_tags/page_datetime_test.rb +0 -34
- data/test/unit/cms_tags/page_integer_test.rb +0 -33
- data/test/unit/cms_tags/page_rich_text.rb +0 -33
- data/test/unit/cms_tags/page_text_test.rb +0 -34
- data/test/unit/cms_tags/snippet_test.rb +0 -33
- data/test/unit/cms_upload_test.rb +0 -26
@@ -59,22 +59,24 @@ class ComfortableMexicanSofa::FormBuilder < ActionView::Helpers::FormBuilder
|
|
59
59
|
css_class = options[:css_class] || tag.class.name.underscore.downcase.idify
|
60
60
|
|
61
61
|
field_css_class = case tag
|
62
|
-
|
63
|
-
|
62
|
+
when ComfortableMexicanSofa::Tag::PageRichText
|
63
|
+
'rich_text'
|
64
|
+
when ComfortableMexicanSofa::Tag::PageText, ComfortableMexicanSofa::Tag::FieldText
|
65
|
+
'code'
|
64
66
|
end
|
65
67
|
|
66
68
|
options[:content_field_method] ||= :text_field_tag
|
67
69
|
field =
|
68
70
|
options[:field] ||
|
69
|
-
@template.send(options[:content_field_method], 'cms_page[
|
71
|
+
@template.send(options[:content_field_method], 'cms_page[blocks_attributes][][content]', tag.content, :id => nil, :class => field_css_class)
|
70
72
|
|
71
73
|
%(
|
72
74
|
<div class='form_element #{css_class}'>
|
73
75
|
<div class='label'>#{label}</div>
|
74
76
|
<div class='value'>
|
75
77
|
#{field}
|
76
|
-
#{@template.hidden_field_tag('cms_page[
|
77
|
-
#{@template.hidden_field_tag('cms_page[
|
78
|
+
#{@template.hidden_field_tag('cms_page[blocks_attributes][][label]', tag.label, :id => nil)}
|
79
|
+
#{@template.hidden_field_tag('cms_page[blocks_attributes][][id]', tag.record_id, :id => nil) if tag.record_id}
|
78
80
|
</div>
|
79
81
|
</div>
|
80
82
|
).html_safe
|
@@ -116,14 +118,4 @@ class ComfortableMexicanSofa::FormBuilder < ActionView::Helpers::FormBuilder
|
|
116
118
|
default_tag_field(tag, :content_field_method => :text_area_tag)
|
117
119
|
end
|
118
120
|
|
119
|
-
# Capturing all calls of cms_tag_* type. For those we'll try to render
|
120
|
-
# a form element. Everything else can trigger MethodNotFound error.
|
121
|
-
def method_missing(method_name, *args)
|
122
|
-
if m = method_name.to_s.match(/^cms_tag_(\w+)$/)
|
123
|
-
send(m[1], *args) if respond_to?(m[1])
|
124
|
-
else
|
125
|
-
super
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
121
|
end
|
@@ -4,13 +4,14 @@
|
|
4
4
|
# include CmsTag
|
5
5
|
# ...
|
6
6
|
# end
|
7
|
-
module
|
7
|
+
module ComfortableMexicanSofa::Tag
|
8
8
|
|
9
9
|
TOKENIZER_REGEX = /(\{\{\s*cms:[^{}]*\}\})|((?:\{?[^{])+|\{+)/
|
10
10
|
|
11
|
-
attr_accessor :
|
12
|
-
:
|
13
|
-
:
|
11
|
+
attr_accessor :page,
|
12
|
+
:label,
|
13
|
+
:params,
|
14
|
+
:parent
|
14
15
|
|
15
16
|
module ClassMethods
|
16
17
|
# Regex that is used to match tags in the content
|
@@ -24,16 +25,13 @@ module CmsTag
|
|
24
25
|
|
25
26
|
# Initializing tag object for a particular Tag type
|
26
27
|
# First capture group in the regex is the tag label
|
27
|
-
def initialize_tag(
|
28
|
+
def initialize_tag(page, tag_signature)
|
28
29
|
if match = tag_signature.match(regex_tag_signature)
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
tag.params = match[2]
|
35
|
-
tag
|
36
|
-
end
|
30
|
+
tag = self.new
|
31
|
+
tag.page = page
|
32
|
+
tag.label = match[1]
|
33
|
+
tag.params = match[2]
|
34
|
+
tag
|
37
35
|
end
|
38
36
|
end
|
39
37
|
end
|
@@ -42,7 +40,7 @@ module CmsTag
|
|
42
40
|
|
43
41
|
# String indentifier of the tag
|
44
42
|
def identifier
|
45
|
-
"#{self.class.
|
43
|
+
"#{self.class.to_s.demodulize.underscore}_#{self.label}"
|
46
44
|
end
|
47
45
|
|
48
46
|
# Ancestors of this tag constructed during rendering process.
|
@@ -68,35 +66,56 @@ module CmsTag
|
|
68
66
|
# as a default.
|
69
67
|
def render
|
70
68
|
# cleaning content from possible irb stuff. Partial and Helper tags are OK.
|
71
|
-
if ComfortableMexicanSofa.config.
|
69
|
+
if !ComfortableMexicanSofa.config.allow_irb &&
|
70
|
+
![ComfortableMexicanSofa::Tag::Partial, ComfortableMexicanSofa::Tag::Helper].member?(self.class)
|
72
71
|
content.to_s.gsub('<%', '<%').gsub('%>', '%>')
|
73
72
|
else
|
74
73
|
content.to_s
|
75
74
|
end
|
76
75
|
end
|
76
|
+
|
77
|
+
# Find or initialize Cms::Block object
|
78
|
+
def block
|
79
|
+
page.blocks.detect{|b| b.label == self.label.to_s} || page.blocks.build(:label => self.label.to_s)
|
80
|
+
end
|
81
|
+
|
82
|
+
# Find or initialize Cms::Snippet object
|
83
|
+
def snippet
|
84
|
+
page.site.snippets.detect{|s| s.slug == self.label.to_s} || page.site.snippets.build(:slug => self.label.to_s)
|
85
|
+
end
|
86
|
+
|
87
|
+
# Checks if this tag is using Cms::Block
|
88
|
+
def is_cms_block?
|
89
|
+
%w(page field).member?(self.class.to_s.demodulize.underscore.split(/_/).first)
|
90
|
+
end
|
91
|
+
|
92
|
+
# Used in displaying form elements for Cms::Block
|
93
|
+
def record_id
|
94
|
+
block.id
|
95
|
+
end
|
77
96
|
end
|
78
97
|
|
79
98
|
private
|
80
99
|
|
81
100
|
# Initializes a tag. It's handled by one of the tag classes
|
82
|
-
def self.initialize_tag(
|
101
|
+
def self.initialize_tag(page, tag_signature)
|
83
102
|
tag_instance = nil
|
84
|
-
tag_classes.find{ |c| tag_instance = c.initialize_tag(
|
103
|
+
tag_classes.find{ |c| tag_instance = c.initialize_tag(page, tag_signature) }
|
85
104
|
tag_instance
|
86
105
|
end
|
87
106
|
|
88
107
|
# Scanning provided content and splitting it into [tag, text] tuples.
|
89
108
|
# Tags are processed further and their content is expanded in the same way.
|
90
109
|
# Tags are defined in the parent tags are ignored and not rendered.
|
91
|
-
def self.process_content(
|
110
|
+
def self.process_content(page, content = '', parent_tag = nil)
|
92
111
|
tokens = content.to_s.scan(TOKENIZER_REGEX)
|
93
112
|
tokens.collect do |tag_signature, text|
|
94
113
|
if tag_signature
|
95
|
-
if tag = self.initialize_tag(
|
114
|
+
if tag = self.initialize_tag(page, tag_signature)
|
96
115
|
tag.parent = parent_tag if parent_tag
|
97
116
|
if tag.ancestors.select{|a| a.identifier == tag.identifier}.blank?
|
98
|
-
|
99
|
-
self.process_content(
|
117
|
+
page.tags << tag
|
118
|
+
self.process_content(page, tag.render, tag)
|
100
119
|
end
|
101
120
|
end
|
102
121
|
else
|
@@ -106,8 +125,8 @@ private
|
|
106
125
|
end
|
107
126
|
|
108
127
|
def self.included(tag)
|
109
|
-
tag.send(:include,
|
110
|
-
tag.send(:extend,
|
128
|
+
tag.send(:include, ComfortableMexicanSofa::Tag::InstanceMethods)
|
129
|
+
tag.send(:extend, ComfortableMexicanSofa::Tag::ClassMethods)
|
111
130
|
@@tag_classes ||= []
|
112
131
|
@@tag_classes << tag
|
113
132
|
end
|
@@ -1,6 +1,5 @@
|
|
1
|
-
class
|
2
|
-
|
3
|
-
include CmsTag
|
1
|
+
class ComfortableMexicanSofa::Tag::FieldDateTime
|
2
|
+
include ComfortableMexicanSofa::Tag
|
4
3
|
|
5
4
|
def self.regex_tag_signature(label = nil)
|
6
5
|
label ||= /[\w\-]+/
|
@@ -8,11 +7,11 @@ class CmsTag::FieldDateTime < CmsBlock
|
|
8
7
|
end
|
9
8
|
|
10
9
|
def content=(value)
|
11
|
-
|
10
|
+
block.content = value
|
12
11
|
end
|
13
12
|
|
14
13
|
def content
|
15
|
-
|
14
|
+
block.content
|
16
15
|
end
|
17
16
|
|
18
17
|
def render
|
@@ -1,6 +1,5 @@
|
|
1
|
-
class
|
2
|
-
|
3
|
-
include CmsTag
|
1
|
+
class ComfortableMexicanSofa::Tag::FieldInteger
|
2
|
+
include ComfortableMexicanSofa::Tag
|
4
3
|
|
5
4
|
def self.regex_tag_signature(label = nil)
|
6
5
|
label ||= /[\w\-]+/
|
@@ -8,11 +7,11 @@ class CmsTag::FieldInteger < CmsBlock
|
|
8
7
|
end
|
9
8
|
|
10
9
|
def content=(value)
|
11
|
-
|
10
|
+
block.content = value
|
12
11
|
end
|
13
12
|
|
14
13
|
def content
|
15
|
-
|
14
|
+
block.content
|
16
15
|
end
|
17
16
|
|
18
17
|
def render
|
@@ -1,6 +1,5 @@
|
|
1
|
-
class
|
2
|
-
|
3
|
-
include CmsTag
|
1
|
+
class ComfortableMexicanSofa::Tag::FieldString
|
2
|
+
include ComfortableMexicanSofa::Tag
|
4
3
|
|
5
4
|
def self.regex_tag_signature(label = nil)
|
6
5
|
label ||= /[\w\-]+/
|
@@ -8,11 +7,11 @@ class CmsTag::FieldString < CmsBlock
|
|
8
7
|
end
|
9
8
|
|
10
9
|
def content=(value)
|
11
|
-
|
10
|
+
block.content = value
|
12
11
|
end
|
13
12
|
|
14
13
|
def content
|
15
|
-
|
14
|
+
block.content
|
16
15
|
end
|
17
16
|
|
18
17
|
def render
|
@@ -1,6 +1,5 @@
|
|
1
|
-
class
|
2
|
-
|
3
|
-
include CmsTag
|
1
|
+
class ComfortableMexicanSofa::Tag::FieldText
|
2
|
+
include ComfortableMexicanSofa::Tag
|
4
3
|
|
5
4
|
def self.regex_tag_signature(label = nil)
|
6
5
|
label ||= /[\w\-]+/
|
@@ -8,11 +7,11 @@ class CmsTag::FieldText < CmsBlock
|
|
8
7
|
end
|
9
8
|
|
10
9
|
def content=(value)
|
11
|
-
|
10
|
+
block.content = value
|
12
11
|
end
|
13
12
|
|
14
13
|
def content
|
15
|
-
|
14
|
+
block.content
|
16
15
|
end
|
17
16
|
|
18
17
|
def render
|
@@ -1,6 +1,5 @@
|
|
1
|
-
class
|
2
|
-
|
3
|
-
include CmsTag
|
1
|
+
class ComfortableMexicanSofa::Tag::PageDateTime
|
2
|
+
include ComfortableMexicanSofa::Tag
|
4
3
|
|
5
4
|
def self.regex_tag_signature(label = nil)
|
6
5
|
label ||= /[\w\-]+/
|
@@ -8,11 +7,11 @@ class CmsTag::PageDateTime < CmsBlock
|
|
8
7
|
end
|
9
8
|
|
10
9
|
def content=(value)
|
11
|
-
|
10
|
+
block.content = value
|
12
11
|
end
|
13
12
|
|
14
13
|
def content
|
15
|
-
|
14
|
+
block.content
|
16
15
|
end
|
17
16
|
|
18
17
|
end
|
@@ -1,6 +1,5 @@
|
|
1
|
-
class
|
2
|
-
|
3
|
-
include CmsTag
|
1
|
+
class ComfortableMexicanSofa::Tag::PageInteger
|
2
|
+
include ComfortableMexicanSofa::Tag
|
4
3
|
|
5
4
|
def self.regex_tag_signature(label = nil)
|
6
5
|
label ||= /[\w\-]+/
|
@@ -8,11 +7,11 @@ class CmsTag::PageInteger < CmsBlock
|
|
8
7
|
end
|
9
8
|
|
10
9
|
def content=(value)
|
11
|
-
|
10
|
+
block.content = value
|
12
11
|
end
|
13
12
|
|
14
13
|
def content
|
15
|
-
|
14
|
+
block.content
|
16
15
|
end
|
17
16
|
|
18
17
|
end
|
@@ -1,6 +1,5 @@
|
|
1
|
-
class
|
2
|
-
|
3
|
-
include CmsTag
|
1
|
+
class ComfortableMexicanSofa::Tag::PageRichText
|
2
|
+
include ComfortableMexicanSofa::Tag
|
4
3
|
|
5
4
|
def self.regex_tag_signature(label = nil)
|
6
5
|
label ||= /[\w\-]+/
|
@@ -8,11 +7,11 @@ class CmsTag::PageRichText < CmsBlock
|
|
8
7
|
end
|
9
8
|
|
10
9
|
def content=(value)
|
11
|
-
|
10
|
+
block.content = value
|
12
11
|
end
|
13
12
|
|
14
13
|
def content
|
15
|
-
|
14
|
+
block.content
|
16
15
|
end
|
17
16
|
|
18
17
|
end
|
@@ -1,6 +1,5 @@
|
|
1
|
-
class
|
2
|
-
|
3
|
-
include CmsTag
|
1
|
+
class ComfortableMexicanSofa::Tag::PageString
|
2
|
+
include ComfortableMexicanSofa::Tag
|
4
3
|
|
5
4
|
def self.regex_tag_signature(label = nil)
|
6
5
|
label ||= /[\w\-]+/
|
@@ -8,11 +7,11 @@ class CmsTag::PageString < CmsBlock
|
|
8
7
|
end
|
9
8
|
|
10
9
|
def content=(value)
|
11
|
-
|
10
|
+
block.content = value
|
12
11
|
end
|
13
12
|
|
14
13
|
def content
|
15
|
-
|
14
|
+
block.content
|
16
15
|
end
|
17
16
|
|
18
17
|
end
|
@@ -1,6 +1,5 @@
|
|
1
|
-
class
|
2
|
-
|
3
|
-
include CmsTag
|
1
|
+
class ComfortableMexicanSofa::Tag::PageText
|
2
|
+
include ComfortableMexicanSofa::Tag
|
4
3
|
|
5
4
|
def self.regex_tag_signature(label = nil)
|
6
5
|
label ||= /[\w\-]+/
|
@@ -8,11 +7,11 @@ class CmsTag::PageText < CmsBlock
|
|
8
7
|
end
|
9
8
|
|
10
9
|
def content=(value)
|
11
|
-
|
10
|
+
block.content = value
|
12
11
|
end
|
13
12
|
|
14
13
|
def content
|
15
|
-
|
14
|
+
block.content
|
16
15
|
end
|
17
16
|
|
18
17
|
end
|
@@ -22,8 +22,9 @@ module ComfortableMexicanSofa::ViewMethods
|
|
22
22
|
|
23
23
|
# Content of a snippet. Example:
|
24
24
|
# cms_snippet_content(:my_snippet)
|
25
|
-
def cms_snippet_content(snippet_slug)
|
26
|
-
return '' unless
|
25
|
+
def cms_snippet_content(snippet_slug, cms_site = nil)
|
26
|
+
return '' unless cms_site ||= (@cms_site || Cms::Site.find_by_hostname!(request.host.downcase))
|
27
|
+
return '' unless snippet = cms_site.snippets.find_by_slug(snippet_slug)
|
27
28
|
snippet.content.to_s.html_safe
|
28
29
|
end
|
29
30
|
|
@@ -33,7 +34,7 @@ module ComfortableMexicanSofa::ViewMethods
|
|
33
34
|
# cms_page_content(:left_column) # if @cms_page is present
|
34
35
|
def cms_page_content(block_label, page = nil)
|
35
36
|
return '' unless page ||= @cms_page
|
36
|
-
return '' unless block = page.
|
37
|
+
return '' unless block = page.blocks.find_by_label(block_label)
|
37
38
|
block.content.to_s.html_safe
|
38
39
|
end
|
39
40
|
end
|