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
@@ -1,21 +1,21 @@
1
1
  class ComfortableMexicanSofa::Tag::File
2
2
  include ComfortableMexicanSofa::Tag
3
3
 
4
- def self.regex_tag_signature(label = nil)
5
- label ||= /[\w\-\.]+/
6
- /\{\{\s*cms:file:(#{label}):?(.*?)\s*\}\}/
4
+ def self.regex_tag_signature(identifier = nil)
5
+ identifier ||= /[\w\-\.]+/
6
+ /\{\{\s*cms:file:(#{identifier}):?(.*?)\s*\}\}/
7
7
  end
8
8
 
9
9
  # Initializing Cms::File object
10
10
  def file
11
- page.site.files.detect{|f| f.file_file_name == self.label.to_s}
11
+ page.site.files.detect{|f| f.file_file_name == self.identifier.to_s}
12
12
  end
13
13
 
14
14
  def content
15
15
  return unless file
16
16
 
17
17
  format = params[0]
18
- text = params[1] || label
18
+ text = params[1] || identifier
19
19
 
20
20
  case format
21
21
  when 'link'
@@ -1,13 +1,13 @@
1
1
  class ComfortableMexicanSofa::Tag::Helper
2
2
  include ComfortableMexicanSofa::Tag
3
3
 
4
- def self.regex_tag_signature(label = nil)
5
- label ||= /[\w\-]+/
6
- /\{\{\s*cms:helper:(#{label}):?(.*?)\s*\}\}/
4
+ def self.regex_tag_signature(identifier = nil)
5
+ identifier ||= /[\w\-]+/
6
+ /\{\{\s*cms:helper:(#{identifier}):?(.*?)\s*\}\}/
7
7
  end
8
8
 
9
9
  def content
10
- "<%= #{label}(#{params.collect{|p| "'#{p}'"}.join(', ')}) %>"
10
+ "<%= #{identifier}(#{params.collect{|p| "'#{p}'"}.join(', ')}) %>"
11
11
  end
12
12
 
13
13
  end
@@ -1,9 +1,9 @@
1
1
  class ComfortableMexicanSofa::Tag::PageDateTime
2
2
  include ComfortableMexicanSofa::Tag
3
3
 
4
- def self.regex_tag_signature(label = nil)
5
- label ||= /[\w\-]+/
6
- /\{\{\s*cms:page:(#{label}):datetime\s*\}\}/
4
+ def self.regex_tag_signature(identifier = nil)
5
+ identifier ||= /[\w\-]+/
6
+ /\{\{\s*cms:page:(#{identifier}):datetime\s*\}\}/
7
7
  end
8
8
 
9
9
  def content
@@ -5,15 +5,15 @@ class ComfortableMexicanSofa::Tag::PageFile
5
5
  # {{ cms:page_file:some_label:type:params }}
6
6
  # Simple tag can be:
7
7
  # {{ cms:page_file:some_label }}
8
- def self.regex_tag_signature(label = nil)
9
- label ||= /[\w\-]+/
10
- /\{\{\s*cms:page_file:(#{label}):?(.*?)\s*\}\}/
8
+ def self.regex_tag_signature(identifier = nil)
9
+ identifier ||= /[\w\-]+/
10
+ /\{\{\s*cms:page_file:(#{identifier}):?(.*?)\s*\}\}/
11
11
  end
12
12
 
13
13
  # Type of the tag controls how file is rendered
14
14
  def type
15
15
  s = params[0].to_s.gsub(/\[.*?\]/, '')
16
- %w(partial url image link).member?(s) ? s : 'url'
16
+ %w(partial url image link field).member?(s) ? s : 'url'
17
17
  end
18
18
 
19
19
  def dimensions
@@ -32,17 +32,19 @@ class ComfortableMexicanSofa::Tag::PageFile
32
32
  file.file.url
33
33
  when 'link'
34
34
  return '' unless file
35
- text = params[1] || label
35
+ text = params[1] || identifier
36
36
  "<a href='#{file.file.url}' target='_blank'>#{text}</a>"
37
37
  when 'image'
38
38
  return '' unless file
39
- text = params[1] || label
39
+ text = params[1] || identifier
40
40
  "<img src='#{file.file.url}' alt='#{text}' />"
41
41
  when 'partial'
42
42
  path = params[1] || 'partials/page_file'
43
43
  ps = (self.params[2..-1] || []).collect_with_index{|p, i| ":param_#{i+1} => '#{p}'"}.join(', ')
44
44
  ps = ps.present?? ", #{ps}" : ''
45
45
  "<%= render :partial => '#{path}', :locals => {:identifier => #{file.try(:id) || 'nil'}#{ps}} %>"
46
+ when 'field'
47
+ ''
46
48
  end
47
49
  end
48
50
 
@@ -1,15 +1,15 @@
1
1
  class ComfortableMexicanSofa::Tag::PageFiles
2
2
  include ComfortableMexicanSofa::Tag
3
3
 
4
- def self.regex_tag_signature(label = nil)
5
- label ||= /[\w\-]+/
6
- /\{\{\s*cms:page_files:(#{label}):?(.*?)\s*\}\}/
4
+ def self.regex_tag_signature(identifier = nil)
5
+ identifier ||= /[\w\-]+/
6
+ /\{\{\s*cms:page_files:(#{identifier}):?(.*?)\s*\}\}/
7
7
  end
8
8
 
9
9
  # Type of the tag controls how file is rendered
10
10
  def type
11
11
  s = params[0].to_s.gsub(/\[.*?\]/, '')
12
- %w(partial url image link).member?(s) ? s : 'url'
12
+ %w(partial url image link field).member?(s) ? s : 'url'
13
13
  end
14
14
 
15
15
  def dimensions
@@ -44,6 +44,8 @@ class ComfortableMexicanSofa::Tag::PageFiles
44
44
  ps = ps.present?? ", #{ps}" : ''
45
45
  ids = files.present?? files.collect(&:id).join(',') : ''
46
46
  "<%= render :partial => '#{path}', :locals => {:identifier => [#{ids}]#{ps}} %>"
47
+ when 'field'
48
+ ''
47
49
  end
48
50
  end
49
51
 
@@ -1,9 +1,9 @@
1
1
  class ComfortableMexicanSofa::Tag::PageInteger
2
2
  include ComfortableMexicanSofa::Tag
3
3
 
4
- def self.regex_tag_signature(label = nil)
5
- label ||= /[\w\-]+/
6
- /\{\{\s*cms:page:(#{label}):integer\s*\}\}/
4
+ def self.regex_tag_signature(identifier = nil)
5
+ identifier ||= /[\w\-]+/
6
+ /\{\{\s*cms:page:(#{identifier}):integer\s*\}\}/
7
7
  end
8
8
 
9
9
  def content
@@ -1,9 +1,9 @@
1
1
  class ComfortableMexicanSofa::Tag::PageRichText
2
2
  include ComfortableMexicanSofa::Tag
3
3
 
4
- def self.regex_tag_signature(label = nil)
5
- label ||= /[\w\-]+/
6
- /\{\{\s*cms:page:(#{label}):rich_text\s*\}\}/
4
+ def self.regex_tag_signature(identifier = nil)
5
+ identifier ||= /[\w\-]+/
6
+ /\{\{\s*cms:page:(#{identifier}):rich_text\s*\}\}/
7
7
  end
8
8
 
9
9
  def content
@@ -1,9 +1,9 @@
1
1
  class ComfortableMexicanSofa::Tag::PageString
2
2
  include ComfortableMexicanSofa::Tag
3
3
 
4
- def self.regex_tag_signature(label = nil)
5
- label ||= /[\w\-]+/
6
- /\{\{\s*cms:page:(#{label}):string\s*\}\}/
4
+ def self.regex_tag_signature(identifier = nil)
5
+ identifier ||= /[\w\-]+/
6
+ /\{\{\s*cms:page:(#{identifier}):string\s*\}\}/
7
7
  end
8
8
 
9
9
  def content
@@ -1,9 +1,9 @@
1
1
  class ComfortableMexicanSofa::Tag::PageText
2
2
  include ComfortableMexicanSofa::Tag
3
3
 
4
- def self.regex_tag_signature(label = nil)
5
- label ||= /[\w\-]+/
6
- /\{\{\s*cms:page:(#{label}):?(?:text)?\s*\}\}/
4
+ def self.regex_tag_signature(identifier = nil)
5
+ identifier ||= /[\w\-]+/
6
+ /\{\{\s*cms:page:(#{identifier}):?(?:text)?\s*\}\}/
7
7
  end
8
8
 
9
9
  def content
@@ -1,14 +1,14 @@
1
1
  class ComfortableMexicanSofa::Tag::Partial
2
2
  include ComfortableMexicanSofa::Tag
3
3
 
4
- def self.regex_tag_signature(label = nil)
5
- label ||= /[\w\/\-]+/
6
- /\{\{\s*cms:partial:(#{label}):?(.*?)\s*\}\}/
4
+ def self.regex_tag_signature(identifier = nil)
5
+ identifier ||= /[\w\/\-]+/
6
+ /\{\{\s*cms:partial:(#{identifier}):?(.*?)\s*\}\}/
7
7
  end
8
8
 
9
9
  def content
10
10
  ps = params.collect_with_index{|p, i| ":param_#{i+1} => '#{p}'"}.join(', ')
11
- "<%= render :partial => '#{label}'#{ps.blank?? nil : ", :locals => {#{ps}}"} %>"
11
+ "<%= render :partial => '#{identifier}'#{ps.blank?? nil : ", :locals => {#{ps}}"} %>"
12
12
  end
13
13
 
14
14
  end
@@ -1,14 +1,15 @@
1
1
  class ComfortableMexicanSofa::Tag::Snippet
2
2
  include ComfortableMexicanSofa::Tag
3
3
 
4
- def self.regex_tag_signature(label = nil)
5
- label ||= /[\w\-]+/
6
- /\{\{\s*cms:snippet:(#{label})\s*\}\}/
4
+ def self.regex_tag_signature(identifier = nil)
5
+ identifier ||= /[\w\-]+/
6
+ /\{\{\s*cms:snippet:(#{identifier})\s*\}\}/
7
7
  end
8
8
 
9
9
  # Find or initialize Cms::Snippet object
10
10
  def snippet
11
- page.site.snippets.detect{|s| s.slug == self.label.to_s} || page.site.snippets.build(:slug => self.label.to_s)
11
+ page.site.snippets.detect{|s| s.identifier == self.identifier.to_s} ||
12
+ page.site.snippets.build(:identifier => self.identifier.to_s)
12
13
  end
13
14
 
14
15
  def content
@@ -17,13 +17,13 @@ module ComfortableMexicanSofa::ViewMethods
17
17
 
18
18
  # Content of a snippet. Example:
19
19
  # cms_snippet_content(:my_snippet)
20
- def cms_snippet_content(snippet_slug, cms_site = nil)
20
+ def cms_snippet_content(identifier, cms_site = nil)
21
21
  return '' unless cms_site ||= (@cms_site || Cms::Site.find_site(request.host.downcase, request.fullpath))
22
- case snippet_slug
22
+ case identifier
23
23
  when Cms::Snippet
24
- snippet = snippet_slug
24
+ snippet = identifier
25
25
  else
26
- return '' unless snippet = cms_site.snippets.find_by_slug(snippet_slug)
26
+ return '' unless snippet = cms_site.snippets.find_by_identifier(identifier)
27
27
  end
28
28
  render :inline => ComfortableMexicanSofa::Tag.process_content(cms_site.pages.build, snippet.content)
29
29
  end
@@ -32,9 +32,9 @@ module ComfortableMexicanSofa::ViewMethods
32
32
  # Example:
33
33
  # cms_page_content(:left_column, CmsPage.first)
34
34
  # cms_page_content(:left_column) # if @cms_page is present
35
- def cms_page_content(block_label, page = nil)
35
+ def cms_page_content(identifier, page = nil)
36
36
  return '' unless page ||= @cms_page
37
- return '' unless block = page.blocks.find_by_label(block_label)
37
+ return '' unless block = page.blocks.find_by_identifier(identifier)
38
38
  render :inline => ComfortableMexicanSofa::Tag.process_content(page, block.content)
39
39
  end
40
40
  end
@@ -1,11 +1,11 @@
1
1
  default_field_text:
2
2
  page: default
3
- label: default_field_text
3
+ identifier: default_field_text
4
4
  content: default_field_text_content
5
5
 
6
6
  default_page_text:
7
7
  page: default
8
- label: default_page_text
8
+ identifier: default_page_text
9
9
  content: |-
10
10
  default_page_text_content_a
11
11
  {{cms:snippet:default}}
@@ -1,3 +1,4 @@
1
1
  default:
2
+ site: default
2
3
  label: Default
3
4
  categorized_type: Cms::File
@@ -1,7 +1,7 @@
1
1
  default:
2
2
  site: default
3
3
  label: Default Layout
4
- slug: default
4
+ identifier: default
5
5
  parent:
6
6
  content: |-
7
7
  {{cms:field:default_field_text:text}}
@@ -17,7 +17,7 @@ default:
17
17
  nested:
18
18
  site: default
19
19
  label: Nested Layout
20
- slug: nested
20
+ identifier: nested
21
21
  parent:
22
22
  content: |-
23
23
  {{cms:page:header}}
@@ -29,7 +29,7 @@ nested:
29
29
  child:
30
30
  site: default
31
31
  label: Child Layout
32
- slug: child
32
+ identifier: child
33
33
  parent: nested
34
34
  content: |-
35
35
  {{cms:page:left_column}}
@@ -9,10 +9,10 @@ page:
9
9
  record: default (Cms::Page)
10
10
  data: <%= {
11
11
  'blocks_attributes' => [
12
- { 'label' => 'default_page_text',
13
- 'content' => 'revision page content' },
14
- { 'label' => 'default_field_text',
15
- 'content' => 'revision field content'}
12
+ { 'identifier' => 'default_page_text',
13
+ 'content' => 'revision page content' },
14
+ { 'identifier' => 'default_field_text',
15
+ 'content' => 'revision field content'}
16
16
  ]}.to_yaml.inspect %>
17
17
 
18
18
  snippet:
@@ -1,5 +1,6 @@
1
1
  default:
2
2
  label: Default Site
3
+ identifier: default-site
3
4
  hostname: test.host
4
5
  path:
5
6
  is_mirrored: false
@@ -1,6 +1,6 @@
1
1
  default:
2
2
  site: default
3
3
  label: Default Snippet
4
- slug: default
4
+ identifier: default
5
5
  content: default_snippet_content
6
6
  position: 0
@@ -0,0 +1,24 @@
1
+ require File.expand_path('../../test_helper', File.dirname(__FILE__))
2
+
3
+ class CmsAdmin::DialogsControllerTest < ActionController::TestCase
4
+
5
+ def test_get_image_dialog
6
+ get :show, :site_id => cms_sites(:default), :type => 'image'
7
+ assert_response :success
8
+ assert_template 'image'
9
+ assert_select "input[name=image_url]"
10
+ end
11
+
12
+ def test_get_link_dialog
13
+ get :show, :site_id => cms_sites(:default), :type => 'link'
14
+ assert_response :success
15
+ assert_template 'link'
16
+ end
17
+
18
+ def test_get_invalid
19
+ get :show, :site_id => cms_sites(:default), :type => 'invalid'
20
+ assert_response :success
21
+ assert_blank response.body
22
+ end
23
+
24
+ end
@@ -113,7 +113,7 @@ class CmsAdmin::FilesControllerTest < ActionController::TestCase
113
113
  def test_create_as_xhr
114
114
  request.env['HTTP_X_FILE_NAME'] = 'image.jpg'
115
115
  request.env['CONTENT_TYPE'] = 'image/jpeg'
116
- request.env['RAW_POST_DATA'] = File.open(File.expand_path('../../fixtures/files/image.jpg', File.dirname(__FILE__))).read
116
+ request.env['RAW_POST_DATA'] = File.open(File.expand_path('../../fixtures/files/image.jpg', File.dirname(__FILE__)))
117
117
 
118
118
  assert_difference 'Cms::File.count' do
119
119
  xhr :post, :create, :site_id => cms_sites(:default)
@@ -46,9 +46,9 @@ class CmsAdmin::LayoutsControllerTest < ActionController::TestCase
46
46
  def test_creation
47
47
  assert_difference 'Cms::Layout.count' do
48
48
  post :create, :site_id => cms_sites(:default), :layout => {
49
- :label => 'Test Layout',
50
- :slug => 'test',
51
- :content => 'Test {{cms:page:content}}'
49
+ :label => 'Test Layout',
50
+ :identifier => 'test',
51
+ :content => 'Test {{cms:page:content}}'
52
52
  }
53
53
  assert_response :redirect
54
54
  layout = Cms::Layout.last
@@ -84,12 +84,12 @@ class CmsAdmin::LayoutsControllerTest < ActionController::TestCase
84
84
  def test_update_failure
85
85
  layout = cms_layouts(:default)
86
86
  put :update, :site_id => cms_sites(:default), :id => layout, :layout => {
87
- :slug => ''
87
+ :identifier => ''
88
88
  }
89
89
  assert_response :success
90
90
  assert_template :edit
91
91
  layout.reload
92
- assert_not_equal '', layout.slug
92
+ assert_not_equal '', layout.identifier
93
93
  assert_equal 'Failed to update layout', flash[:error]
94
94
  end
95
95
 
@@ -105,8 +105,8 @@ class CmsAdmin::LayoutsControllerTest < ActionController::TestCase
105
105
  def test_reorder
106
106
  layout_one = cms_layouts(:default)
107
107
  layout_two = cms_sites(:default).layouts.create!(
108
- :label => 'test',
109
- :slug => 'test'
108
+ :label => 'test',
109
+ :identifier => 'test'
110
110
  )
111
111
  assert_equal 0, layout_one.position
112
112
  assert_equal 1, layout_two.position
@@ -17,7 +17,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
17
17
  end
18
18
 
19
19
  def test_get_index_with_category
20
- category = Cms::Category.create!(:label => 'Test Category', :categorized_type => 'Cms::Page')
20
+ category = cms_sites(:default).categories.create!(:label => 'Test Category', :categorized_type => 'Cms::Page')
21
21
  category.categorizations.create!(:categorized => cms_pages(:child))
22
22
 
23
23
  get :index, :site_id => cms_sites(:default), :category => category.label
@@ -51,7 +51,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
51
51
  get :new, :site_id => cms_sites(:default)
52
52
  assert_response :success
53
53
  assert_select "input[type='text'][name='page[blocks_attributes][0][content]'][class='datetime']"
54
- assert_select "input[type='hidden'][name='page[blocks_attributes][0][label]'][value='test_label']"
54
+ assert_select "input[type='hidden'][name='page[blocks_attributes][0][identifier]'][value='test_label']"
55
55
  end
56
56
 
57
57
  def test_get_new_with_field_integer
@@ -59,7 +59,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
59
59
  get :new, :site_id => cms_sites(:default)
60
60
  assert_response :success
61
61
  assert_select "input[type='number'][name='page[blocks_attributes][0][content]']"
62
- assert_select "input[type='hidden'][name='page[blocks_attributes][0][label]'][value='test_label']"
62
+ assert_select "input[type='hidden'][name='page[blocks_attributes][0][identifier]'][value='test_label']"
63
63
  end
64
64
 
65
65
  def test_get_new_with_field_string
@@ -67,7 +67,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
67
67
  get :new, :site_id => cms_sites(:default)
68
68
  assert_response :success
69
69
  assert_select "input[type='text'][name='page[blocks_attributes][0][content]']"
70
- assert_select "input[type='hidden'][name='page[blocks_attributes][0][label]'][value='test_label']"
70
+ assert_select "input[type='hidden'][name='page[blocks_attributes][0][identifier]'][value='test_label']"
71
71
  end
72
72
 
73
73
  def test_get_new_with_field_text
@@ -75,7 +75,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
75
75
  get :new, :site_id => cms_sites(:default)
76
76
  assert_response :success
77
77
  assert_select "textarea[name='page[blocks_attributes][0][content]'][class='code']"
78
- assert_select "input[type='hidden'][name='page[blocks_attributes][0][label]'][value='test_label']"
78
+ assert_select "input[type='hidden'][name='page[blocks_attributes][0][identifier]'][value='test_label']"
79
79
  end
80
80
 
81
81
  def test_get_new_with_page_datetime
@@ -83,7 +83,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
83
83
  get :new, :site_id => cms_sites(:default)
84
84
  assert_response :success
85
85
  assert_select "input[type='text'][name='page[blocks_attributes][0][content]'][class='datetime']"
86
- assert_select "input[type='hidden'][name='page[blocks_attributes][0][label]'][value='test_label']"
86
+ assert_select "input[type='hidden'][name='page[blocks_attributes][0][identifier]'][value='test_label']"
87
87
  end
88
88
 
89
89
  def test_get_new_with_page_integer
@@ -91,7 +91,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
91
91
  get :new, :site_id => cms_sites(:default)
92
92
  assert_response :success
93
93
  assert_select "input[type='number'][name='page[blocks_attributes][0][content]']"
94
- assert_select "input[type='hidden'][name='page[blocks_attributes][0][label]'][value='test_label']"
94
+ assert_select "input[type='hidden'][name='page[blocks_attributes][0][identifier]'][value='test_label']"
95
95
  end
96
96
 
97
97
  def test_get_new_with_page_string
@@ -99,7 +99,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
99
99
  get :new, :site_id => cms_sites(:default)
100
100
  assert_response :success
101
101
  assert_select "input[type='text'][name='page[blocks_attributes][0][content]']"
102
- assert_select "input[type='hidden'][name='page[blocks_attributes][0][label]'][value='test_label']"
102
+ assert_select "input[type='hidden'][name='page[blocks_attributes][0][identifier]'][value='test_label']"
103
103
  end
104
104
 
105
105
  def test_get_new_with_page_text
@@ -107,7 +107,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
107
107
  get :new, :site_id => cms_sites(:default)
108
108
  assert_response :success
109
109
  assert_select "textarea[name='page[blocks_attributes][0][content]'][class='code']"
110
- assert_select "input[type='hidden'][name='page[blocks_attributes][0][label]'][value='test_label']"
110
+ assert_select "input[type='hidden'][name='page[blocks_attributes][0][identifier]'][value='test_label']"
111
111
  end
112
112
 
113
113
  def test_get_new_with_page_file
@@ -115,7 +115,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
115
115
  get :new, :site_id => cms_sites(:default)
116
116
  assert_response :success
117
117
  assert_select "input[type='file'][name='page[blocks_attributes][0][content]']"
118
- assert_select "input[type='hidden'][name='page[blocks_attributes][0][label]'][value='test_label']"
118
+ assert_select "input[type='hidden'][name='page[blocks_attributes][0][identifier]'][value='test_label']"
119
119
  end
120
120
 
121
121
  def test_get_new_with_page_files
@@ -123,7 +123,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
123
123
  get :new, :site_id => cms_sites(:default)
124
124
  assert_response :success
125
125
  assert_select "input[type='file'][name='page[blocks_attributes][0][content][]'][multiple=multiple]"
126
- assert_select "input[type='hidden'][name='page[blocks_attributes][0][label]'][value='test_label']"
126
+ assert_select "input[type='hidden'][name='page[blocks_attributes][0][identifier]'][value='test_label']"
127
127
  end
128
128
 
129
129
  def test_get_new_with_collection
@@ -135,7 +135,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
135
135
  assert_select "option[value='']", :html => '---- Select Cms/Snippet ----'
136
136
  assert_select "option[value='#{snippet.id}']", :html => snippet.label
137
137
  end
138
- assert_select "input[type='hidden'][name='page[blocks_attributes][0][label]'][value='snippet']"
138
+ assert_select "input[type='hidden'][name='page[blocks_attributes][0][identifier]'][value='snippet']"
139
139
  end
140
140
 
141
141
  def test_get_new_with_rich_page_text
@@ -143,7 +143,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
143
143
  get :new, :site_id => cms_sites(:default)
144
144
  assert_response :success
145
145
  assert_select "textarea[name='page[blocks_attributes][0][content]'][class='rich_text']"
146
- assert_select "input[type='hidden'][name='page[blocks_attributes][0][label]'][value='test_label']"
146
+ assert_select "input[type='hidden'][name='page[blocks_attributes][0][identifier]'][value='test_label']"
147
147
  end
148
148
 
149
149
  def test_get_new_with_several_tag_fields
@@ -151,9 +151,9 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
151
151
  get :new, :site_id => cms_sites(:default)
152
152
  assert_response :success
153
153
  assert_select "textarea[name='page[blocks_attributes][0][content]']"
154
- assert_select "input[type='hidden'][name='page[blocks_attributes][0][label]'][value='label_a']"
154
+ assert_select "input[type='hidden'][name='page[blocks_attributes][0][identifier]'][value='label_a']"
155
155
  assert_select "textarea[name='page[blocks_attributes][1][content]']"
156
- assert_select "input[type='hidden'][name='page[blocks_attributes][1][label]'][value='label_b']"
156
+ assert_select "input[type='hidden'][name='page[blocks_attributes][1][identifier]'][value='label_b']"
157
157
  end
158
158
 
159
159
  def test_get_new_with_crashy_tag
@@ -167,9 +167,9 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
167
167
  get :new, :site_id => cms_sites(:default)
168
168
  assert_response :success
169
169
  assert_select "textarea[name='page[blocks_attributes][0][content]'][class='code']"
170
- assert_select "input[type='hidden'][name='page[blocks_attributes][0][label]'][value='test_label']"
170
+ assert_select "input[type='hidden'][name='page[blocks_attributes][0][identifier]'][value='test_label']"
171
171
  assert_select "textarea[name='page[blocks_attributes][1][content]'][class='code']", 0
172
- assert_select "input[type='hidden'][name='page[blocks_attributes][1][label]'][value='test_label']", 0
172
+ assert_select "input[type='hidden'][name='page[blocks_attributes][1][identifier]'][value='test_label']", 0
173
173
  end
174
174
 
175
175
  def test_get_new_as_child_page
@@ -215,10 +215,10 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
215
215
  :parent_id => cms_pages(:default).id,
216
216
  :layout_id => cms_layouts(:default).id,
217
217
  :blocks_attributes => [
218
- { :label => 'default_page_text',
219
- :content => 'content content' },
220
- { :label => 'default_field_text',
221
- :content => 'title content' }
218
+ { :identifier => 'default_page_text',
219
+ :content => 'content content' },
220
+ { :identifier => 'default_field_text',
221
+ :content => 'title content' }
222
222
  ]
223
223
  }, :commit => 'Create Page'
224
224
  assert_response :redirect
@@ -235,10 +235,10 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
235
235
  post :create, :site_id => cms_sites(:default), :page => {
236
236
  :layout_id => cms_layouts(:default).id,
237
237
  :blocks_attributes => [
238
- { :label => 'default_page_text',
239
- :content => 'content content' },
240
- { :label => 'default_field_text',
241
- :content => 'title content' }
238
+ { :identifier => 'default_page_text',
239
+ :content => 'content content' },
240
+ { :identifier => 'default_field_text',
241
+ :content => 'title content' }
242
242
  ]
243
243
  }
244
244
  assert_response :success
@@ -271,10 +271,10 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
271
271
  :label => 'Updated Label',
272
272
  :layout_id => cms_layouts(:nested).id,
273
273
  :blocks_attributes => [
274
- { :label => 'content',
275
- :content => 'new_page_text_content' },
276
- { :label => 'header',
277
- :content => 'new_page_string_content' }
274
+ { :identifier => 'content',
275
+ :content => 'new_page_text_content' },
276
+ { :identifier => 'header',
277
+ :content => 'new_page_string_content' }
278
278
  ]
279
279
  }
280
280
  page.reload
@@ -282,7 +282,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
282
282
  assert_redirected_to :action => :edit, :id => page
283
283
  assert_equal 'Page updated', flash[:notice]
284
284
  assert_equal 'Updated Label', page.label
285
- assert_equal ['content', 'default_field_text', 'default_page_text', 'header'], page.blocks.collect{|b| b.label}
285
+ assert_equal ['content', 'default_field_text', 'default_page_text', 'header'], page.blocks.collect{|b| b.identifier}
286
286
  end
287
287
  end
288
288
 
@@ -341,8 +341,8 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
341
341
  :parent_id => cms_pages(:default).id,
342
342
  :layout_id => layout.id,
343
343
  :blocks_attributes => [
344
- { :label => 'default_page_text',
345
- :content => 'preview content' }
344
+ { :identifier => 'default_page_text',
345
+ :content => 'preview content' }
346
346
  ]
347
347
  }
348
348
  assert_response :success
@@ -361,9 +361,8 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
361
361
  put :update, :site_id => page.site, :preview => 'Preview', :id => page, :page => {
362
362
  :label => 'Updated Label',
363
363
  :blocks_attributes => [
364
- { :label => 'default_page_text',
365
- :content => 'preview content',
366
- :id => cms_blocks(:default_page_text).id}
364
+ { :identifier => 'default_page_text',
365
+ :content => 'preview content' }
367
366
  ]
368
367
  }
369
368
  assert_response :success