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.
Files changed (144) hide show
  1. data/README.md +8 -18
  2. data/Rakefile +1 -4
  3. data/VERSION +1 -1
  4. data/app/controllers/cms_admin/base_controller.rb +8 -9
  5. data/app/controllers/cms_admin/layouts_controller.rb +5 -5
  6. data/app/controllers/cms_admin/pages_controller.rb +14 -14
  7. data/app/controllers/cms_admin/sites_controller.rb +4 -4
  8. data/app/controllers/cms_admin/snippets_controller.rb +4 -4
  9. data/app/controllers/cms_admin/uploads_controller.rb +2 -2
  10. data/app/controllers/cms_content_controller.rb +21 -8
  11. data/app/models/cms/block.rb +13 -0
  12. data/app/models/{cms_layout.rb → cms/layout.rb} +16 -44
  13. data/app/models/{cms_page.rb → cms/page.rb} +26 -57
  14. data/app/models/{cms_site.rb → cms/site.rb} +8 -6
  15. data/app/models/cms/snippet.rb +36 -0
  16. data/app/models/{cms_upload.rb → cms/upload.rb} +5 -3
  17. data/app/views/cms_admin/layouts/_form.html.erb +2 -2
  18. data/app/views/cms_admin/pages/_form.html.erb +5 -5
  19. data/app/views/cms_admin/pages/_form_blocks.html.erb +3 -3
  20. data/app/views/cms_admin/uploads/_index.html.erb +1 -1
  21. data/app/views/layouts/cms_admin.html.erb +2 -38
  22. data/app/views/layouts/cms_admin/_body.html.erb +17 -0
  23. data/app/views/layouts/cms_admin/_center.html.erb +6 -0
  24. data/app/views/layouts/cms_admin/_head.html.erb +11 -0
  25. data/app/views/layouts/cms_admin/_left.html.erb +7 -0
  26. data/app/views/layouts/cms_admin/_right.html.erb +1 -0
  27. data/comfortable_mexican_sofa.gemspec +94 -96
  28. data/config/environments/development.rb +1 -1
  29. data/config/environments/production.rb +1 -1
  30. data/config/environments/test.rb +1 -1
  31. data/config/initializers/comfortable_mexican_sofa.rb +10 -12
  32. data/db/cms_fixtures/example.com/layouts/default/_default.yml +1 -0
  33. data/db/cms_fixtures/example.com/layouts/default/content.html +5 -0
  34. data/db/cms_fixtures/example.com/layouts/default/css.css +1 -0
  35. data/db/cms_fixtures/example.com/layouts/default/js.js +1 -0
  36. data/db/cms_fixtures/example.com/layouts/default/nested/_nested.yml +1 -0
  37. data/db/cms_fixtures/example.com/layouts/default/nested/content.html +2 -0
  38. data/db/cms_fixtures/example.com/layouts/default/nested/css.css +1 -0
  39. data/db/cms_fixtures/example.com/layouts/default/nested/js.js +1 -0
  40. data/db/cms_fixtures/example.com/pages/index/_index.yml +2 -0
  41. data/db/cms_fixtures/example.com/pages/index/child/_child.yml +2 -0
  42. data/db/cms_fixtures/example.com/pages/index/child/left.html +1 -0
  43. data/db/cms_fixtures/example.com/pages/index/child/right.html +1 -0
  44. data/db/cms_fixtures/example.com/pages/index/content.html +2 -0
  45. data/db/cms_fixtures/example.com/snippets/default/_default.yml +1 -0
  46. data/db/cms_fixtures/example.com/snippets/default/content.html +1 -0
  47. data/db/migrate/01_create_cms.rb +11 -11
  48. data/db/migrate/upgrades/02_upgrade_to_1_1_0.rb +19 -0
  49. data/lib/comfortable_mexican_sofa.rb +6 -13
  50. data/lib/comfortable_mexican_sofa/configuration.rb +21 -20
  51. data/lib/comfortable_mexican_sofa/controller_methods.rb +3 -4
  52. data/lib/comfortable_mexican_sofa/engine.rb +1 -1
  53. data/lib/comfortable_mexican_sofa/fixtures.rb +155 -0
  54. data/lib/comfortable_mexican_sofa/form_builder.rb +7 -15
  55. data/lib/comfortable_mexican_sofa/{cms_tag.rb → tag.rb} +42 -23
  56. data/lib/comfortable_mexican_sofa/{cms_tag → tags}/field_datetime.rb +4 -5
  57. data/lib/comfortable_mexican_sofa/{cms_tag → tags}/field_integer.rb +4 -5
  58. data/lib/comfortable_mexican_sofa/{cms_tag → tags}/field_string.rb +4 -5
  59. data/lib/comfortable_mexican_sofa/{cms_tag → tags}/field_text.rb +4 -5
  60. data/lib/comfortable_mexican_sofa/{cms_tag → tags}/helper.rb +2 -5
  61. data/lib/comfortable_mexican_sofa/{cms_tag → tags}/page_datetime.rb +4 -5
  62. data/lib/comfortable_mexican_sofa/{cms_tag → tags}/page_integer.rb +4 -5
  63. data/lib/comfortable_mexican_sofa/{cms_tag → tags}/page_rich_text.rb +4 -5
  64. data/lib/comfortable_mexican_sofa/{cms_tag → tags}/page_string.rb +4 -5
  65. data/lib/comfortable_mexican_sofa/{cms_tag → tags}/page_text.rb +4 -5
  66. data/lib/comfortable_mexican_sofa/{cms_tag → tags}/partial.rb +2 -5
  67. data/lib/comfortable_mexican_sofa/tags/snippet.rb +13 -0
  68. data/lib/comfortable_mexican_sofa/view_methods.rb +4 -3
  69. data/lib/generators/cms_generator.rb +1 -1
  70. data/lib/tasks/comfortable_mexican_sofa.rake +12 -272
  71. data/public/javascripts/comfortable_mexican_sofa/cms.js +1 -1
  72. data/test/fixtures/{cms_blocks.yml → cms/blocks.yml} +2 -2
  73. data/test/fixtures/{cms_layouts.yml → cms/layouts.yml} +3 -3
  74. data/test/fixtures/{cms_pages.yml → cms/pages.yml} +4 -4
  75. data/test/fixtures/{cms_sites.yml → cms/sites.yml} +0 -0
  76. data/test/fixtures/{cms_snippets.yml → cms/snippets.yml} +1 -1
  77. data/test/fixtures/{cms_uploads.yml → cms/uploads.yml} +1 -1
  78. data/test/functional/cms_admin/layouts_controller_test.rb +6 -6
  79. data/test/functional/cms_admin/pages_controller_test.rb +64 -64
  80. data/test/functional/cms_admin/sites_controller_test.rb +5 -5
  81. data/test/functional/cms_admin/snippets_controller_test.rb +6 -6
  82. data/test/functional/cms_admin/uploads_controller_test.rb +4 -4
  83. data/test/functional/cms_content_controller_test.rb +27 -11
  84. data/test/integration/fixtures_test.rb +43 -0
  85. data/test/integration/sites_test.rb +23 -13
  86. data/test/test_helper.rb +9 -8
  87. data/test/unit/{cms_configuration_test.rb → configuration_test.rb} +5 -3
  88. data/test/unit/fixtures_test.rb +198 -0
  89. data/test/unit/models/block_test.rb +33 -0
  90. data/test/unit/models/layout_test.rb +129 -0
  91. data/test/unit/models/page_test.rb +199 -0
  92. data/test/unit/models/site_test.rb +41 -0
  93. data/test/unit/models/snippet_test.rb +32 -0
  94. data/test/unit/models/upload_test.rb +32 -0
  95. data/test/unit/{cms_tag_test.rb → tag_test.rb} +61 -44
  96. data/test/unit/tags/field_datetime_test.rb +44 -0
  97. data/test/unit/tags/field_integer_test.rb +43 -0
  98. data/test/unit/tags/field_string_test.rb +46 -0
  99. data/test/unit/tags/field_text_test.rb +42 -0
  100. data/test/unit/{cms_tags → tags}/helper_test.rb +18 -6
  101. data/test/unit/tags/page_datetime_test.rb +44 -0
  102. data/test/unit/tags/page_integer_test.rb +43 -0
  103. data/test/unit/tags/page_rich_text.rb +43 -0
  104. data/test/unit/{cms_tags → tags}/page_string_test.rb +15 -5
  105. data/test/unit/tags/page_text_test.rb +46 -0
  106. data/test/unit/{cms_tags → tags}/partial_test.rb +24 -8
  107. data/test/unit/tags/snippet_test.rb +45 -0
  108. data/test/unit/view_methods_test.rb +2 -2
  109. metadata +95 -121
  110. data/app/models/cms_block.rb +0 -28
  111. data/app/models/cms_snippet.rb +0 -69
  112. data/db/cms_seeds/example.local/layouts/default.yml +0 -8
  113. data/db/cms_seeds/example.local/layouts/nested.yml +0 -6
  114. data/db/cms_seeds/example.local/pages/child.yml +0 -10
  115. data/db/cms_seeds/example.local/pages/child/subchild.yml +0 -14
  116. data/db/cms_seeds/example.local/pages/index.yml +0 -11
  117. data/db/cms_seeds/example.local/snippets/example.yml +0 -4
  118. data/lib/comfortable_mexican_sofa/cms_tag/snippet.rb +0 -18
  119. data/test/cms_seeds/test.host/layouts/broken.yml +0 -1
  120. data/test/cms_seeds/test.host/layouts/default.yml +0 -3
  121. data/test/cms_seeds/test.host/layouts/nested.yml +0 -4
  122. data/test/cms_seeds/test.host/pages/broken.yml +0 -1
  123. data/test/cms_seeds/test.host/pages/child.yml +0 -10
  124. data/test/cms_seeds/test.host/pages/child/subchild.yml +0 -10
  125. data/test/cms_seeds/test.host/pages/index.yml +0 -10
  126. data/test/cms_seeds/test.host/snippets/broken.yml +0 -1
  127. data/test/cms_seeds/test.host/snippets/default.yml +0 -3
  128. data/test/integration/rake_tasks_test.rb +0 -65
  129. data/test/integration/render_cms_seed_test.rb +0 -34
  130. data/test/unit/cms_block_test.rb +0 -43
  131. data/test/unit/cms_layout_test.rb +0 -179
  132. data/test/unit/cms_page_test.rb +0 -257
  133. data/test/unit/cms_site_test.rb +0 -41
  134. data/test/unit/cms_snippet_test.rb +0 -77
  135. data/test/unit/cms_tags/field_datetime_test.rb +0 -34
  136. data/test/unit/cms_tags/field_integer_test.rb +0 -33
  137. data/test/unit/cms_tags/field_string_test.rb +0 -34
  138. data/test/unit/cms_tags/field_text_test.rb +0 -32
  139. data/test/unit/cms_tags/page_datetime_test.rb +0 -34
  140. data/test/unit/cms_tags/page_integer_test.rb +0 -33
  141. data/test/unit/cms_tags/page_rich_text.rb +0 -33
  142. data/test/unit/cms_tags/page_text_test.rb +0 -34
  143. data/test/unit/cms_tags/snippet_test.rb +0 -33
  144. 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
- when CmsTag::PageRichText then 'rich_text'
63
- when CmsTag::PageText, CmsTag::FieldText then 'code'
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[cms_blocks_attributes][][content]', tag.content, :id => nil, :class => field_css_class)
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[cms_blocks_attributes][][label]', tag.label, :id => nil)}
77
- #{@template.hidden_field_tag('cms_page[cms_blocks_attributes][][id]', tag.record_id, :id => nil) if tag.record_id}
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 CmsTag
7
+ module ComfortableMexicanSofa::Tag
8
8
 
9
9
  TOKENIZER_REGEX = /(\{\{\s*cms:[^{}]*\}\})|((?:\{?[^{])+|\{+)/
10
10
 
11
- attr_accessor :params,
12
- :parent,
13
- :record_id
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(cms_page, tag_signature)
28
+ def initialize_tag(page, tag_signature)
28
29
  if match = tag_signature.match(regex_tag_signature)
29
- if self.respond_to?(:initialize_or_find)
30
- self.initialize_or_find(cms_page, match[1])
31
- else
32
- tag = self.new
33
- tag.label = match[1]
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.name.underscore}_#{self.label}"
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.disable_irb && ![CmsTag::Partial, CmsTag::Helper].member?(self.class)
69
+ if !ComfortableMexicanSofa.config.allow_irb &&
70
+ ![ComfortableMexicanSofa::Tag::Partial, ComfortableMexicanSofa::Tag::Helper].member?(self.class)
72
71
  content.to_s.gsub('<%', '&lt;%').gsub('%>', '%&gt;')
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(cms_page, tag_signature)
101
+ def self.initialize_tag(page, tag_signature)
83
102
  tag_instance = nil
84
- tag_classes.find{ |c| tag_instance = c.initialize_tag(cms_page, tag_signature) }
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(cms_page, content = '', parent_tag = nil)
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(cms_page, tag_signature)
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
- cms_page.cms_tags << tag
99
- self.process_content(cms_page, tag.render, tag)
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, CmsTag::InstanceMethods)
110
- tag.send(:extend, CmsTag::ClassMethods)
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 CmsTag::FieldDateTime < CmsBlock
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
- write_attribute(:content, value)
10
+ block.content = value
12
11
  end
13
12
 
14
13
  def content
15
- read_attribute(:content)
14
+ block.content
16
15
  end
17
16
 
18
17
  def render
@@ -1,6 +1,5 @@
1
- class CmsTag::FieldInteger < CmsBlock
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
- write_attribute(:content, value)
10
+ block.content = value
12
11
  end
13
12
 
14
13
  def content
15
- read_attribute(:content)
14
+ block.content
16
15
  end
17
16
 
18
17
  def render
@@ -1,6 +1,5 @@
1
- class CmsTag::FieldString < CmsBlock
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
- write_attribute(:content, value)
10
+ block.content = value
12
11
  end
13
12
 
14
13
  def content
15
- read_attribute(:content)
14
+ block.content
16
15
  end
17
16
 
18
17
  def render
@@ -1,6 +1,5 @@
1
- class CmsTag::FieldText < CmsBlock
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
- write_attribute(:content, value)
10
+ block.content = value
12
11
  end
13
12
 
14
13
  def content
15
- read_attribute(:content)
14
+ block.content
16
15
  end
17
16
 
18
17
  def render
@@ -1,8 +1,5 @@
1
- class CmsTag::Helper
2
-
3
- attr_accessor :label
4
-
5
- include CmsTag
1
+ class ComfortableMexicanSofa::Tag::Helper
2
+ include ComfortableMexicanSofa::Tag
6
3
 
7
4
  def self.regex_tag_signature(label = nil)
8
5
  label ||= /[\w\-]+/
@@ -1,6 +1,5 @@
1
- class CmsTag::PageDateTime < CmsBlock
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
- write_attribute(:content, value)
10
+ block.content = value
12
11
  end
13
12
 
14
13
  def content
15
- read_attribute(:content)
14
+ block.content
16
15
  end
17
16
 
18
17
  end
@@ -1,6 +1,5 @@
1
- class CmsTag::PageInteger < CmsBlock
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
- write_attribute(:content, value)
10
+ block.content = value
12
11
  end
13
12
 
14
13
  def content
15
- read_attribute(:content)
14
+ block.content
16
15
  end
17
16
 
18
17
  end
@@ -1,6 +1,5 @@
1
- class CmsTag::PageRichText < CmsBlock
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
- write_attribute(:content, value)
10
+ block.content = value
12
11
  end
13
12
 
14
13
  def content
15
- read_attribute(:content)
14
+ block.content
16
15
  end
17
16
 
18
17
  end
@@ -1,6 +1,5 @@
1
- class CmsTag::PageString < CmsBlock
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
- write_attribute(:content, value)
10
+ block.content = value
12
11
  end
13
12
 
14
13
  def content
15
- read_attribute(:content)
14
+ block.content
16
15
  end
17
16
 
18
17
  end
@@ -1,6 +1,5 @@
1
- class CmsTag::PageText < CmsBlock
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
- write_attribute(:content, value)
10
+ block.content = value
12
11
  end
13
12
 
14
13
  def content
15
- read_attribute(:content)
14
+ block.content
16
15
  end
17
16
 
18
17
  end
@@ -1,8 +1,5 @@
1
- class CmsTag::Partial
2
-
3
- attr_accessor :label
4
-
5
- include CmsTag
1
+ class ComfortableMexicanSofa::Tag::Partial
2
+ include ComfortableMexicanSofa::Tag
6
3
 
7
4
  def self.regex_tag_signature(label = nil)
8
5
  label ||= /[\w\/\-]+/
@@ -0,0 +1,13 @@
1
+ class ComfortableMexicanSofa::Tag::Snippet
2
+ include ComfortableMexicanSofa::Tag
3
+
4
+ def self.regex_tag_signature(label = nil)
5
+ label ||= /[\w\-]+/
6
+ /\{\{\s*cms:snippet:(#{label})\s*\}\}/
7
+ end
8
+
9
+ def content
10
+ snippet.content
11
+ end
12
+
13
+ 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 snippet = CmsSnippet.load_for_slug(@cms_site, snippet_slug)
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.cms_blocks.select{|b| b.label == block_label}.first
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
@@ -28,7 +28,7 @@ class CmsGenerator < Rails::Generators::Base
28
28
  end
29
29
 
30
30
  def generate_cms_seeds
31
- directory 'db/cms_seeds', 'db/cms_seeds'
31
+ directory 'db/cms_fixtures', 'db/cms_fixtures'
32
32
  end
33
33
 
34
34
  def show_readme