comfortable_mexican_sofa 1.5.11 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (196) hide show
  1. data/.travis.yml +2 -2
  2. data/Gemfile +1 -1
  3. data/VERSION +1 -1
  4. data/app/assets/images/comfortable_mexican_sofa/checkerboard.gif +0 -0
  5. data/app/assets/images/comfortable_mexican_sofa/elrte/elrte-toolbar.png +0 -0
  6. data/app/assets/images/comfortable_mexican_sofa/elrte/google-maps.png +0 -0
  7. data/app/assets/images/comfortable_mexican_sofa/elrte/iframe.png +0 -0
  8. data/app/assets/images/comfortable_mexican_sofa/elrte/media-director.png +0 -0
  9. data/app/assets/images/comfortable_mexican_sofa/elrte/media-flash.png +0 -0
  10. data/app/assets/images/comfortable_mexican_sofa/elrte/media-quicktime.png +0 -0
  11. data/app/assets/images/comfortable_mexican_sofa/elrte/media-realaudio.png +0 -0
  12. data/app/assets/images/comfortable_mexican_sofa/elrte/media-rutube.png +0 -0
  13. data/app/assets/images/comfortable_mexican_sofa/elrte/media-vimeo.png +0 -0
  14. data/app/assets/images/comfortable_mexican_sofa/elrte/media-winmedia.png +0 -0
  15. data/app/assets/images/comfortable_mexican_sofa/elrte/media-youtube.png +0 -0
  16. data/app/assets/images/comfortable_mexican_sofa/elrte/outline-div.png +0 -0
  17. data/app/assets/images/comfortable_mexican_sofa/elrte/outline-p.png +0 -0
  18. data/app/assets/images/comfortable_mexican_sofa/elrte/pagebreak.gif +0 -0
  19. data/app/assets/images/comfortable_mexican_sofa/elrte/pixel.gif +0 -0
  20. data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/evilgrin.png +0 -0
  21. data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/grin.png +0 -0
  22. data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/happy.png +0 -0
  23. data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/smile.png +0 -0
  24. data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/surprised.png +0 -0
  25. data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/tongue.png +0 -0
  26. data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/unhappy.png +0 -0
  27. data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/waii.png +0 -0
  28. data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/wink.png +0 -0
  29. data/app/assets/images/comfortable_mexican_sofa/x.png +0 -0
  30. data/app/assets/javascripts/comfortable_mexican_sofa/application.js +28 -3
  31. data/app/assets/javascripts/comfortable_mexican_sofa/codemirror/codemirror.js +1 -1
  32. data/app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.codemirror.js +35 -0
  33. data/app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.js +267 -0
  34. data/app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_image.js +61 -0
  35. data/app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_link.js +58 -0
  36. data/app/assets/javascripts/comfortable_mexican_sofa/jquery.js +4 -18
  37. data/app/assets/stylesheets/comfortable_mexican_sofa/application.css +3 -0
  38. data/app/assets/stylesheets/comfortable_mexican_sofa/codemirror.css +6 -0
  39. data/app/assets/stylesheets/comfortable_mexican_sofa/content.css +0 -65
  40. data/app/assets/stylesheets/comfortable_mexican_sofa/dialogs.css +45 -0
  41. data/app/assets/stylesheets/comfortable_mexican_sofa/elrte.css +173 -0
  42. data/app/assets/stylesheets/comfortable_mexican_sofa/files.css +82 -0
  43. data/app/assets/stylesheets/comfortable_mexican_sofa/form.css +2 -2
  44. data/app/assets/stylesheets/comfortable_mexican_sofa/structure.css +1 -1
  45. data/app/assets/stylesheets/comfortable_mexican_sofa/widgets.css +14 -56
  46. data/app/controllers/cms_admin/categories_controller.rb +2 -2
  47. data/app/controllers/cms_admin/dialogs_controller.rb +13 -0
  48. data/app/controllers/cms_admin/files_controller.rb +4 -1
  49. data/app/controllers/cms_admin/revisions_controller.rb +2 -2
  50. data/app/controllers/cms_content_controller.rb +1 -1
  51. data/app/models/cms/block.rb +2 -2
  52. data/app/models/cms/category.rb +3 -0
  53. data/app/models/cms/file.rb +9 -1
  54. data/app/models/cms/layout.rb +2 -2
  55. data/app/models/cms/page.rb +7 -5
  56. data/app/models/cms/site.rb +10 -5
  57. data/app/models/cms/snippet.rb +5 -3
  58. data/app/views/cms_admin/categories/_form.html.erb +1 -1
  59. data/app/views/cms_admin/categories/_index.html.erb +2 -2
  60. data/app/views/cms_admin/dialogs/image.html.erb +7 -0
  61. data/app/views/cms_admin/dialogs/link.html.erb +5 -0
  62. data/app/views/cms_admin/files/_file.html.erb +17 -9
  63. data/app/views/cms_admin/files/_index.html.erb +8 -18
  64. data/app/views/cms_admin/files/create.js.erb +1 -1
  65. data/app/views/cms_admin/layouts/_form.html.erb +1 -1
  66. data/app/views/cms_admin/layouts/_index_branch.html.erb +1 -1
  67. data/app/views/cms_admin/pages/_form_blocks.html.erb +1 -1
  68. data/app/views/cms_admin/revisions/show.html.erb +1 -1
  69. data/app/views/cms_admin/sites/_form.html.erb +2 -1
  70. data/app/views/cms_admin/snippets/_form.html.erb +1 -1
  71. data/app/views/cms_admin/snippets/index.html.erb +1 -1
  72. data/app/views/layouts/cms_admin/_head.html.erb +7 -6
  73. data/comfortable_mexican_sofa.gemspec +46 -47
  74. data/config/initializers/paperclip.rb +0 -25
  75. data/config/locales/en.yml +6 -0
  76. data/config/locales/es.yml +6 -0
  77. data/config/routes.rb +3 -2
  78. data/db/migrate/01_create_cms.rb +37 -35
  79. data/db/migrate/upgrades/07_upgrade_to_1_6_0.rb +25 -0
  80. data/lib/comfortable_mexican_sofa/error.rb +4 -4
  81. data/lib/comfortable_mexican_sofa/extensions/is_categorized.rb +3 -1
  82. data/lib/comfortable_mexican_sofa/extensions/is_mirrored.rb +8 -8
  83. data/lib/comfortable_mexican_sofa/fixtures.rb +19 -19
  84. data/lib/comfortable_mexican_sofa/form_builder.rb +4 -4
  85. data/lib/comfortable_mexican_sofa/render_methods.rb +8 -8
  86. data/lib/comfortable_mexican_sofa/tag.rb +14 -13
  87. data/lib/comfortable_mexican_sofa/tags/asset.rb +6 -6
  88. data/lib/comfortable_mexican_sofa/tags/collection.rb +3 -3
  89. data/lib/comfortable_mexican_sofa/tags/field_datetime.rb +3 -3
  90. data/lib/comfortable_mexican_sofa/tags/field_integer.rb +3 -3
  91. data/lib/comfortable_mexican_sofa/tags/field_string.rb +3 -3
  92. data/lib/comfortable_mexican_sofa/tags/field_text.rb +3 -3
  93. data/lib/comfortable_mexican_sofa/tags/file.rb +5 -5
  94. data/lib/comfortable_mexican_sofa/tags/helper.rb +4 -4
  95. data/lib/comfortable_mexican_sofa/tags/page_datetime.rb +3 -3
  96. data/lib/comfortable_mexican_sofa/tags/page_file.rb +8 -6
  97. data/lib/comfortable_mexican_sofa/tags/page_files.rb +6 -4
  98. data/lib/comfortable_mexican_sofa/tags/page_integer.rb +3 -3
  99. data/lib/comfortable_mexican_sofa/tags/page_rich_text.rb +3 -3
  100. data/lib/comfortable_mexican_sofa/tags/page_string.rb +3 -3
  101. data/lib/comfortable_mexican_sofa/tags/page_text.rb +3 -3
  102. data/lib/comfortable_mexican_sofa/tags/partial.rb +4 -4
  103. data/lib/comfortable_mexican_sofa/tags/snippet.rb +5 -4
  104. data/lib/comfortable_mexican_sofa/view_methods.rb +6 -6
  105. data/test/fixtures/cms/blocks.yml +2 -2
  106. data/test/fixtures/cms/categories.yml +1 -0
  107. data/test/fixtures/cms/layouts.yml +3 -3
  108. data/test/fixtures/cms/revisions.yml +4 -4
  109. data/test/fixtures/cms/sites.yml +1 -0
  110. data/test/fixtures/cms/snippets.yml +1 -1
  111. data/test/fixtures/files/data.zip +0 -0
  112. data/test/functional/cms_admin/dialogs_controller_test.rb +24 -0
  113. data/test/functional/cms_admin/files_controller_test.rb +1 -1
  114. data/test/functional/cms_admin/layouts_controller_test.rb +7 -7
  115. data/test/functional/cms_admin/pages_controller_test.rb +34 -35
  116. data/test/functional/cms_admin/revisions_controller_test.rb +2 -2
  117. data/test/functional/cms_admin/sites_controller_test.rb +3 -2
  118. data/test/functional/cms_admin/snippets_controller_test.rb +8 -8
  119. data/test/functional/cms_content_controller_test.rb +10 -11
  120. data/test/gemfiles/{Gemfile.rails-3.0.10 → Gemfile.rails-3.0} +1 -1
  121. data/test/gemfiles/{Gemfile.rails-3.1.1 → Gemfile.rails-3.1} +1 -1
  122. data/test/integration/fixtures_test.rb +4 -4
  123. data/test/integration/mirrors_test.rb +1 -1
  124. data/test/integration/render_cms_test.rb +10 -10
  125. data/test/integration/sites_test.rb +3 -3
  126. data/test/test_helper.rb +3 -0
  127. data/test/unit/fixtures_test.rb +11 -11
  128. data/test/unit/mirrors_test.rb +25 -25
  129. data/test/unit/models/block_test.rb +29 -29
  130. data/test/unit/models/categorization_test.rb +1 -1
  131. data/test/unit/models/category_test.rb +2 -2
  132. data/test/unit/models/file_test.rb +18 -0
  133. data/test/unit/models/layout_test.rb +21 -18
  134. data/test/unit/models/page_test.rb +3 -3
  135. data/test/unit/models/site_test.rb +26 -17
  136. data/test/unit/models/snippet_test.rb +6 -6
  137. data/test/unit/revisions_test.rb +13 -13
  138. data/test/unit/tag_test.rb +39 -45
  139. data/test/unit/tags/asset_test.rb +1 -1
  140. data/test/unit/tags/collection_test.rb +12 -10
  141. data/test/unit/tags/field_datetime_test.rb +3 -3
  142. data/test/unit/tags/field_integer_test.rb +3 -3
  143. data/test/unit/tags/field_string_test.rb +4 -4
  144. data/test/unit/tags/field_text_test.rb +3 -3
  145. data/test/unit/tags/file_test.rb +1 -1
  146. data/test/unit/tags/helper_test.rb +3 -3
  147. data/test/unit/tags/page_datetime_test.rb +3 -3
  148. data/test/unit/tags/page_file_test.rb +7 -4
  149. data/test/unit/tags/page_files_test.rb +7 -4
  150. data/test/unit/tags/page_integer_test.rb +3 -3
  151. data/test/unit/tags/page_rich_text_test.rb +3 -3
  152. data/test/unit/tags/page_string_test.rb +3 -3
  153. data/test/unit/tags/page_text_test.rb +4 -4
  154. data/test/unit/tags/partial_test.rb +4 -4
  155. data/test/unit/tags/snippet_test.rb +3 -3
  156. metadata +51 -52
  157. data/app/assets/images/comfortable_mexican_sofa/wym_icons.png +0 -0
  158. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-blockquote.png +0 -0
  159. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-h1.png +0 -0
  160. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-h2.png +0 -0
  161. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-h3.png +0 -0
  162. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-h4.png +0 -0
  163. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-h5.png +0 -0
  164. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-h6.png +0 -0
  165. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-p.png +0 -0
  166. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-pre.png +0 -0
  167. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/wymiframe.css +0 -52
  168. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/wymiframe.html +0 -26
  169. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/jquery.wymeditor.cms.js +0 -342
  170. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/jquery.wymeditor.embed.js +0 -19
  171. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/jquery.wymeditor.pack.js +0 -1
  172. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/bg.js +0 -45
  173. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/ca.js +0 -45
  174. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/cs.js +0 -45
  175. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/cy.js +0 -45
  176. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/de.js +0 -45
  177. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/en.js +0 -45
  178. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/es.js +0 -45
  179. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/fa.js +0 -46
  180. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/fi.js +0 -44
  181. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/fr.js +0 -45
  182. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/gl.js +0 -45
  183. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/he.js +0 -45
  184. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/hr.js +0 -45
  185. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/hu.js +0 -45
  186. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/it.js +0 -45
  187. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/nb.js +0 -45
  188. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/nl.js +0 -45
  189. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/nn.js +0 -45
  190. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/pl.js +0 -45
  191. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/pt-br.js +0 -45
  192. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/pt.js +0 -45
  193. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/ru.js +0 -45
  194. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/sv.js +0 -45
  195. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/tr.js +0 -45
  196. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/zh_cn.js +0 -47
@@ -0,0 +1,25 @@
1
+ class UpgradeTo150 < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :cms_sites, :identifier, :string, :null => false
4
+ add_index :cms_sites, :identifier
5
+
6
+ rename_column :cms_layouts, :slug, :identifier
7
+ rename_column :cms_blocks, :label, :identifier
8
+ rename_column :cms_snippets, :slug, :identifier
9
+
10
+ add_column :cms_categories, :site_id, :integer, :null => :false
11
+ add_index :cms_categories, [:site_id, :categorized_type, :label], :unique => true
12
+ end
13
+
14
+ def self.down
15
+ remove_index :cms_categories, [:site_id, :categorized_type, :label], :unique => true
16
+ remove_column :cms_categories, :site_id
17
+
18
+ rename_column :cms_snippets, :identifier, :slug
19
+ rename_column :cms_blocks, :identifier, :label
20
+ rename_column :cms_layouts, :identifier, :slug
21
+
22
+ remove_index :cms_sites, :identifier
23
+ remove_column :cms_sites, :identifier
24
+ end
25
+ end
@@ -4,14 +4,14 @@ module ComfortableMexicanSofa
4
4
  end
5
5
 
6
6
  class MissingSite < ComfortableMexicanSofa::Error
7
- def initialize(slug)
8
- super "Cannot find CMS Site with slug: #{slug}"
7
+ def initialize(identifier)
8
+ super "Cannot find CMS Site with identifier: #{identifier}"
9
9
  end
10
10
  end
11
11
 
12
12
  class MissingLayout < ComfortableMexicanSofa::Error
13
- def initialize(slug)
14
- super "Cannot find CMS Layout with slug: #{slug}"
13
+ def initialize(identifier)
14
+ super "Cannot find CMS Layout with identifier: #{identifier}"
15
15
  end
16
16
  end
17
17
 
@@ -22,7 +22,9 @@ module ComfortableMexicanSofa::IsCategorized
22
22
 
23
23
  scope :for_category, lambda { |*categories|
24
24
  if (categories = [categories].flatten.compact).present?
25
- select("DISTINCT #{table_name}.*").joins(:categorizations => :category).where('cms_categories.label' => categories)
25
+ select("DISTINCT #{table_name}.*").
26
+ joins(:categorizations => :category).
27
+ where('cms_categories.label' => categories)
26
28
  end
27
29
  }
28
30
  end
@@ -22,9 +22,9 @@ module ComfortableMexicanSofa::IsMirrored
22
22
  return [] unless self.site.is_mirrored?
23
23
  (Cms::Site.mirrored - [self.site]).collect do |site|
24
24
  case self
25
- when Cms::Layout then site.layouts.find_by_slug(self.slug)
25
+ when Cms::Layout then site.layouts.find_by_identifier(self.identifier)
26
26
  when Cms::Page then site.pages.find_by_full_path(self.full_path)
27
- when Cms::Snippet then site.snippets.find_by_slug(self.slug)
27
+ when Cms::Snippet then site.snippets.find_by_identifier(self.identifier)
28
28
  end
29
29
  end.compact
30
30
  end
@@ -38,10 +38,10 @@ module ComfortableMexicanSofa::IsMirrored
38
38
  (Cms::Site.mirrored - [self.site]).each do |site|
39
39
  mirror = case self
40
40
  when Cms::Layout
41
- m = site.layouts.find_by_slug(self.slug_was || self.slug) || site.layouts.new
41
+ m = site.layouts.find_by_identifier(self.identifier_was || self.identifier) || site.layouts.new
42
42
  m.attributes = {
43
- :slug => self.slug,
44
- :parent_id => site.layouts.find_by_slug(self.parent.try(:slug)).try(:id)
43
+ :identifier => self.identifier,
44
+ :parent_id => site.layouts.find_by_identifier(self.parent.try(:identifier)).try(:id)
45
45
  }
46
46
  m
47
47
  when Cms::Page
@@ -50,13 +50,13 @@ module ComfortableMexicanSofa::IsMirrored
50
50
  :slug => self.slug,
51
51
  :label => self.slug.blank?? self.label : m.label,
52
52
  :parent_id => site.pages.find_by_full_path(self.parent.try(:full_path)).try(:id),
53
- :layout => site.layouts.find_by_slug(self.layout.slug)
53
+ :layout => site.layouts.find_by_identifier(self.layout.identifier)
54
54
  }
55
55
  m
56
56
  when Cms::Snippet
57
- m = site.snippets.find_by_slug(self.slug_was || self.slug) || site.snippets.new
57
+ m = site.snippets.find_by_identifier(self.identifier_was || self.identifier) || site.snippets.new
58
58
  m.attributes = {
59
- :slug => self.slug
59
+ :identifier => self.identifier
60
60
  }
61
61
  m
62
62
  end
@@ -20,11 +20,11 @@ module ComfortableMexicanSofa::Fixtures
20
20
  end
21
21
 
22
22
  Dir.glob("#{path}/*").select{|f| File.directory?(f)}.each do |path|
23
- slug = path.split('/').last
24
- layout = site.layouts.find_by_slug(slug) || site.layouts.new(:slug => slug)
23
+ identifier = path.split('/').last
24
+ layout = site.layouts.find_by_identifier(identifier) || site.layouts.new(:identifier => identifier)
25
25
 
26
26
  # updating attributes
27
- if File.exists?(file_path = File.join(path, "_#{slug}.yml"))
27
+ if File.exists?(file_path = File.join(path, "_#{identifier}.yml"))
28
28
  if layout.new_record? || File.mtime(file_path) > layout.updated_at
29
29
  attributes = YAML.load_file(file_path).symbolize_keys!
30
30
  layout.label = attributes[:label] || slug.titleize
@@ -56,7 +56,7 @@ module ComfortableMexicanSofa::Fixtures
56
56
  layout.parent = parent
57
57
  if layout.changed?
58
58
  layout.save!
59
- Rails.logger.debug "[Fixtures] Saved Layout {#{layout.slug}}"
59
+ Rails.logger.debug "[Fixtures] Saved Layout {#{layout.identifier}}"
60
60
  end
61
61
  layout_ids << layout.id
62
62
 
@@ -94,7 +94,7 @@ module ComfortableMexicanSofa::Fixtures
94
94
  if page.new_record? || File.mtime(file_path) > page.updated_at
95
95
  attributes = YAML.load_file(file_path).symbolize_keys!
96
96
  page.label = attributes[:label] || slug.titleize
97
- page.layout = site.layouts.find_by_slug(attributes[:layout]) || parent.try(:layout)
97
+ page.layout = site.layouts.find_by_identifier(attributes[:layout]) || parent.try(:layout)
98
98
  page.target_page = site.pages.find_by_full_path(attributes[:target_page])
99
99
  page.is_published = attributes[:is_published].present?? attributes[:is_published] : true
100
100
  end
@@ -107,10 +107,10 @@ module ComfortableMexicanSofa::Fixtures
107
107
  blocks_attributes = [ ]
108
108
  Dir.glob("#{path}/*.html").each do |file_path|
109
109
  if page.new_record? || File.mtime(file_path) > page.updated_at
110
- label = file_path.split('/').last.split('.').first
110
+ identifier = file_path.split('/').last.split('.').first
111
111
  blocks_attributes << {
112
- :label => label,
113
- :content => File.open(file_path, 'rb').read
112
+ :identifier => identifier,
113
+ :content => File.open(file_path, 'rb').read
114
114
  }
115
115
  end
116
116
  end
@@ -146,11 +146,11 @@ module ComfortableMexicanSofa::Fixtures
146
146
 
147
147
  snippet_ids = []
148
148
  Dir.glob("#{path}/*").select{|f| File.directory?(f)}.each do |path|
149
- slug = path.split('/').last
150
- snippet = site.snippets.find_by_slug(slug) || site.snippets.new(:slug => slug)
149
+ identifier = path.split('/').last
150
+ snippet = site.snippets.find_by_identifier(identifier) || site.snippets.new(:identifier => identifier)
151
151
 
152
152
  # updating attributes
153
- if File.exists?(file_path = File.join(path, "_#{slug}.yml"))
153
+ if File.exists?(file_path = File.join(path, "_#{identifier}.yml"))
154
154
  if snippet.new_record? || File.mtime(file_path) > snippet.updated_at
155
155
  attributes = YAML.load_file(file_path).symbolize_keys!
156
156
  snippet.label = attributes[:label] || slug.titleize
@@ -169,7 +169,7 @@ module ComfortableMexicanSofa::Fixtures
169
169
  # saving
170
170
  if snippet.changed?
171
171
  snippet.save!
172
- Rails.logger.debug "[Fixtures] Saved Snippet {#{snippet.slug}}"
172
+ Rails.logger.debug "[Fixtures] Saved Snippet {#{snippet.identifier}}"
173
173
  end
174
174
  snippet_ids << snippet.id
175
175
  end
@@ -186,14 +186,14 @@ module ComfortableMexicanSofa::Fixtures
186
186
  FileUtils.mkdir_p(path)
187
187
 
188
188
  site.layouts.each do |layout|
189
- layout_path = File.join(path, layout.ancestors.reverse.collect{|l| l.slug}, layout.slug)
189
+ layout_path = File.join(path, layout.ancestors.reverse.collect{|l| l.identifier}, layout.identifier)
190
190
  FileUtils.mkdir_p(layout_path)
191
191
 
192
- open(File.join(layout_path, "_#{layout.slug}.yml"), 'w') do |f|
192
+ open(File.join(layout_path, "_#{layout.identifier}.yml"), 'w') do |f|
193
193
  f.write({
194
194
  'label' => layout.label,
195
195
  'app_layout' => layout.app_layout,
196
- 'parent' => layout.parent.try(:slug)
196
+ 'parent' => layout.parent.try(:identifier)
197
197
  }.to_yaml)
198
198
  end
199
199
  open(File.join(layout_path, 'content.html'), 'w') do |f|
@@ -222,14 +222,14 @@ module ComfortableMexicanSofa::Fixtures
222
222
  open(File.join(page_path, "_#{page.slug}.yml"), 'w') do |f|
223
223
  f.write({
224
224
  'label' => page.label,
225
- 'layout' => page.layout.try(:slug),
225
+ 'layout' => page.layout.try(:identifier),
226
226
  'parent' => page.parent && (page.parent.slug.present?? page.parent.slug : 'index'),
227
227
  'target_page' => page.target_page.try(:slug),
228
228
  'is_published' => page.is_published
229
229
  }.to_yaml)
230
230
  end
231
231
  page.blocks_attributes.each do |block|
232
- open(File.join(page_path, "#{block[:label]}.html"), 'w') do |f|
232
+ open(File.join(page_path, "#{block[:identifier]}.html"), 'w') do |f|
233
233
  f.write(block[:content])
234
234
  end
235
235
  end
@@ -243,8 +243,8 @@ module ComfortableMexicanSofa::Fixtures
243
243
  FileUtils.mkdir_p(path)
244
244
 
245
245
  site.snippets.each do |snippet|
246
- FileUtils.mkdir_p(snippet_path = File.join(path, snippet.slug))
247
- open(File.join(snippet_path, "_#{snippet.slug}.yml"), 'w') do |f|
246
+ FileUtils.mkdir_p(snippet_path = File.join(path, snippet.identifier))
247
+ open(File.join(snippet_path, "_#{snippet.identifier}.yml"), 'w') do |f|
248
248
  f.write({'label' => snippet.label}.to_yaml)
249
249
  end
250
250
  open(File.join(snippet_path, 'content.html'), 'w') do |f|
@@ -57,7 +57,7 @@ class ComfortableMexicanSofa::FormBuilder < ActionView::Helpers::FormBuilder
57
57
  # -- Tag Field Fields -----------------------------------------------------
58
58
  def default_tag_field(tag, index, options = {})
59
59
  method = options.delete(:method) || :text_field_tag
60
- label = tag.label.to_s.titleize
60
+ label = tag.identifier.to_s.titleize
61
61
  css_class = tag.class.to_s.demodulize.underscore
62
62
  content = ''
63
63
 
@@ -81,7 +81,7 @@ class ComfortableMexicanSofa::FormBuilder < ActionView::Helpers::FormBuilder
81
81
  else
82
82
  content << @template.send(method, "page[blocks_attributes][#{index}][content]", tag.content, :id => nil, :class => input_class)
83
83
  end
84
- content << @template.hidden_field_tag("page[blocks_attributes][#{index}][label]", tag.label, :id => nil)
84
+ content << @template.hidden_field_tag("page[blocks_attributes][#{index}][identifier]", tag.identifier, :id => nil)
85
85
 
86
86
  simple_field(label, content, :class => css_class)
87
87
  end
@@ -141,8 +141,8 @@ class ComfortableMexicanSofa::FormBuilder < ActionView::Helpers::FormBuilder
141
141
  @template.options_for_select(options, :selected => tag.content),
142
142
  :id => nil
143
143
  )
144
- content << @template.hidden_field_tag("page[blocks_attributes][#{index}][label]", tag.label, :id => nil)
145
- simple_field(tag.label.titleize, content, :class => tag.class.to_s.demodulize.underscore )
144
+ content << @template.hidden_field_tag("page[blocks_attributes][#{index}][identifier]", tag.identifier, :id => nil)
145
+ simple_field(tag.identifier.titleize, content, :class => tag.class.to_s.demodulize.underscore )
146
146
  end
147
147
 
148
148
  end
@@ -37,9 +37,9 @@ module ComfortableMexicanSofa::RenderMethods
37
37
  def render(options = {}, locals = {}, &block)
38
38
 
39
39
  # TODO: add slug to Cms::Site as well
40
- if options.is_a?(Hash) && site_slug = options.delete(:cms_site)
41
- unless @cms_site = Cms::Site.find_by_label(site_slug)
42
- raise ComfortableMexicanSofa::MissingSite.new(site_slug)
40
+ if options.is_a?(Hash) && identifier = options.delete(:cms_site)
41
+ unless @cms_site = Cms::Site.find_by_identifier(identifier)
42
+ raise ComfortableMexicanSofa::MissingSite.new(identifier)
43
43
  end
44
44
  end
45
45
 
@@ -55,25 +55,25 @@ module ComfortableMexicanSofa::RenderMethods
55
55
  raise ComfortableMexicanSofa::MissingPage.new(path)
56
56
  end
57
57
 
58
- elsif options.is_a?(Hash) && slug = options.delete(:cms_layout)
58
+ elsif options.is_a?(Hash) && identifier = options.delete(:cms_layout)
59
59
  @cms_site ||= Cms::Site.find_site(request.host.downcase, request.fullpath)
60
- if @cms_layout = @cms_site && @cms_site.layouts.find_by_slug(slug)
60
+ if @cms_layout = @cms_site && @cms_site.layouts.find_by_identifier(identifier)
61
61
  cms_app_layout = @cms_layout.try(:app_layout)
62
62
  cms_page = @cms_site.pages.build(:layout => @cms_layout)
63
63
  cms_blocks = options.delete(:cms_blocks) || { :content => render_to_string(:layout => false)}
64
- cms_blocks.each do |block_label, value|
64
+ cms_blocks.each do |identifier, value|
65
65
  content = if value.is_a?(Hash)
66
66
  render_to_string(value.keys.first.to_sym => value[value.keys.first], :layout => false)
67
67
  else
68
68
  value.to_s
69
69
  end
70
- cms_page.blocks.build(:label => block_label.to_s, :content => content)
70
+ cms_page.blocks.build(:identifier => identifier.to_s, :content => content)
71
71
  end
72
72
  options[:layout] ||= cms_app_layout.blank?? nil : cms_app_layout
73
73
  options[:inline] = cms_page.content(true)
74
74
  super(options, locals, &block)
75
75
  else
76
- raise ComfortableMexicanSofa::MissingLayout.new(slug)
76
+ raise ComfortableMexicanSofa::MissingLayout.new(identifier)
77
77
  end
78
78
 
79
79
  else
@@ -11,7 +11,7 @@ module ComfortableMexicanSofa::Tag
11
11
  TOKENIZER_REGEX = /(\{\{\s*cms:[^{}]*\}\})|((?:\{?[^{])+|\{+)/
12
12
 
13
13
  attr_accessor :page,
14
- :label,
14
+ :identifier,
15
15
  :params,
16
16
  :parent
17
17
 
@@ -20,19 +20,19 @@ module ComfortableMexicanSofa::Tag
20
20
  # Example:
21
21
  # /\{\{\s*?cms:page:(\w+)\}\}/
22
22
  # will match tags like these:
23
- # {{cms:page:my_label}}
24
- def regex_tag_signature(label = nil)
23
+ # {{cms:page:my_identifier}}
24
+ def regex_tag_signature(identifier = nil)
25
25
  nil
26
26
  end
27
27
 
28
28
  # Initializing tag object for a particular Tag type
29
- # First capture group in the regex is the tag label
29
+ # First capture group in the regex is the tag identifier
30
30
  def initialize_tag(page, tag_signature)
31
31
  if match = tag_signature.match(regex_tag_signature)
32
32
  tag = self.new
33
- tag.page = page
34
- tag.label = match[1]
35
- tag.params = match[2].to_s.split(':')
33
+ tag.page = page
34
+ tag.identifier = match[1]
35
+ tag.params = match[2].to_s.split(':')
36
36
  tag
37
37
  end
38
38
  end
@@ -41,8 +41,8 @@ module ComfortableMexicanSofa::Tag
41
41
  module InstanceMethods
42
42
 
43
43
  # String indentifier of the tag
44
- def identifier
45
- "#{self.class.to_s.demodulize.underscore}_#{self.label}"
44
+ def id
45
+ "#{self.class.to_s.demodulize.underscore}_#{self.identifier}"
46
46
  end
47
47
 
48
48
  # Ancestors of this tag constructed during rendering process.
@@ -54,9 +54,9 @@ module ComfortableMexicanSofa::Tag
54
54
 
55
55
  # Regex that is used to identify instance of the tag
56
56
  # Example:
57
- # /<\{\s*?cms:page:tag_label\}/
57
+ # /<\{\s*?cms:page:tag_identifier\}/
58
58
  def regex_tag_signature
59
- self.class.regex_tag_signature(label)
59
+ self.class.regex_tag_signature(identifier)
60
60
  end
61
61
 
62
62
  # Content that is accociated with Tag instance.
@@ -73,7 +73,8 @@ module ComfortableMexicanSofa::Tag
73
73
 
74
74
  # Find or initialize Cms::Block object
75
75
  def block
76
- page.blocks.detect{|b| b.label == self.label.to_s} || page.blocks.build(:label => self.label.to_s)
76
+ page.blocks.detect{|b| b.identifier == self.identifier.to_s} ||
77
+ page.blocks.build(:identifier => self.identifier.to_s)
77
78
  end
78
79
 
79
80
  # Checks if this tag is using Cms::Block
@@ -105,7 +106,7 @@ private
105
106
  if tag_signature
106
107
  if tag = self.initialize_tag(page, tag_signature)
107
108
  tag.parent = parent_tag if parent_tag
108
- if tag.ancestors.select{|a| a.identifier == tag.identifier}.blank?
109
+ if tag.ancestors.select{|a| a.id == tag.id}.blank?
109
110
  page.tags << tag
110
111
  self.process_content(page, tag.render, tag)
111
112
  end
@@ -1,23 +1,23 @@
1
1
  class ComfortableMexicanSofa::Tag::Asset
2
2
  include ComfortableMexicanSofa::Tag
3
3
 
4
- def self.regex_tag_signature(label = nil)
5
- label ||= /[\w\-]+/
6
- /\{\{\s*cms:asset:(#{label}):?(.*?)\s*\}\}/
4
+ def self.regex_tag_signature(identifier = nil)
5
+ identifier ||= /[\w\-]+/
6
+ /\{\{\s*cms:asset:(#{identifier}):?(.*?)\s*\}\}/
7
7
  end
8
8
 
9
9
  def content
10
- return unless (layout = Cms::Layout.find_by_slug(label))
10
+ return unless (layout = Cms::Layout.find_by_identifier(identifier))
11
11
  type = params[0]
12
12
  format = params[1]
13
13
 
14
14
  case type
15
15
  when 'css'
16
- out = "/cms-css/#{page.site.id}/#{label}.css"
16
+ out = "/cms-css/#{page.site.id}/#{identifier}.css"
17
17
  out = "<link href='#{out}' media='screen' rel='stylesheet' type='text/css' />" if format == 'html_tag'
18
18
  out
19
19
  when 'js'
20
- out = "/cms-js/#{page.site.id}/#{label}.js"
20
+ out = "/cms-js/#{page.site.id}/#{identifier}.js"
21
21
  out = "<script src='#{out}' type='text/javascript'></script>" if format == 'html_tag'
22
22
  out
23
23
  end
@@ -7,9 +7,9 @@ class ComfortableMexicanSofa::Tag::Collection
7
7
  # {{ cms:collection:album:foo/my_album }}
8
8
  # A more complete example of the above:
9
9
  # {{ cms:collection:album:foo/my_album:albums/show:title:slug:param_a:param_b }}
10
- def self.regex_tag_signature(label = nil)
11
- label ||= /[\w\/\-]+/
12
- /\{\{\s*cms:collection:(#{label}):(.*?)\s*\}\}/
10
+ def self.regex_tag_signature(identifier = nil)
11
+ identifier ||= /[\w\/\-]+/
12
+ /\{\{\s*cms:collection:(#{identifier}):(.*?)\s*\}\}/
13
13
  end
14
14
 
15
15
  # Class definitition. It's basically `Herp::DerpityDerp.undescore` so an example
@@ -1,9 +1,9 @@
1
1
  class ComfortableMexicanSofa::Tag::FieldDateTime
2
2
  include ComfortableMexicanSofa::Tag
3
3
 
4
- def self.regex_tag_signature(label = nil)
5
- label ||= /[\w\-]+/
6
- /\{\{\s*cms:field:(#{label}):datetime\s*\}\}/
4
+ def self.regex_tag_signature(identifier = nil)
5
+ identifier ||= /[\w\-]+/
6
+ /\{\{\s*cms:field:(#{identifier}):datetime\s*\}\}/
7
7
  end
8
8
 
9
9
  def content
@@ -1,9 +1,9 @@
1
1
  class ComfortableMexicanSofa::Tag::FieldInteger
2
2
  include ComfortableMexicanSofa::Tag
3
3
 
4
- def self.regex_tag_signature(label = nil)
5
- label ||= /[\w\-]+/
6
- /\{\{\s*cms:field:(#{label}):integer\s*\}\}/
4
+ def self.regex_tag_signature(identifier = nil)
5
+ identifier ||= /[\w\-]+/
6
+ /\{\{\s*cms:field:(#{identifier}):integer\s*\}\}/
7
7
  end
8
8
 
9
9
  def content
@@ -1,9 +1,9 @@
1
1
  class ComfortableMexicanSofa::Tag::FieldString
2
2
  include ComfortableMexicanSofa::Tag
3
3
 
4
- def self.regex_tag_signature(label = nil)
5
- label ||= /[\w\-]+/
6
- /\{\{\s*cms:field:(#{label}):?(?:string)?\s*\}\}/
4
+ def self.regex_tag_signature(identifier = nil)
5
+ identifier ||= /[\w\-]+/
6
+ /\{\{\s*cms:field:(#{identifier}):?(?:string)?\s*\}\}/
7
7
  end
8
8
 
9
9
  def content
@@ -1,9 +1,9 @@
1
1
  class ComfortableMexicanSofa::Tag::FieldText
2
2
  include ComfortableMexicanSofa::Tag
3
3
 
4
- def self.regex_tag_signature(label = nil)
5
- label ||= /[\w\-]+/
6
- /\{\{\s*cms:field:(#{label}):?(?:text)?\s*?\}\}/
4
+ def self.regex_tag_signature(identifier = nil)
5
+ identifier ||= /[\w\-]+/
6
+ /\{\{\s*cms:field:(#{identifier}):?(?:text)?\s*?\}\}/
7
7
  end
8
8
 
9
9
  def content