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
@@ -7,7 +7,7 @@
7
7
  width: 117px;
8
8
  float: left;
9
9
  text-align: right;
10
- font: 13px/19px 'Lucida Grande', 'Tahoma', serif;
10
+ font: 13px/19px 'Lucida Grande', 'Tahoma', sans-serif;
11
11
  text-shadow: #fff 1px 1px;
12
12
  padding: 0px 10px;
13
13
  background-color: #f1f1f1;
@@ -169,7 +169,7 @@
169
169
  padding: 3px 5px;
170
170
  background-color: #484848;
171
171
  border-radius: 3px;
172
- font: 9px/14px 'Arial', serif;
172
+ font: 9px/14px 'Arial', sans-serif;
173
173
  text-transform: uppercase;
174
174
  color: #fff;
175
175
  margin-bottom: 3px;
@@ -64,7 +64,7 @@ html, body#cms_body {
64
64
  border-radius: 3px;
65
65
  -moz-border-radius: 3px;
66
66
  margin-bottom: 10px;
67
- overflow: hidden;
67
+ overflow: auto;
68
68
  color: #fff;
69
69
  }
70
70
  /* -- Flash Messages ----------------------------------------------------- */
@@ -8,64 +8,22 @@
8
8
  .ui-timepicker-div dl dd{ margin: -25px 10px 10px 65px; }
9
9
  .ui-timepicker-div td { font-size: 90%; }
10
10
 
11
- /* -- WYMeditor ---------------------------------------------------------- */
12
- .wym_box {
13
- background: #f1f1f1;
14
- border-radius: 3px;
15
- padding: 3px;
16
- }
17
- .wym_box .wym_toolbar {
18
- overflow: hidden;
19
- margin-bottom: 2px;
20
- }
21
- .wym_box .wym_toolbar .wym_toolbar_section li:last-child a {
22
- margin-right: 10px;
23
- }
24
- .wym_box .wym_toolbar a {
25
- display: block;
26
- float: left;
27
- margin-right: 2px;
28
- height: 20px;
29
- width: 20px;
30
- background: #fff url(/assets/comfortable_mexican_sofa/wym_icons.png) no-repeat;
31
- border: 1px solid #fff;
32
- border-radius: 3px;
33
- text-indent: -9999px;
34
- }
35
- .wym_box .wym_toolbar a:hover {
36
- border: 1px solid #d8d8d8;
37
- }
38
- .wym_box .wym_toolbar li.wym_containers_h2 a { background-position: -20px 0px }
39
- .wym_box .wym_toolbar li.wym_containers_h3 a { background-position: -40px 0px }
40
- .wym_box .wym_toolbar li.wym_containers_p a { background-position: -60px 0px }
41
- .wym_box .wym_toolbar li.wym_containers_pre a { background-position: -80px 0px }
42
-
43
- .wym_box .wym_toolbar li.wym_tools_strong a { background-position: -100px 0px }
44
- .wym_box .wym_toolbar li.wym_tools_emphasis a { background-position: -120px 0px }
45
- .wym_box .wym_toolbar li.wym_tools_ordered_list a { background-position: -140px 0px }
46
- .wym_box .wym_toolbar li.wym_tools_unordered_list a { background-position: -160px 0px }
47
- .wym_box .wym_toolbar li.wym_tools_table a { background-position: -180px 0px }
48
- .wym_box .wym_toolbar li.wym_tools_link a { background-position: -200px 0px }
49
- .wym_box .wym_toolbar li.wym_tools_unlink a { background-position: -220px 0px }
50
- .wym_box .wym_toolbar li.wym_tools_image a { background-position: -240px 0px }
51
- .wym_box .wym_toolbar li.wym_tools_paste a { background-position: -260px 0px }
52
- .wym_box .wym_toolbar li.wym_tools_html a { background-position: -280px 0px }
53
-
54
- .wym_box .wym_toolbar li.wym_classes_align_left a { background-position: -300px 0px }
55
- .wym_box .wym_toolbar li.wym_classes_align_center a { background-position: -320px 0px }
56
- .wym_box .wym_toolbar li.wym_classes_align_right a { background-position: -340px 0px }
57
-
58
- .wym_box .wym_html,
59
- .wym_box .wym_iframe {
11
+ /* -- elrte -------------------------------------------------------------- */
12
+ .el-dialogform-content iframe {
60
13
  background: #fff;
61
- border: 1px solid #d8d8d8;
62
14
  }
63
- .wym_box .wym_html {
64
- margin-bottom: 5px;
15
+ .el-rte .toolbar ul li.sofa_image {
16
+ background-position: -384px -2px
17
+ }
18
+ .el-rte .toolbar ul li.sofa_link {
19
+ background-position:-244px -29px
65
20
  }
66
- .wym_box iframe {
67
- display: block;
68
- height: 350px;
69
- width: 100%;
21
+ #cms_body .el-rte .toolbar ul li.formatblock h1,
22
+ #cms_body .el-rte .toolbar ul li.formatblock h2 {
23
+ font: normal 11px 'Trebuchet MS', Verdana, Geneva, sans-serif;
70
24
  border: 0px;
25
+ padding: 0px;
26
+ margin: 0px;
27
+ letter-spacing: normal;
28
+ text-shadow: none;
71
29
  }
@@ -7,7 +7,7 @@ class CmsAdmin::CategoriesController < CmsAdmin::BaseController
7
7
  end
8
8
 
9
9
  def create
10
- @category = Cms::Category.create!(params[:category])
10
+ @category = @site.categories.create!(params[:category])
11
11
  rescue ActiveRecord::RecordInvalid
12
12
  logger.detailed_error($!)
13
13
  render :nothing => true
@@ -27,7 +27,7 @@ class CmsAdmin::CategoriesController < CmsAdmin::BaseController
27
27
  protected
28
28
 
29
29
  def load_category
30
- @category = Cms::Category.find(params[:id])
30
+ @category = @site.categories.find(params[:id])
31
31
  rescue ActiveRecord::RecordNotFound
32
32
  render :nothing => true
33
33
  end
@@ -0,0 +1,13 @@
1
+ class CmsAdmin::DialogsController < CmsAdmin::BaseController
2
+
3
+ TEMPLATES = %w(image link)
4
+
5
+ def show
6
+ if template = TEMPLATES.include?(params[:type])? params[:type] : nil
7
+ render :template => "cms_admin/dialogs/#{template}", :layout => false
8
+ else
9
+ render :nothing => true
10
+ end
11
+ end
12
+
13
+ end
@@ -32,7 +32,10 @@ class CmsAdmin::FilesController < CmsAdmin::BaseController
32
32
  redirect_to :action => :edit, :id => @file
33
33
  end
34
34
  format.js do
35
- io = request.env['rack.input'].clone
35
+ # FIX: No idea why this cannot be simulated in the test
36
+ io = Rails.env.test??
37
+ request.env['RAW_POST_DATA'].clone :
38
+ request.env['rack.input'].clone
36
39
  io.class.class_eval { attr_accessor :original_filename, :content_type }
37
40
  io.original_filename = request.env['HTTP_X_FILE_NAME']
38
41
  io.content_type = request.env['CONTENT_TYPE']
@@ -10,8 +10,8 @@ class CmsAdmin::RevisionsController < CmsAdmin::BaseController
10
10
  def show
11
11
  case @record
12
12
  when Cms::Page
13
- @current_content = @record.blocks.inject({}){|c, b| c[b.label] = b.content; c }
14
- @versioned_content = @record.blocks.inject({}){|c, b| c[b.label] = @revision.data['blocks_attributes'].detect{|r| r[:label] == b.label}.try(:[], :content); c }
13
+ @current_content = @record.blocks.inject({}){|c, b| c[b.identifier] = b.content; c }
14
+ @versioned_content = @record.blocks.inject({}){|c, b| c[b.identifier] = @revision.data['blocks_attributes'].detect{|r| r[:identifier] == b.identifier}.try(:[], :content); c }
15
15
  else
16
16
  @current_content = @record.revision_fields.inject({}){|c, f| c[f] = @record.send(f); c }
17
17
  @versioned_content = @record.revision_fields.inject({}){|c, f| c[f] = @revision.data[f]; c }
@@ -65,7 +65,7 @@ protected
65
65
  end
66
66
 
67
67
  def load_cms_layout
68
- @cms_layout = @cms_site.layouts.find_by_slug!(params[:layout_slug])
68
+ @cms_layout = @cms_site.layouts.find_by_identifier!(params[:identifier])
69
69
  rescue ActiveRecord::RecordNotFound
70
70
  render :nothing => true, :status => 404
71
71
  end
@@ -14,14 +14,14 @@ class Cms::Block < ActiveRecord::Base
14
14
  before_save :prepare_files
15
15
 
16
16
  # -- Validations ----------------------------------------------------------
17
- validates :label,
17
+ validates :identifier,
18
18
  :presence => true,
19
19
  :uniqueness => { :scope => :page_id }
20
20
 
21
21
  # -- Instance Methods -----------------------------------------------------
22
22
  # Tag object that is using this block
23
23
  def tag
24
- @tag ||= page.tags(true).detect{|t| t.is_cms_block? && t.label == label}
24
+ @tag ||= page.tags(true).detect{|t| t.is_cms_block? && t.identifier == identifier}
25
25
  end
26
26
 
27
27
  protected
@@ -5,10 +5,13 @@ class Cms::Category < ActiveRecord::Base
5
5
  set_table_name :cms_categories
6
6
 
7
7
  # -- Relationships --------------------------------------------------------
8
+ belongs_to :site
8
9
  has_many :categorizations,
9
10
  :dependent => :destroy
10
11
 
11
12
  # -- Validations ----------------------------------------------------------
13
+ validates :site_id,
14
+ :presence => true
12
15
  validates :label,
13
16
  :presence => true,
14
17
  :uniqueness => { :scope => :categorized_type }
@@ -14,9 +14,12 @@ class Cms::File < ActiveRecord::Base
14
14
  has_attached_file :file, ComfortableMexicanSofa.config.upload_file_options.merge(
15
15
  # dimensions accessor needs to be set before file assignment for this to work
16
16
  :styles => lambda { |f|
17
- f.instance.dimensions.blank?? { } : { :original => f.instance.dimensions }
17
+ (f.instance.dimensions.blank?? { } : { :original => f.instance.dimensions }).merge(
18
+ :cms_thumb => '80x60#'
19
+ )
18
20
  }
19
21
  )
22
+ before_post_process :is_image?
20
23
 
21
24
  # -- Relationships --------------------------------------------------------
22
25
  belongs_to :site
@@ -36,6 +39,11 @@ class Cms::File < ActiveRecord::Base
36
39
  scope :images, where(:file_content_type => IMAGE_MIMETYPES)
37
40
  scope :not_images, where('file_content_type NOT IN (?)', IMAGE_MIMETYPES)
38
41
 
42
+ # -- Instance Methods -----------------------------------------------------
43
+ def is_image?
44
+ IMAGE_MIMETYPES.include?(file_content_type)
45
+ end
46
+
39
47
  protected
40
48
 
41
49
  def assign_label
@@ -23,7 +23,7 @@ class Cms::Layout < ActiveRecord::Base
23
23
  :presence => true
24
24
  validates :label,
25
25
  :presence => true
26
- validates :slug,
26
+ validates :identifier,
27
27
  :presence => true,
28
28
  :uniqueness => { :scope => :site_id },
29
29
  :format => { :with => /^\w[a-z0-9_-]*$/i }
@@ -73,7 +73,7 @@ class Cms::Layout < ActiveRecord::Base
73
73
  protected
74
74
 
75
75
  def assign_label
76
- self.label = self.label.blank?? self.slug.try(:titleize) : self.label
76
+ self.label = self.label.blank?? self.identifier.try(:titleize) : self.label
77
77
  end
78
78
 
79
79
  def assign_position
@@ -70,22 +70,24 @@ class Cms::Page < ActiveRecord::Base
70
70
  def blocks_attributes(was = false)
71
71
  self.blocks.collect do |block|
72
72
  block_attr = {}
73
- block_attr[:label] = block.label
74
- block_attr[:content] = was ? block.content_was : block.content
73
+ block_attr[:identifier] = block.identifier
74
+ block_attr[:content] = was ? block.content_was : block.content
75
75
  block_attr
76
76
  end
77
77
  end
78
78
 
79
79
  # Array of block hashes in the following format:
80
80
  # [
81
- # { :label => 'block_1', :content => 'block content' },
82
- # { :label => 'block_2', :content => 'block content' }
81
+ # { :identifier => 'block_1', :content => 'block content' },
82
+ # { :identifier => 'block_2', :content => 'block content' }
83
83
  # ]
84
84
  def blocks_attributes=(block_hashes = [])
85
85
  block_hashes = block_hashes.values if block_hashes.is_a?(Hash)
86
86
  block_hashes.each do |block_hash|
87
87
  block_hash.symbolize_keys! unless block_hash.is_a?(HashWithIndifferentAccess)
88
- block = self.blocks.detect{|b| b.label == block_hash[:label]} || self.blocks.build(:label => block_hash[:label])
88
+ block =
89
+ self.blocks.detect{|b| b.identifier == block_hash[:identifier]} ||
90
+ self.blocks.build(:identifier => block_hash[:identifier])
89
91
  block.content = block_hash[:content]
90
92
  self.blocks_attributes_changed = self.blocks_attributes_changed || block.content_changed?
91
93
  end
@@ -5,16 +5,21 @@ class Cms::Site < ActiveRecord::Base
5
5
  set_table_name :cms_sites
6
6
 
7
7
  # -- Relationships --------------------------------------------------------
8
- has_many :layouts, :dependent => :destroy
9
- has_many :pages, :dependent => :destroy
10
- has_many :snippets, :dependent => :destroy
11
- has_many :files, :dependent => :destroy
8
+ has_many :layouts, :dependent => :destroy
9
+ has_many :pages, :dependent => :destroy
10
+ has_many :snippets, :dependent => :destroy
11
+ has_many :files, :dependent => :destroy
12
+ has_many :categories, :dependent => :destroy
12
13
 
13
14
  # -- Callbacks ------------------------------------------------------------
14
15
  before_validation :assign_label
15
16
  before_save :clean_path
16
17
 
17
18
  # -- Validations ----------------------------------------------------------
19
+ validates :identifier,
20
+ :presence => true,
21
+ :uniqueness => true,
22
+ :format => { :with => /^\w[a-z0-9_-]*$/i }
18
23
  validates :label,
19
24
  :presence => true
20
25
  validates :hostname,
@@ -44,7 +49,7 @@ class Cms::Site < ActiveRecord::Base
44
49
  protected
45
50
 
46
51
  def assign_label
47
- self.label = self.label.blank?? self.hostname : self.label
52
+ self.label = self.label.blank?? self.identifier.try(:titleize) : self.label
48
53
  end
49
54
 
50
55
  def clean_path
@@ -22,7 +22,7 @@ class Cms::Snippet < ActiveRecord::Base
22
22
  :presence => true
23
23
  validates :label,
24
24
  :presence => true
25
- validates :slug,
25
+ validates :identifier,
26
26
  :presence => true,
27
27
  :uniqueness => { :scope => :site_id },
28
28
  :format => { :with => /^\w[a-z0-9_-]*$/i }
@@ -33,14 +33,16 @@ class Cms::Snippet < ActiveRecord::Base
33
33
  protected
34
34
 
35
35
  def assign_label
36
- self.label = self.label.blank?? self.slug.try(:titleize) : self.label
36
+ self.label = self.label.blank?? self.identifier.try(:titleize) : self.label
37
37
  end
38
38
 
39
39
  # Note: This might be slow. We have no idea where the snippet is used, so
40
40
  # gotta reload every single page. Kinda sucks, but might be ok unless there
41
41
  # are hundreds of pages.
42
42
  def clear_cached_page_content
43
- site.pages.all.each{ |page| page.save }
43
+ site.pages.all.each do |p|
44
+ Cms::Page.where(:id => p.id).update_all(:content => p.content(true))
45
+ end
44
46
  end
45
47
 
46
48
  def assign_position
@@ -1,5 +1,5 @@
1
1
  <% object = form.object %>
2
- <% if (categories = Cms::Category.of_type(object.class.to_s)).present? %>
2
+ <% if (categories = @site.categories.of_type(object.class.to_s)).present? %>
3
3
  <%= form.simple_field t('.label'), nil, :class => 'categories' do %>
4
4
  <% categories.each do |category| %>
5
5
  <%= hidden_field_tag "#{object.class.to_s.demodulize.downcase}[category_ids][#{category.id}]", 0, :id => nil %>
@@ -11,13 +11,13 @@
11
11
  <div class='category all <%= (params[:category].blank?? 'active' : nil ) %>'>
12
12
  <%= link_to t('.all'), :category => nil %>
13
13
  </div>
14
- <% Cms::Category.of_type(type).each do |category| %>
14
+ <% @site.categories.of_type(type).each do |category| %>
15
15
  <%= render :partial => 'cms_admin/categories/show', :object => category, :locals => { :read => true } %>
16
16
  <% end %>
17
17
  </div>
18
18
 
19
19
  <div class='categories editable' style='display:none'>
20
- <% Cms::Category.of_type(type).each do |category| %>
20
+ <% @site.categories.of_type(type).each do |category| %>
21
21
  <%= render :partial => 'cms_admin/categories/show', :object => category %>
22
22
  <% end %>
23
23
  <div class='category new'>
@@ -0,0 +1,7 @@
1
+ <form class='image_url'>
2
+ <label for='image_url'> URL </label>
3
+ <input type='text' name='image_url' id='image_url'/>
4
+ <input type='submit' value='<%= t('.insert') %>'/>
5
+ </form>
6
+
7
+ <%= render :partial => 'cms_admin/files/index', :locals => {:type => 'image' } %>
@@ -0,0 +1,5 @@
1
+ <form class='link_url'>
2
+ <label for='link_url'> URL </label>
3
+ <input type='text' name='link_url' id='link_url'/>
4
+ <input type='submit' value='<%= t('.create') %>'/>
5
+ </form>
@@ -1,10 +1,18 @@
1
- <div class='file <%= dom_id(file) %>'>
2
- <% file_name = file.file_file_name
3
- file_ext = file.file_file_name.split('.').last
4
- if (file_name.size - file_ext.size) > 30
5
- file_name = file_name.truncate(30) + file_ext
6
- end
7
- %>
8
- <%= link_to file_name, file.file.url, :target => '_blank', :class => 'filename' %>
9
- <%= link_to span_tag('x'), cms_admin_site_file_path(@site, file), :method => :delete, :remote => true, :confirm => t('.are_you_sure'), :class => 'delete' %>
1
+ <div class='file <%= dom_id(file) %> <%= file.is_image?? 'image' : nil %>'>
2
+
3
+ <div class='file_name'>
4
+ <%= link_to file.file_file_name, file.file.url, :target => '_blank', :class => 'filename' %>
5
+ <%= link_to span_tag('x'), cms_admin_site_file_path(@site, file), :method => :delete, :remote => true, :confirm => t('.are_you_sure'), :class => 'delete' %>
6
+ </div>
7
+
8
+ <div class='file_info' data-url='<%= file.file.url %>'>
9
+ <div class='thumb'>
10
+ <%= image_tag file.file.url(:cms_thumb) if file.is_image? %>
11
+ </div>
12
+ <div class='details'>
13
+ <input type='text' value='<%= file.file.url %>'/>
14
+ <div class='file_type'><%= file.file_content_type %></div>
15
+ <div class='file_size'><%= number_to_human_size(file.file_file_size) %></div>
16
+ </div>
17
+ </div>
10
18
  </div>
@@ -1,26 +1,16 @@
1
- <div id='file_uploads' class='box'>
1
+ <% type ||= nil %>
2
+ <% files_scope = (type == 'image') ? @site.files.images : @site.files %>
3
+
4
+ <div class='box file_uploads'>
2
5
 
3
6
  <%= form_for :file, :url => cms_admin_site_files_path(@site), :html => {:multipart => true} do |form| %>
4
7
  <a id='uploader_button' href='#' class='big button'><%= t('.button') %></a>
5
- <%= form.file_field :file, :multiple => true %>
8
+ <%= form.file_field :file, :multiple => true, :id => false %>
6
9
  <% end %>
7
10
 
8
- <div id='uploaded_files'>
9
- <% if (images = Cms::File.images.order(:label)).present? %>
10
- <div class='section images'>
11
- <h3>Images</h3>
12
- <% images.each do |file| %>
13
- <%= render :partial => 'cms_admin/files/file', :object => file %>
14
- <% end %>
15
- </div>
16
- <% end %>
17
- <% if (images = Cms::File.not_images.order(:label)).present? %>
18
- <div class='section other'>
19
- <h3>Files</h3>
20
- <% images.each do |file| %>
21
- <%= render :partial => 'cms_admin/files/file', :object => file %>
22
- <% end %>
23
- </div>
11
+ <div class='uploaded_files'>
12
+ <% files_scope.order(:label).each do |file| %>
13
+ <%= render :partial => 'cms_admin/files/file', :object => file %>
24
14
  <% end %>
25
15
  </div>
26
16
  </div>