comfortable_mexican_sofa 2.0.2 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +95 -4
  3. data/.travis.yml +2 -1
  4. data/CONTRIBUTING.md +8 -5
  5. data/Gemfile +9 -9
  6. data/Rakefile +1 -1
  7. data/app/assets/javascripts/comfy/admin/cms/base.js.coffee +1 -0
  8. data/app/assets/stylesheets/comfy/admin/cms/base.sass +14 -4
  9. data/app/controllers/application_controller.rb +2 -2
  10. data/app/controllers/comfy/admin/base_controller.rb +1 -1
  11. data/app/controllers/comfy/admin/cms/base_controller.rb +7 -6
  12. data/app/controllers/comfy/admin/cms/categories_controller.rb +2 -1
  13. data/app/controllers/comfy/admin/cms/files_controller.rb +32 -29
  14. data/app/controllers/comfy/admin/cms/layouts_controller.rb +10 -9
  15. data/app/controllers/comfy/admin/cms/pages_controller.rb +31 -27
  16. data/app/controllers/comfy/admin/cms/revisions/base_controller.rb +5 -4
  17. data/app/controllers/comfy/admin/cms/revisions/layout_controller.rb +2 -1
  18. data/app/controllers/comfy/admin/cms/revisions/page_controller.rb +9 -3
  19. data/app/controllers/comfy/admin/cms/revisions/snippet_controller.rb +2 -1
  20. data/app/controllers/comfy/admin/cms/revisions/translation_controller.rb +9 -3
  21. data/app/controllers/comfy/admin/cms/sites_controller.rb +10 -9
  22. data/app/controllers/comfy/admin/cms/snippets_controller.rb +10 -9
  23. data/app/controllers/comfy/admin/cms/translations_controller.rb +15 -14
  24. data/app/controllers/comfy/cms/assets_controller.rb +4 -3
  25. data/app/controllers/comfy/cms/base_controller.rb +12 -11
  26. data/app/controllers/comfy/cms/content_controller.rb +8 -7
  27. data/app/controllers/concerns/comfy/paginate.rb +2 -1
  28. data/app/helpers/comfy/cms_helper.rb +6 -3
  29. data/app/models/comfy/cms/categorization.rb +2 -1
  30. data/app/models/comfy/cms/category.rb +3 -2
  31. data/app/models/comfy/cms/file.rb +9 -7
  32. data/app/models/comfy/cms/fragment.rb +8 -6
  33. data/app/models/comfy/cms/layout.rb +24 -24
  34. data/app/models/comfy/cms/page.rb +51 -32
  35. data/app/models/comfy/cms/revision.rb +2 -1
  36. data/app/models/comfy/cms/site.rb +27 -26
  37. data/app/models/comfy/cms/snippet.rb +7 -5
  38. data/app/models/comfy/cms/translation.rb +6 -4
  39. data/app/models/concerns/comfy/cms/with_categories.rb +9 -7
  40. data/app/models/concerns/comfy/cms/with_fragments.rb +15 -13
  41. data/app/views/comfy/admin/cms/categories/_categories.html.haml +1 -1
  42. data/app/views/comfy/admin/cms/files/_file.html.haml +3 -3
  43. data/app/views/comfy/admin/cms/files/_modal.html.haml +2 -2
  44. data/app/views/comfy/admin/cms/{pages/_fragment_attachments.html.haml → fragments/_form_fragment_attachments.html.haml} +0 -0
  45. data/app/views/comfy/admin/cms/{pages → fragments}/_form_fragments.html.haml +0 -0
  46. data/app/views/comfy/admin/cms/layouts/_index_branch.html.haml +2 -2
  47. data/app/views/comfy/admin/cms/pages/_form.html.haml +7 -7
  48. data/app/views/comfy/admin/cms/pages/_index_branch.html.haml +16 -15
  49. data/app/views/comfy/admin/cms/pages/form_fragments.js.erb +1 -1
  50. data/app/views/comfy/admin/cms/pages/toggle_branch.js.erb +1 -1
  51. data/app/views/comfy/admin/cms/snippets/index.html.haml +3 -3
  52. data/app/views/comfy/admin/cms/translations/_form.html.haml +1 -1
  53. data/app/views/comfy/admin/cms/translations/form_fragments.js.erb +1 -1
  54. data/app/views/layouts/comfy/admin/cms/_body.html.haml +1 -4
  55. data/app/views/layouts/comfy/admin/cms.html.haml +1 -1
  56. data/bin/bundle +3 -0
  57. data/bin/rails +4 -0
  58. data/bin/rake +4 -0
  59. data/bin/setup +36 -0
  60. data/bin/update +31 -0
  61. data/bin/yarn +11 -0
  62. data/comfortable_mexican_sofa.gemspec +14 -14
  63. data/config/application.rb +4 -3
  64. data/config/boot.rb +3 -3
  65. data/config/cms_routes.rb +1 -1
  66. data/config/environment.rb +1 -1
  67. data/config/environments/development.rb +2 -2
  68. data/config/environments/test.rb +1 -1
  69. data/config/initializers/comfortable_mexican_sofa.rb +2 -5
  70. data/config/locales/cs.yml +2 -1
  71. data/config/locales/da.yml +2 -1
  72. data/config/locales/de.yml +2 -1
  73. data/config/locales/en.yml +2 -1
  74. data/config/locales/es.yml +2 -1
  75. data/config/locales/fr.yml +2 -1
  76. data/config/locales/it.yml +2 -1
  77. data/config/locales/ja.yml +2 -1
  78. data/config/locales/nb.yml +2 -1
  79. data/config/locales/nl.yml +2 -1
  80. data/config/locales/pl.yml +2 -1
  81. data/config/locales/pt-BR.yml +2 -1
  82. data/config/locales/ru.yml +2 -1
  83. data/config/locales/sk.yml +2 -1
  84. data/config/locales/sv.yml +2 -1
  85. data/config/locales/tr.yml +2 -1
  86. data/config/locales/uk.yml +2 -1
  87. data/config/locales/zh-CN.yml +2 -1
  88. data/config/locales/zh-TW.yml +2 -1
  89. data/config.ru +1 -1
  90. data/lib/comfortable_mexican_sofa/access_control/admin_authentication.rb +2 -1
  91. data/lib/comfortable_mexican_sofa/access_control/admin_authorization.rb +2 -0
  92. data/lib/comfortable_mexican_sofa/access_control/public_authentication.rb +3 -1
  93. data/lib/comfortable_mexican_sofa/access_control/public_authorization.rb +2 -0
  94. data/lib/comfortable_mexican_sofa/configuration.rb +27 -29
  95. data/lib/comfortable_mexican_sofa/content/block.rb +2 -1
  96. data/lib/comfortable_mexican_sofa/content/params_parser.rb +22 -21
  97. data/lib/comfortable_mexican_sofa/content/renderer.rb +10 -8
  98. data/lib/comfortable_mexican_sofa/content/tag.rb +1 -0
  99. data/lib/comfortable_mexican_sofa/content/tags/asset.rb +4 -3
  100. data/lib/comfortable_mexican_sofa/content/tags/checkbox.rb +3 -2
  101. data/lib/comfortable_mexican_sofa/content/tags/date.rb +4 -3
  102. data/lib/comfortable_mexican_sofa/content/tags/datetime.rb +4 -3
  103. data/lib/comfortable_mexican_sofa/content/tags/file.rb +15 -13
  104. data/lib/comfortable_mexican_sofa/content/tags/file_link.rb +8 -7
  105. data/lib/comfortable_mexican_sofa/content/tags/files.rb +15 -13
  106. data/lib/comfortable_mexican_sofa/content/tags/fragment.rb +7 -6
  107. data/lib/comfortable_mexican_sofa/content/tags/helper.rb +2 -1
  108. data/lib/comfortable_mexican_sofa/content/tags/markdown.rb +5 -4
  109. data/lib/comfortable_mexican_sofa/content/tags/number.rb +4 -3
  110. data/lib/comfortable_mexican_sofa/content/tags/partial.rb +1 -0
  111. data/lib/comfortable_mexican_sofa/content/tags/snippet.rb +3 -2
  112. data/lib/comfortable_mexican_sofa/content/tags/template.rb +1 -0
  113. data/lib/comfortable_mexican_sofa/content/tags/text.rb +4 -3
  114. data/lib/comfortable_mexican_sofa/content/tags/textarea.rb +4 -3
  115. data/lib/comfortable_mexican_sofa/content/tags/wysiwyg.rb +4 -3
  116. data/lib/comfortable_mexican_sofa/content.rb +21 -21
  117. data/lib/comfortable_mexican_sofa/engine.rb +17 -15
  118. data/lib/comfortable_mexican_sofa/error.rb +12 -6
  119. data/lib/comfortable_mexican_sofa/extensions/acts_as_tree.rb +17 -11
  120. data/lib/comfortable_mexican_sofa/extensions/has_revisions.rb +14 -13
  121. data/lib/comfortable_mexican_sofa/form_builder.rb +2 -2
  122. data/lib/comfortable_mexican_sofa/render_methods.rb +74 -76
  123. data/lib/comfortable_mexican_sofa/routes/cms.rb +4 -4
  124. data/lib/comfortable_mexican_sofa/routes/cms_admin.rb +2 -1
  125. data/lib/comfortable_mexican_sofa/routing.rb +4 -2
  126. data/lib/comfortable_mexican_sofa/seeds/file/exporter.rb +7 -6
  127. data/lib/comfortable_mexican_sofa/seeds/file/importer.rb +9 -9
  128. data/lib/comfortable_mexican_sofa/seeds/layout/exporter.rb +8 -7
  129. data/lib/comfortable_mexican_sofa/seeds/layout/importer.rb +11 -10
  130. data/lib/comfortable_mexican_sofa/seeds/page/exporter.rb +25 -23
  131. data/lib/comfortable_mexican_sofa/seeds/page/importer.rb +47 -43
  132. data/lib/comfortable_mexican_sofa/seeds/snippet/exporter.rb +7 -6
  133. data/lib/comfortable_mexican_sofa/seeds/snippet/importer.rb +7 -6
  134. data/lib/comfortable_mexican_sofa/seeds.rb +16 -9
  135. data/lib/comfortable_mexican_sofa/version.rb +4 -2
  136. data/lib/comfortable_mexican_sofa/view_hooks.rb +10 -9
  137. data/lib/comfortable_mexican_sofa.rb +30 -30
  138. data/lib/generators/comfy/cms/assets_generator.rb +6 -4
  139. data/lib/generators/comfy/cms/cms_generator.rb +14 -14
  140. data/lib/generators/comfy/cms/controllers_generator.rb +5 -3
  141. data/lib/generators/comfy/cms/models_generator.rb +5 -3
  142. data/lib/generators/comfy/cms/views_generator.rb +5 -3
  143. data/lib/generators/comfy/scaffold/scaffold_generator.rb +19 -18
  144. data/lib/tasks/cms_seeds.rake +4 -5
  145. data/test/controllers/comfy/admin/cms/base_controller_test.rb +4 -3
  146. data/test/controllers/comfy/admin/cms/categories_controller_test.rb +19 -18
  147. data/test/controllers/comfy/admin/cms/files_controller_test.rb +19 -19
  148. data/test/controllers/comfy/admin/cms/layouts_controller_test.rb +33 -32
  149. data/test/controllers/comfy/admin/cms/pages_controller_test.rb +99 -98
  150. data/test/controllers/comfy/admin/cms/revisions/layout_controller_test.rb +9 -9
  151. data/test/controllers/comfy/admin/cms/revisions/page_controller_test.rb +6 -6
  152. data/test/controllers/comfy/admin/cms/revisions/snippet_controller_test.rb +9 -8
  153. data/test/controllers/comfy/admin/cms/revisions/translation_controller_test.rb +6 -7
  154. data/test/controllers/comfy/admin/cms/sites_controller_test.rb +31 -30
  155. data/test/controllers/comfy/admin/cms/snippets_controller_test.rb +38 -37
  156. data/test/controllers/comfy/admin/cms/translations_controller_test.rb +21 -20
  157. data/test/controllers/comfy/cms/assets_controller_test.rb +14 -13
  158. data/test/controllers/comfy/cms/content_controller_test.rb +58 -57
  159. data/test/gemfiles/Gemfile.rails.5.2 +5 -4
  160. data/test/generators/cms_assets_generator_test.rb +6 -4
  161. data/test/generators/cms_controllers_generator_test.rb +7 -5
  162. data/test/generators/cms_generator_test.rb +12 -10
  163. data/test/generators/cms_models_generator_test.rb +7 -5
  164. data/test/generators/cms_views_generator_test.rb +6 -4
  165. data/test/generators/scaffold_generator_test.rb +18 -16
  166. data/test/helpers/cms_helper_test.rb +5 -2
  167. data/test/integration/access_control_test.rb +29 -20
  168. data/test/integration/i18n_test.rb +8 -7
  169. data/test/integration/js_variables_test.rb +2 -1
  170. data/test/integration/render_cms_test.rb +93 -88
  171. data/test/integration/routing_test.rb +4 -3
  172. data/test/integration/seeds_test.rb +21 -22
  173. data/test/integration/sites_test.rb +26 -25
  174. data/test/integration/view_hooks_test.rb +15 -14
  175. data/test/lib/configuration_test.rb +13 -15
  176. data/test/lib/content/block_test.rb +1 -1
  177. data/test/lib/content/params_parser_test.rb +11 -10
  178. data/test/lib/content/renderer_test.rb +16 -11
  179. data/test/lib/content/tag_test.rb +7 -3
  180. data/test/lib/content/tags/asset_test.rb +4 -3
  181. data/test/lib/content/tags/checkbox_test.rb +2 -1
  182. data/test/lib/content/tags/date_test.rb +2 -1
  183. data/test/lib/content/tags/datetime_test.rb +2 -1
  184. data/test/lib/content/tags/file_link_test.rb +3 -2
  185. data/test/lib/content/tags/file_test.rb +3 -2
  186. data/test/lib/content/tags/files_test.rb +4 -3
  187. data/test/lib/content/tags/fragment_test.rb +2 -1
  188. data/test/lib/content/tags/helper_test.rb +4 -3
  189. data/test/lib/content/tags/markdown_test.rb +2 -1
  190. data/test/lib/content/tags/number_test.rb +2 -1
  191. data/test/lib/content/tags/partial_test.rb +4 -3
  192. data/test/lib/content/tags/snippet_test.rb +2 -1
  193. data/test/lib/content/tags/template_test.rb +2 -1
  194. data/test/lib/content/tags/text_test.rb +2 -1
  195. data/test/lib/content/tags/textarea_test.rb +2 -1
  196. data/test/lib/content/tags/wysiwyg_test.rb +2 -1
  197. data/test/lib/revisions_test.rb +44 -42
  198. data/test/lib/seeds/files_test.rb +30 -29
  199. data/test/lib/seeds/layouts_test.rb +13 -12
  200. data/test/lib/seeds/pages_test.rb +32 -29
  201. data/test/lib/seeds/snippets_test.rb +21 -20
  202. data/test/lib/seeds_test.rb +9 -8
  203. data/test/models/categorization_test.rb +10 -9
  204. data/test/models/category_test.rb +1 -1
  205. data/test/models/file_test.rb +1 -1
  206. data/test/models/fragment_test.rb +11 -10
  207. data/test/models/layout_test.rb +71 -70
  208. data/test/models/page_test.rb +170 -159
  209. data/test/models/site_test.rb +17 -16
  210. data/test/models/snippet_test.rb +1 -0
  211. data/test/models/translation_test.rb +2 -1
  212. data/test/tasks/cms_seeds_test.rb +3 -2
  213. data/test/test_helper.rb +42 -40
  214. metadata +55 -51
  215. data/.rubocop_todo.yml +0 -974
  216. data/script/rails +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b44e849fc5e9ae2bf75d22a0976d8852f30e1606
4
- data.tar.gz: 7a26fcd671fb42318a968aa3f6ede11d67d233ba
3
+ metadata.gz: fb5f504ed7a73ffd87abc1a6a22559c08a03b64b
4
+ data.tar.gz: 14f3121059d919b4c612cfef5a28ec76e540f1b3
5
5
  SHA512:
6
- metadata.gz: 2c102b76ac471fda8769a9dfbfb29289c1133c3c963ebddc3cbe4d5b69714fa7a294c30979e3a2634c5ebdf26ec9efe983f860b2bb860608c97d84abbabef39d
7
- data.tar.gz: 7d704fc6e99d1fead6caaa51ff00f033a4a20941aa29f079b227a143bf97251830382dcf708296cf7ee8f89e5de29bbc4364298d536e9d37fc5d2f8bc19c212f
6
+ metadata.gz: c688307b159cc80dea239cc9ea2892ecdd0cc5452313c109ccb30dc110c79db26ed534d208ee61396840e85379191c83ef5dda135cfaff6af04d1f6ad83a1839
7
+ data.tar.gz: ba27c94a808feb48b9763eecf0e7ae2353d22c97218c237285db00b00ec48c70147aca696a3e78278a51b5a2612da81cd8930332a5a209558000f7b58a07ac89
data/.rubocop.yml CHANGED
@@ -1,5 +1,96 @@
1
- inherit_from:
2
- - .rubocop_todo.yml
3
-
4
1
  AllCops:
5
- TargetRubyVersion: 2.3
2
+ TargetRubyVersion: 2.2
3
+ Exclude:
4
+ - bin/*
5
+ - db/schema.rb
6
+ - db/migrate/**/*
7
+ - test/fixtures/**/*
8
+ - tmp/**/*
9
+
10
+ # -- Performance ---------------------------------------------------------------
11
+ Performance/Casecmp:
12
+ Enabled: false
13
+
14
+ # -- Metrics -------------------------------------------------------------------
15
+ Metrics/PerceivedComplexity:
16
+ Enabled: false
17
+
18
+ Metrics/MethodLength:
19
+ Enabled: false
20
+
21
+ Metrics/MethodLength:
22
+ Enabled: false
23
+
24
+ Metrics/ParameterLists:
25
+ Enabled: false
26
+
27
+ Metrics/LineLength:
28
+ Max: 120
29
+
30
+ Metrics/CyclomaticComplexity:
31
+ Enabled: false
32
+
33
+ Metrics/ClassLength:
34
+ Enabled: false
35
+
36
+ Metrics/BlockLength:
37
+ Enabled: false
38
+
39
+ Metrics/AbcSize:
40
+ Enabled: false
41
+
42
+ # -- Layout --------------------------------------------------------------------
43
+ Layout/MultilineOperationIndentation:
44
+ Enabled: false
45
+
46
+ Layout/MultilineMethodCallIndentation:
47
+ EnforcedStyle: indented
48
+
49
+ Layout/MultilineHashBraceLayout:
50
+ Enabled: false
51
+
52
+ Layout/IndentArray:
53
+ EnforcedStyle: consistent
54
+
55
+ Layout/EmptyLinesAroundModuleBody:
56
+ EnforcedStyle: empty_lines_except_namespace
57
+
58
+ Layout/EmptyLinesAroundExceptionHandlingKeywords:
59
+ Enabled: false
60
+
61
+ Layout/EmptyLinesAroundClassBody:
62
+ EnforcedStyle: empty_lines_except_namespace
63
+
64
+ Layout/AlignParameters:
65
+ Enabled: false
66
+
67
+ Layout/AccessModifierIndentation:
68
+ EnforcedStyle: outdent
69
+
70
+ # -- Style ---------------------------------------------------------------------
71
+ Style/StringLiterals:
72
+ EnforcedStyle: double_quotes
73
+
74
+ Style/RegexpLiteral:
75
+ EnforcedStyle: percent_r
76
+
77
+ Style/Lambda:
78
+ EnforcedStyle: literal
79
+
80
+ Style/IfUnlessModifier:
81
+ Enabled: false
82
+
83
+ Style/GuardClause:
84
+ Enabled: false
85
+
86
+ Style/Documentation:
87
+ Enabled: false
88
+
89
+ Style/DateTime:
90
+ Enabled: false
91
+
92
+ Style/ClassAndModuleChildren:
93
+ Enabled: false
94
+
95
+ Style/AsciiComments:
96
+ Enabled: false
data/.travis.yml CHANGED
@@ -4,7 +4,8 @@ before_install:
4
4
  before_script:
5
5
  - rake db:migrate
6
6
  script:
7
- - rake test
7
+ - bundle exec rake test
8
+ - bundle exec rubocop
8
9
  rvm:
9
10
  - 2.2.7
10
11
  - 2.3.5
data/CONTRIBUTING.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # Contributing
2
+
2
3
  Contribute your code to ComfortableMexicanSofa in 5 easy steps:
3
4
 
4
5
  ### 1. Fork it
@@ -8,8 +9,9 @@ Fork the project. Optionally, create a branch you want to work on.
8
9
  ### 2. Get it running locally
9
10
 
10
11
  - Install gem dependencies with `bundle install`
11
- - There's nothing to configure, by default database is SQLite so it will be created for you
12
- - Make sure that existing tests are passing by running `rake test:all`
12
+ - There's nothing to configure, by default database is SQLite so it will be created for you.
13
+ Just run `rake db:migrate`
14
+ - Make sure that existing tests are passing by running `rake test`
13
15
  - You should be able to start the app via `rails s` and navigate to http://localhost:3000/admin
14
16
 
15
17
  ### 3. Hack away
@@ -18,12 +20,13 @@ Fork the project. Optionally, create a branch you want to work on.
18
20
  - When adding new code just make sure it follows the same slyle as the existing code.
19
21
  - Avoid adding 3rd party dependencies if you can.
20
22
  - Tests please, but nothing complicated. UnitTest / Fixtures all the way. Make sure all tests pass.
23
+ - Run `bundle exec rubocop` and fix any issues raised.
21
24
 
22
25
  ### 4. Make a pull request
23
26
 
24
- If you never done it before read this: https://help.github.com/articles/using-pull-requests
27
+ - If you never done it before read this: https://help.github.com/articles/using-pull-requests
28
+ - When PR is submitted check if TravisCI ran all tests successfully and Rubocop didn't raise any issues
25
29
 
26
30
  ### 5. Done!
27
31
 
28
- If everything is good your changes will be merged into master branch. Eventually a new version of gem will be cut.
29
-
32
+ If everything is good your changes will be merged into master branch. Eventually a new version of gem will be published.
data/Gemfile CHANGED
@@ -1,21 +1,21 @@
1
- source 'http://rubygems.org'
1
+ source "http://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
5
  # apps can also use will_paginate so there's no dependency in gemspec
6
- gem 'kaminari'
6
+ gem "kaminari"
7
7
 
8
8
  group :development do
9
+ gem "awesome_print"
10
+ gem "better_errors"
11
+ gem "binding_of_caller"
9
12
  gem "listen"
10
- gem 'awesome_print'
11
- gem 'better_errors'
12
- gem 'binding_of_caller'
13
13
  gem "rubocop", "~> 0.51.0", require: false
14
14
  end
15
15
 
16
16
  group :test do
17
- gem 'rails-controller-testing'
18
- gem 'sqlite3'
19
- gem 'mocha', require: false
20
- gem 'coveralls', require: false
17
+ gem "coveralls", require: false
18
+ gem "mocha", require: false
19
+ gem "rails-controller-testing"
20
+ gem "sqlite3"
21
21
  end
data/Rakefile CHANGED
@@ -1,3 +1,3 @@
1
- require_relative 'config/application'
1
+ require_relative "config/application"
2
2
 
3
3
  Rails.application.load_tasks
@@ -99,6 +99,7 @@ window.CMS.codemirror = ->
99
99
  $('textarea[data-cms-cm-mode]').each (i, element) ->
100
100
  cm = CodeMirror.fromTextArea element,
101
101
  mode: $(element).data('cms-cm-mode')
102
+ tabSize: 2
102
103
  lineWrapping: true
103
104
  autoCloseTags: true
104
105
  lineNumbers: true
@@ -104,7 +104,7 @@ body#comfy
104
104
 
105
105
  .box
106
106
  padding: 1rem
107
- margin: 0.5rem 0
107
+ margin-bottom: 1rem
108
108
  background-color: $white
109
109
  border: 1px solid $gray-200
110
110
  .box.translations
@@ -154,6 +154,8 @@ body#comfy
154
154
  padding: 0
155
155
  li
156
156
  list-style: none
157
+ ul
158
+ padding-left: 0
157
159
  .row
158
160
  background-color: $gray-100
159
161
  margin-bottom: 5px
@@ -161,9 +163,9 @@ body#comfy
161
163
  .item
162
164
  display: flex
163
165
  .item-controls
164
- width: 30px
165
166
  padding: 2px 0
166
167
  .dragger, .toggle
168
+ margin-right: 15px
167
169
  display: block
168
170
  color: $gray-500
169
171
  &:hover
@@ -194,8 +196,6 @@ body#comfy
194
196
  background-color: $white
195
197
  .row:hover
196
198
  background-color: $white
197
- ul.list
198
- padding-left: 2rem
199
199
 
200
200
  // -- Pages ------------------------------------------------------------------
201
201
  &.c-comfy-admin-cms-pages
@@ -227,6 +227,16 @@ body#comfy
227
227
  img
228
228
  width: 100%
229
229
 
230
+ .cms-uploader-drag-drop-target-active
231
+ position: fixed !important
232
+ z-index: 9999
233
+ top: 0
234
+ left: 0
235
+ width: 100%
236
+ height: 100%
237
+ border: dotted #ccc 1px
238
+ background-color: rgba(255, 255, 255, 0.7)
239
+
230
240
  // -- Revisions --------------------------------------------------------------
231
241
  &[class*="c-comfy-admin-cms-revisions-"], &[class*="c-comfy-admin-blog-revisions-"]
232
242
  .label
@@ -1,5 +1,5 @@
1
1
  class ApplicationController < ActionController::Base
2
-
2
+
3
3
  protect_from_forgery
4
-
4
+
5
5
  end
@@ -15,6 +15,6 @@ class Comfy::Admin::BaseController < ComfortableMexicanSofa.config.base_controll
15
15
 
16
16
  before_action :authenticate
17
17
 
18
- layout 'comfy/admin/cms'
18
+ layout "comfy/admin/cms"
19
19
 
20
20
  end
@@ -6,7 +6,7 @@ class Comfy::Admin::Cms::BaseController < Comfy::Admin::BaseController
6
6
  except: :jump
7
7
 
8
8
  if ComfortableMexicanSofa.config.admin_cache_sweeper.present?
9
- cache_sweeper *ComfortableMexicanSofa.config.admin_cache_sweeper
9
+ cache_sweeper(*ComfortableMexicanSofa.config.admin_cache_sweeper)
10
10
  end
11
11
 
12
12
  def jump
@@ -20,11 +20,11 @@ protected
20
20
 
21
21
  def load_admin_site
22
22
  id_param = params[:site_id] || session[:site_id]
23
- if @site = ::Comfy::Cms::Site.find_by(id: id_param) || ::Comfy::Cms::Site.first
23
+ if (@site = ::Comfy::Cms::Site.find_by(id: id_param) || ::Comfy::Cms::Site.first)
24
24
  session[:site_id] = @site.id
25
25
  else
26
26
  I18n.locale = ComfortableMexicanSofa.config.admin_locale || I18n.default_locale
27
- flash[:danger] = I18n.t('comfy.admin.cms.base.site_not_found')
27
+ flash[:danger] = I18n.t("comfy.admin.cms.base.site_not_found")
28
28
  return redirect_to(new_comfy_admin_cms_site_path)
29
29
  end
30
30
  end
@@ -37,10 +37,11 @@ protected
37
37
  def load_seeds
38
38
  return unless ComfortableMexicanSofa.config.enable_seeds
39
39
 
40
- controllers = %w(layouts pages snippets files).collect{|c| 'comfy/admin/cms/' + c}
41
- if controllers.member?(params[:controller]) && params[:action] == 'index'
40
+ controllers = %w[layouts pages snippets files].collect { |c| "comfy/admin/cms/" + c }
41
+ if controllers.member?(params[:controller]) && params[:action] == "index"
42
42
  ComfortableMexicanSofa::Seeds::Importer.new(@site.identifier).import!
43
- flash.now[:warning] = I18n.t('comfy.admin.cms.base.seeds_enabled')
43
+ flash.now[:warning] = I18n.t("comfy.admin.cms.base.seeds_enabled")
44
44
  end
45
45
  end
46
+
46
47
  end
@@ -1,6 +1,6 @@
1
1
  class Comfy::Admin::Cms::CategoriesController < Comfy::Admin::Cms::BaseController
2
2
 
3
- before_action :load_category, only: [:edit, :update, :destroy]
3
+ before_action :load_category, only: %i[edit update destroy]
4
4
  before_action :authorize
5
5
 
6
6
  def edit
@@ -34,4 +34,5 @@ protected
34
34
  def category_params
35
35
  params.fetch(:category, {}).permit!
36
36
  end
37
+
37
38
  end
@@ -2,8 +2,8 @@ class Comfy::Admin::Cms::FilesController < Comfy::Admin::Cms::BaseController
2
2
 
3
3
  include ActionView::Helpers::NumberHelper
4
4
 
5
- before_action :build_file, only: [:new, :create]
6
- before_action :load_file, only: [:edit, :update, :destroy]
5
+ before_action :build_file, only: %i[new create]
6
+ before_action :load_file, only: %i[edit update destroy]
7
7
  before_action :authorize
8
8
 
9
9
  def index
@@ -12,23 +12,25 @@ class Comfy::Admin::Cms::FilesController < Comfy::Admin::Cms::BaseController
12
12
  case params[:source]
13
13
 
14
14
  # Integration with Redactor 1.0 Wysiwyg
15
- when 'redactor'
15
+ when "redactor"
16
16
  file_scope = files_scope.limit(100).order(:position)
17
- file_hashes = case params[:type]
18
- when 'image'
19
- file_scope.with_images.collect do |file|
20
- { thumb: url_for(file.attachment.variant(Comfy::Cms::File::VARIANT_SIZE[:redactor])),
21
- image: url_for(file.attachment),
22
- title: file.label }
23
- end
24
- else
25
- file_scope.collect do |file|
26
- { title: file.label,
27
- name: file.attachment.filename,
28
- link: url_for(file.attachment),
29
- size: number_to_human_size(file.attachment.byte_size) }
17
+ file_hashes =
18
+ case params[:type]
19
+ when "image"
20
+ file_scope.with_images.collect do |file|
21
+ { thumb: url_for(file.attachment.variant(Comfy::Cms::File::VARIANT_SIZE[:redactor])),
22
+ image: url_for(file.attachment),
23
+ title: file.label }
24
+ end
25
+ else
26
+ file_scope.collect do |file|
27
+ { title: file.label,
28
+ name: file.attachment.filename,
29
+ link: url_for(file.attachment),
30
+ size: number_to_human_size(file.attachment.byte_size) }
31
+ end
30
32
  end
31
- end
33
+
32
34
  render json: file_hashes
33
35
 
34
36
  else
@@ -46,10 +48,10 @@ class Comfy::Admin::Cms::FilesController < Comfy::Admin::Cms::BaseController
46
48
 
47
49
  def create
48
50
  if params[:category]
49
- ids = @site.categories.of_type('Comfy::Cms::File')
51
+ ids = @site.categories.of_type("Comfy::Cms::File")
50
52
  .where(label: params[:category])
51
- .each_with_object({}){|c, h| h[c.id] = 1}
52
- @file.category_ids = ids
53
+ .each_with_object({}) { |c, h| h[c.id] = 1 }
54
+ @file.category_ids = ids
53
55
  end
54
56
 
55
57
  # Automatically tagging upload if it's done through redactor
@@ -70,18 +72,18 @@ class Comfy::Admin::Cms::FilesController < Comfy::Admin::Cms::BaseController
70
72
  filename: @file.attachment.filename
71
73
  }
72
74
  else
73
- flash[:success] = I18n.t('comfy.admin.cms.files.created')
75
+ flash[:success] = I18n.t("comfy.admin.cms.files.created")
74
76
  redirect_to action: :edit, id: @file
75
77
  end
76
78
 
77
79
  rescue ActiveRecord::RecordInvalid
78
80
  case params[:source]
79
- when 'plupload'
81
+ when "plupload"
80
82
  render body: @file.errors.full_messages.to_sentence, status: :unprocessable_entity
81
- when 'redactor'
83
+ when "redactor"
82
84
  render body: nil, status: :unprocessable_entity
83
85
  else
84
- flash.now[:danger] = I18n.t('comfy.admin.cms.files.creation_failure')
86
+ flash.now[:danger] = I18n.t("comfy.admin.cms.files.creation_failure")
85
87
  render action: :new
86
88
  end
87
89
  end
@@ -92,10 +94,10 @@ class Comfy::Admin::Cms::FilesController < Comfy::Admin::Cms::BaseController
92
94
 
93
95
  def update
94
96
  if @file.update(file_params)
95
- flash[:success] = I18n.t('comfy.admin.cms.files.updated')
97
+ flash[:success] = I18n.t("comfy.admin.cms.files.updated")
96
98
  redirect_to action: :edit, id: @file
97
99
  else
98
- flash.now[:danger] = I18n.t('comfy.admin.cms.files.update_failure')
100
+ flash.now[:danger] = I18n.t("comfy.admin.cms.files.update_failure")
99
101
  render action: :edit
100
102
  end
101
103
  end
@@ -105,7 +107,7 @@ class Comfy::Admin::Cms::FilesController < Comfy::Admin::Cms::BaseController
105
107
  respond_to do |format|
106
108
  format.js
107
109
  format.html do
108
- flash[:success] = I18n.t('comfy.admin.cms.files.deleted')
110
+ flash[:success] = I18n.t("comfy.admin.cms.files.deleted")
109
111
  redirect_to action: :index
110
112
  end
111
113
  end
@@ -129,16 +131,17 @@ protected
129
131
  def load_file
130
132
  @file = @site.files.find(params[:id])
131
133
  rescue ActiveRecord::RecordNotFound
132
- flash[:danger] = I18n.t('comfy.admin.cms.files.not_found')
134
+ flash[:danger] = I18n.t("comfy.admin.cms.files.not_found")
133
135
  redirect_to action: :index
134
136
  end
135
137
 
136
138
  def file_params
137
139
  file = params[:file]
138
140
  unless file.is_a?(Hash) || file.respond_to?(:to_unsafe_hash)
139
- params[:file] = { }
141
+ params[:file] = {}
140
142
  params[:file][:file] = file
141
143
  end
142
144
  params.fetch(:file, {}).permit!
143
145
  end
146
+
144
147
  end
@@ -1,11 +1,11 @@
1
1
  class Comfy::Admin::Cms::LayoutsController < Comfy::Admin::Cms::BaseController
2
2
 
3
- before_action :build_layout, only: [:new, :create]
4
- before_action :load_layout, only: [:edit, :update, :destroy]
3
+ before_action :build_layout, only: %i[new create]
4
+ before_action :load_layout, only: %i[edit update destroy]
5
5
  before_action :authorize
6
6
 
7
7
  def index
8
- return redirect_to action: :new if @site.layouts.count == 0
8
+ return redirect_to action: :new if @site.layouts.count.zero?
9
9
  @layouts = @site.layouts.roots.order(:position)
10
10
  end
11
11
 
@@ -19,25 +19,25 @@ class Comfy::Admin::Cms::LayoutsController < Comfy::Admin::Cms::BaseController
19
19
 
20
20
  def create
21
21
  @layout.save!
22
- flash[:success] = I18n.t('comfy.admin.cms.layouts.created')
22
+ flash[:success] = I18n.t("comfy.admin.cms.layouts.created")
23
23
  redirect_to action: :edit, id: @layout
24
24
  rescue ActiveRecord::RecordInvalid
25
- flash.now[:danger] = I18n.t('comfy.admin.cms.layouts.creation_failure')
25
+ flash.now[:danger] = I18n.t("comfy.admin.cms.layouts.creation_failure")
26
26
  render action: :new
27
27
  end
28
28
 
29
29
  def update
30
30
  @layout.update_attributes!(layout_params)
31
- flash[:success] = I18n.t('comfy.admin.cms.layouts.updated')
31
+ flash[:success] = I18n.t("comfy.admin.cms.layouts.updated")
32
32
  redirect_to action: :edit, id: @layout
33
33
  rescue ActiveRecord::RecordInvalid
34
- flash.now[:danger] = I18n.t('comfy.admin.cms.layouts.update_failure')
34
+ flash.now[:danger] = I18n.t("comfy.admin.cms.layouts.update_failure")
35
35
  render action: :edit
36
36
  end
37
37
 
38
38
  def destroy
39
39
  @layout.destroy
40
- flash[:success] = I18n.t('comfy.admin.cms.layouts.deleted')
40
+ flash[:success] = I18n.t("comfy.admin.cms.layouts.deleted")
41
41
  redirect_to action: :index
42
42
  end
43
43
 
@@ -60,11 +60,12 @@ protected
60
60
  def load_layout
61
61
  @layout = @site.layouts.find(params[:id])
62
62
  rescue ActiveRecord::RecordNotFound
63
- flash[:danger] = I18n.t('comfy.admin.cms.layouts.not_found')
63
+ flash[:danger] = I18n.t("comfy.admin.cms.layouts.not_found")
64
64
  redirect_to action: :index
65
65
  end
66
66
 
67
67
  def layout_params
68
68
  params.fetch(:layout, {}).permit!
69
69
  end
70
+
70
71
  end
@@ -1,23 +1,26 @@
1
1
  class Comfy::Admin::Cms::PagesController < Comfy::Admin::Cms::BaseController
2
2
 
3
- before_action :check_for_layouts, only: [:new, :edit]
4
- before_action :build_page, only: [:new, :create]
5
- before_action :load_page, only: [:edit, :update, :destroy]
3
+ before_action :check_for_layouts, only: %i[new edit]
4
+ before_action :build_page, only: %i[new create]
5
+ before_action :load_page, only: %i[edit update destroy]
6
+
6
7
  before_action :authorize
7
- before_action :preview_page, only: [:create, :update]
8
+
9
+ before_action :preview_page, only: %i[create update]
8
10
 
9
11
  def index
10
12
  return redirect_to action: :new if site_has_no_pages?
11
13
 
12
- return index_for_redactor if params[:source] == 'redactor'
14
+ return index_for_redactor if params[:source] == "redactor"
13
15
 
14
16
  @pages_by_parent = pages_grouped_by_parent
15
17
 
16
- @pages = if params[:categories].present?
17
- @site.pages.includes(:categories).for_category(params[:categories]).order(:label)
18
- else
19
- [@site.pages.root].compact
20
- end
18
+ @pages =
19
+ if params[:categories].present?
20
+ @site.pages.includes(:categories).for_category(params[:categories]).order(:label)
21
+ else
22
+ [@site.pages.root].compact
23
+ end
21
24
  end
22
25
 
23
26
  def new
@@ -30,25 +33,25 @@ class Comfy::Admin::Cms::PagesController < Comfy::Admin::Cms::BaseController
30
33
 
31
34
  def create
32
35
  @page.save!
33
- flash[:success] = I18n.t('comfy.admin.cms.pages.created')
36
+ flash[:success] = I18n.t("comfy.admin.cms.pages.created")
34
37
  redirect_to action: :edit, id: @page
35
38
  rescue ActiveRecord::RecordInvalid
36
- flash.now[:danger] = I18n.t('comfy.admin.cms.pages.creation_failure')
39
+ flash.now[:danger] = I18n.t("comfy.admin.cms.pages.creation_failure")
37
40
  render action: :new
38
41
  end
39
42
 
40
43
  def update
41
44
  @page.save!
42
- flash[:success] = I18n.t('comfy.admin.cms.pages.updated')
45
+ flash[:success] = I18n.t("comfy.admin.cms.pages.updated")
43
46
  redirect_to action: :edit, id: @page
44
47
  rescue ActiveRecord::RecordInvalid
45
- flash.now[:danger] = I18n.t('comfy.admin.cms.pages.update_failure')
48
+ flash.now[:danger] = I18n.t("comfy.admin.cms.pages.update_failure")
46
49
  render action: :edit
47
50
  end
48
51
 
49
52
  def destroy
50
53
  @page.destroy
51
- flash[:success] = I18n.t('comfy.admin.cms.pages.deleted')
54
+ flash[:success] = I18n.t("comfy.admin.cms.pages.deleted")
52
55
  redirect_to action: :index
53
56
  end
54
57
 
@@ -64,7 +67,7 @@ class Comfy::Admin::Cms::PagesController < Comfy::Admin::Cms::BaseController
64
67
  id = @page.id.to_s
65
68
  s.member?(id) ? s.delete(id) : s << id
66
69
  rescue ActiveRecord::RecordNotFound
67
- # do nothing
70
+ render nothing: true
68
71
  end
69
72
 
70
73
  def reorder
@@ -80,23 +83,23 @@ protected
80
83
  tree_walker = ->(page, list, offset) do
81
84
  return unless page.present?
82
85
  label = "#{'. . ' * offset}#{page.label}"
83
- list << {name: label, url: page.url(relative: true)}
86
+ list << { name: label, url: page.url(relative: true) }
84
87
  page.children.each do |child_page|
85
- tree_walker.(child_page, list, offset + 1)
88
+ tree_walker.call(child_page, list, offset + 1)
86
89
  end
87
90
  list
88
91
  end
89
92
 
90
93
  page_select_options = [{
91
- name: I18n.t('comfy.admin.cms.pages.form.choose_link'),
94
+ name: I18n.t("comfy.admin.cms.pages.form.choose_link"),
92
95
  url: false
93
- }] + tree_walker.(@site.pages.root, [ ], 0)
96
+ }] + tree_walker.call(@site.pages.root, [], 0)
94
97
 
95
98
  render json: page_select_options
96
99
  end
97
100
 
98
101
  def site_has_no_pages?
99
- @site.pages.count == 0
102
+ @site.pages.count.zero?
100
103
  end
101
104
 
102
105
  def pages_grouped_by_parent
@@ -104,8 +107,8 @@ protected
104
107
  end
105
108
 
106
109
  def check_for_layouts
107
- if @site.layouts.count == 0
108
- flash[:danger] = I18n.t('comfy.admin.cms.pages.layout_not_found')
110
+ if @site.layouts.count.zero?
111
+ flash[:danger] = I18n.t("comfy.admin.cms.pages.layout_not_found")
109
112
  redirect_to new_comfy_admin_cms_site_layout_path(@site)
110
113
  end
111
114
  end
@@ -120,13 +123,13 @@ protected
120
123
  @page = @site.pages.find(params[:id])
121
124
  @page.attributes = page_params
122
125
  rescue ActiveRecord::RecordNotFound
123
- flash[:danger] = I18n.t('comfy.admin.cms.pages.not_found')
126
+ flash[:danger] = I18n.t("comfy.admin.cms.pages.not_found")
124
127
  redirect_to action: :index
125
128
  end
126
129
 
127
130
  def preview_page
128
131
  if params[:preview]
129
- layout = @page.layout.app_layout.blank?? false : @page.layout.app_layout
132
+ layout = @page.layout.app_layout.blank? ? false : @page.layout.app_layout
130
133
  @cms_site = @page.site
131
134
  @cms_layout = @page.layout
132
135
  @cms_page = @page
@@ -136,13 +139,14 @@ protected
136
139
  I18n.locale = @cms_site.locale
137
140
 
138
141
  # Chrome chokes on content with iframes. Issue #434
139
- response.headers['X-XSS-Protection'] = '0'
142
+ response.headers["X-XSS-Protection"] = "0"
140
143
 
141
- render inline: @page.render, layout: layout, content_type: 'text/html'
144
+ render inline: @page.render, layout: layout, content_type: "text/html"
142
145
  end
143
146
  end
144
147
 
145
148
  def page_params
146
149
  params.fetch(:page, {}).permit!
147
150
  end
151
+
148
152
  end