occams 1.0.0 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/.github/issue_template.md +2 -4
  3. data/.rubocop.yml +23 -40
  4. data/CHANGELOG.md +18 -3
  5. data/Gemfile +17 -17
  6. data/LICENSE +1 -1
  7. data/README.md +15 -19
  8. data/Rakefile +1 -1
  9. data/TODOS.md +6 -0
  10. data/app/controllers/application_controller.rb +0 -2
  11. data/app/controllers/concerns/occams/paginate.rb +0 -2
  12. data/app/controllers/concerns/occams/reorder_action.rb +0 -2
  13. data/app/controllers/occams/admin/base_controller.rb +1 -3
  14. data/app/controllers/occams/admin/cms/base_controller.rb +10 -11
  15. data/app/controllers/occams/admin/cms/categories_controller.rb +0 -2
  16. data/app/controllers/occams/admin/cms/files_controller.rb +21 -24
  17. data/app/controllers/occams/admin/cms/layouts_controller.rb +8 -9
  18. data/app/controllers/occams/admin/cms/pages_controller.rb +28 -29
  19. data/app/controllers/occams/admin/cms/revisions/base_controller.rb +5 -7
  20. data/app/controllers/occams/admin/cms/revisions/layout_controller.rb +1 -3
  21. data/app/controllers/occams/admin/cms/revisions/page_controller.rb +3 -5
  22. data/app/controllers/occams/admin/cms/revisions/snippet_controller.rb +1 -3
  23. data/app/controllers/occams/admin/cms/revisions/translation_controller.rb +3 -5
  24. data/app/controllers/occams/admin/cms/sites_controller.rb +7 -8
  25. data/app/controllers/occams/admin/cms/snippets_controller.rb +7 -8
  26. data/app/controllers/occams/admin/cms/translations_controller.rb +26 -28
  27. data/app/controllers/occams/cms/assets_controller.rb +5 -7
  28. data/app/controllers/occams/cms/base_controller.rb +7 -14
  29. data/app/controllers/occams/cms/content_controller.rb +19 -16
  30. data/app/helpers/occams/admin/cms_helper.rb +3 -5
  31. data/app/helpers/occams/cms_helper.rb +13 -10
  32. data/app/models/concerns/occams/cms/with_categories.rb +6 -8
  33. data/app/models/concerns/occams/cms/with_fragments.rb +6 -8
  34. data/app/models/occams/cms/categorization.rb +3 -5
  35. data/app/models/occams/cms/category.rb +5 -7
  36. data/app/models/occams/cms/file.rb +10 -10
  37. data/app/models/occams/cms/fragment.rb +5 -6
  38. data/app/models/occams/cms/layout.rb +11 -12
  39. data/app/models/occams/cms/page.rb +20 -17
  40. data/app/models/occams/cms/revision.rb +1 -3
  41. data/app/models/occams/cms/site.rb +16 -17
  42. data/app/models/occams/cms/snippet.rb +5 -7
  43. data/app/models/occams/cms/translation.rb +5 -6
  44. data/app/views/layouts/occams/admin/cms/_left.html.haml +5 -0
  45. data/app/views/occams/admin/cms/files/_file.html.haml +1 -1
  46. data/config/application.rb +4 -6
  47. data/config/boot.rb +4 -3
  48. data/config/environment.rb +1 -1
  49. data/config/environments/development.rb +2 -2
  50. data/config/environments/test.rb +1 -1
  51. data/config/initializers/occams.rb +2 -2
  52. data/config.ru +1 -1
  53. data/lib/generators/occams/cms/assets_generator.rb +3 -5
  54. data/lib/generators/occams/cms/cms_generator.rb +13 -15
  55. data/lib/generators/occams/cms/controllers_generator.rb +2 -4
  56. data/lib/generators/occams/cms/models_generator.rb +2 -4
  57. data/lib/generators/occams/cms/views_generator.rb +2 -4
  58. data/lib/generators/occams/scaffold/scaffold_generator.rb +19 -20
  59. data/lib/occams/access_control/admin_authentication.rb +0 -2
  60. data/lib/occams/access_control/admin_authorization.rb +0 -2
  61. data/lib/occams/access_control/public_authentication.rb +0 -2
  62. data/lib/occams/access_control/public_authorization.rb +0 -2
  63. data/lib/occams/configuration.rb +33 -35
  64. data/lib/occams/content/block.rb +0 -2
  65. data/lib/occams/content/params_parser.rb +12 -14
  66. data/lib/occams/content/renderer.rb +15 -18
  67. data/lib/occams/content/tag.rb +1 -3
  68. data/lib/occams/content/tags/asset.rb +13 -15
  69. data/lib/occams/content/tags/checkbox.rb +4 -6
  70. data/lib/occams/content/tags/date.rb +2 -4
  71. data/lib/occams/content/tags/datetime.rb +4 -6
  72. data/lib/occams/content/tags/file.rb +13 -15
  73. data/lib/occams/content/tags/file_link.rb +9 -10
  74. data/lib/occams/content/tags/files.rb +10 -12
  75. data/lib/occams/content/tags/fragment.rb +4 -6
  76. data/lib/occams/content/tags/helper.rb +6 -8
  77. data/lib/occams/content/tags/markdown.rb +2 -4
  78. data/lib/occams/content/tags/mixins/file_content.rb +4 -5
  79. data/lib/occams/content/tags/number.rb +1 -3
  80. data/lib/occams/content/tags/page_file_link.rb +9 -10
  81. data/lib/occams/content/tags/partial.rb +5 -7
  82. data/lib/occams/content/tags/snippet.rb +3 -5
  83. data/lib/occams/content/tags/template.rb +5 -7
  84. data/lib/occams/content/tags/text.rb +1 -3
  85. data/lib/occams/content/tags/textarea.rb +1 -3
  86. data/lib/occams/content/tags/wysiwyg.rb +1 -3
  87. data/lib/occams/content.rb +22 -22
  88. data/lib/occams/engine.rb +11 -13
  89. data/lib/occams/error.rb +0 -8
  90. data/lib/occams/extensions/acts_as_tree.rb +14 -20
  91. data/lib/occams/extensions/has_revisions.rb +7 -11
  92. data/lib/occams/form_builder.rb +5 -9
  93. data/lib/occams/render_methods.rb +11 -17
  94. data/lib/occams/routes/cms.rb +3 -5
  95. data/lib/occams/routes/cms_admin.rb +7 -9
  96. data/lib/occams/routing.rb +2 -4
  97. data/lib/occams/seeds/file/exporter.rb +7 -13
  98. data/lib/occams/seeds/file/importer.rb +13 -17
  99. data/lib/occams/seeds/layout/exporter.rb +9 -11
  100. data/lib/occams/seeds/layout/importer.rb +9 -11
  101. data/lib/occams/seeds/page/exporter.rb +19 -23
  102. data/lib/occams/seeds/page/importer.rb +17 -19
  103. data/lib/occams/seeds/snippet/exporter.rb +6 -8
  104. data/lib/occams/seeds/snippet/importer.rb +6 -8
  105. data/lib/occams/seeds.rb +6 -12
  106. data/lib/occams/version.rb +1 -3
  107. data/lib/occams/view_hooks.rb +1 -3
  108. data/lib/occams.rb +25 -29
  109. data/lib/tasks/cms_seeds.rake +4 -4
  110. data/occams.gemspec +22 -21
  111. metadata +65 -10
  112. data/LICENSE.comfy +0 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8dcda75b6239c3fb7e71b35c45c3b5674373bd96d9c14457776af68ff8b1a391
4
- data.tar.gz: 003f1604af55a848c28214b6fcccbb2863ec797adad4515580d933ddb9078c79
3
+ metadata.gz: ce680397bd166f37f751f3809e6bae83bfa630626d20e21d479631487ba03f59
4
+ data.tar.gz: 6b0bb13446c96370910182f7acdcb66ba9bc93cacb1815483fa182e1b51d9af5
5
5
  SHA512:
6
- metadata.gz: 6a7f7f9b4317cefb3961cd916b75f4df6bd8247686f80224926bc5cde93f255e840b567cf506e03112c069e755ffa9810840eff605905fe39ec65471a9c17658
7
- data.tar.gz: 68ed2b0e79500d11ac2c940f4b89c33a894a388b26eec05cfec13d6c28198bc61ec945ad49367df83546d7d40e0b36dab379e6dd4fa6bfca7f206b35424ce964
6
+ metadata.gz: 3389d7c086da5dd49d5a3e54c81e0036abd459b13c9885ff7159aa49d74d39ca0667b2618438edd8414c3a4d97f8b1ced0d5abd6bddf4ffdbb9b9f8bf28e538d
7
+ data.tar.gz: 9c47baa318396a1f77fc19cec2b0c8b7498a7946edb1ab6c0bbe66ca5df5de425211bcdf822758b4a8d752150327cfbbbf043031999bf410cfce97a1ed3ce304
@@ -1,16 +1,14 @@
1
- *Note:* For general questions and feature requests please leave a message
2
- on Gitter: https://gitter.im/comfy/comfortable-mexican-sofa
3
1
 
4
2
  ### Expected behavior
5
3
  Tell us what should happen
6
4
 
7
5
  ### Actual behavior
8
- Tell us what happens instead
6
+ Tell us what does happen
9
7
 
10
8
  ### Steps to reproduce
11
9
  Things that help:
12
10
 
13
- * Describe issue in detail.
11
+ * Describe the issue in detail.
14
12
  * Add relevant code snippets.
15
13
  * Create a failing test case.
16
14
 
data/.rubocop.yml CHANGED
@@ -1,5 +1,6 @@
1
1
  AllCops:
2
2
  TargetRubyVersion: 2.7
3
+ NewCops: enable
3
4
  Exclude:
4
5
  - bin/*
5
6
  - db/schema.rb
@@ -11,77 +12,59 @@ AllCops:
11
12
  Layout/FirstArrayElementIndentation:
12
13
  EnforcedStyle: consistent
13
14
 
14
- Layout/MultilineHashBraceLayout:
15
- Enabled: false
15
+ Layout/LineLength:
16
+ Max: 148
16
17
 
17
18
  Layout/MultilineMethodCallIndentation:
18
19
  EnforcedStyle: indented
19
20
 
20
- Layout/MultilineOperationIndentation:
21
- Enabled: false
22
-
23
- Layout/ParameterAlignment:
24
- Enabled: false
25
-
26
21
  Layout/AccessModifierIndentation:
27
22
  EnforcedStyle: outdent
28
23
 
29
24
  # -- Metrics -------------------------------------------------------------------
30
- Metrics/PerceivedComplexity:
31
- Enabled: false
32
-
33
- Metrics/MethodLength:
25
+ Metrics/AbcSize:
34
26
  Enabled: false
35
27
 
36
- Metrics/MethodLength:
37
- Enabled: false
28
+ Metrics/BlockLength:
29
+ Max: 45
38
30
 
39
- Metrics/ParameterLists:
31
+ Metrics/ClassLength:
40
32
  Enabled: false
41
33
 
42
- Metrics/LineLength:
43
- Max: 120
44
-
45
34
  Metrics/CyclomaticComplexity:
46
- Enabled: false
35
+ Max: 12
47
36
 
48
- Metrics/ClassLength:
49
- Enabled: false
50
-
51
- Metrics/BlockLength:
37
+ Metrics/MethodLength:
52
38
  Enabled: false
53
39
 
54
- Metrics/AbcSize:
55
- Enabled: false
40
+ Metrics/PerceivedComplexity:
41
+ Max: 12
56
42
 
57
43
  # -- Naming --------------------------------------------------------------------
58
44
  Naming/MethodParameterName:
59
45
  Enabled: false
60
46
 
61
47
  # -- Style ---------------------------------------------------------------------
62
- Style/StringLiterals:
63
- EnforcedStyle: double_quotes
64
-
65
- Style/RegexpLiteral:
66
- EnforcedStyle: percent_r
67
-
68
- Style/Lambda:
69
- EnforcedStyle: literal
48
+ Style/ClassAndModuleChildren:
49
+ Enabled: false
70
50
 
71
- Style/IfUnlessModifier:
51
+ Style/Documentation:
72
52
  Enabled: false
73
53
 
74
- Style/GuardClause:
54
+ Style/DocumentDynamicEvalDefinition:
75
55
  Enabled: false
76
56
 
77
- Style/Documentation:
57
+ Style/IfUnlessModifier:
78
58
  Enabled: false
79
59
 
80
- Style/DateTime:
60
+ Style/Lambda:
61
+ EnforcedStyle: literal
62
+
63
+ Style/OptionalBooleanParameter:
81
64
  Enabled: false
82
65
 
83
- Style/ClassAndModuleChildren:
66
+ Style/SafeNavigation:
84
67
  Enabled: false
85
68
 
86
- Style/AsciiComments:
87
- Enabled: false
69
+ Style/RegexpLiteral:
70
+ EnforcedStyle: percent_r
data/CHANGELOG.md CHANGED
@@ -1,7 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.0.2 -
4
+
5
+ - Fixed image rendering which rubocop broke in v1.0.1
6
+ - Show unpublished pages in Rails development mode
7
+ - Show Rails ENV at foot of Admin menu, along with versions of Occams, Rails and Ruby
8
+ - Updated documentation at [Occams Wiki](https://github.com/avonderluft/occams/wiki)
9
+ - Comprehensive rubocop linting
10
+
11
+ ## v1.0.1 - 8/7/2023
12
+
13
+ - Fixed image thumbnail hover for Rails 7
14
+ - Added display of Rails and Ruby versions along with Occams version at foot of Admin menu
15
+ - Refined gemspec dependencies
16
+ - Tweaked with a bunch of rubocop linting
17
+
3
18
  ## v1.0.0 - 8/5/2023
4
19
 
5
- - Copies the original [ComfortableMexicanSofa](https://github.com/comfy/comfortable-mexican-sofa)
6
- - Adds the changes from [Restarone's fork](https://github.com/restarone/comfortable-mexican-sofa) (23 commits)
7
- - Adds the ability to write snippets in Markdown
20
+ - Copied the original [ComfortableMexicanSofa](https://github.com/comfy/comfortable-mexican-sofa)
21
+ - Added the changes from [Restarone's fork](https://github.com/restarone/comfortable-mexican-sofa) (23 commits)
22
+ - Added the ability to write snippets in Markdown
data/Gemfile CHANGED
@@ -1,30 +1,30 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source "http://rubygems.org"
3
+ source 'http://rubygems.org'
4
4
 
5
5
  gemspec
6
6
 
7
7
  group :development, :test do
8
- gem "autoprefixer-rails", "~> 8.1.0"
9
- gem "byebug", "~> 10.0.0", platforms: %i[mri mingw x64_mingw]
10
- gem "capybara", "~> 3.39.0"
11
- gem "image_processing", ">= 1.2"
12
- gem "kaminari", "~> 1.1.1"
13
- gem "puma", "~> 3.12.2"
14
- gem "rubocop", "~> 0.55.0", require: false
15
- gem "selenium-webdriver", "~> 4.9.0"
16
- gem "sqlite3", "~> 1.4.2"
8
+ gem 'autoprefixer-rails', '~> 8.1.0'
9
+ gem 'byebug', '~> 10.0.0', platforms: %i[mri mingw x64_mingw]
10
+ gem 'capybara', '~> 3.39.0'
11
+ gem 'image_processing', '>= 1.2'
12
+ gem 'kaminari', '~> 1.2', '>= 1.2.2'
13
+ gem 'puma', '~> 3.12.2'
14
+ gem 'rubocop', '~> 0.55.0', require: false
15
+ gem 'selenium-webdriver', '~> 4.9.0'
16
+ gem 'sqlite3', '~> 1.4.2'
17
17
  end
18
18
 
19
19
  group :development do
20
- gem "listen", "~> 3.8.0"
21
- gem "web-console", "~> 3.5.1"
20
+ gem 'listen', '~> 3.8.0'
21
+ gem 'web-console', '~> 3.5.1'
22
22
  end
23
23
 
24
24
  group :test do
25
- gem "coveralls", "~> 0.8.21", require: false
26
- gem "diffy", "~> 3.2.0"
27
- gem "equivalent-xml", "~> 0.6.0"
28
- gem "mocha", "~> 1.3.0", require: false
29
- gem "rails-controller-testing", "~> 1.0.2"
25
+ gem 'coveralls', '~> 0.8.23', require: false
26
+ gem 'diffy', '~> 3.4.2'
27
+ gem 'equivalent-xml', '~> 0.6.0'
28
+ gem 'mocha', '~> 2.1.0', require: false
29
+ gem 'rails-controller-testing', '~> 1.0.5'
30
30
  end
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2023 Andrew vonderLuft
1
+ Copyright (c) 2010-2019 Oleg Khabarov (ComfortableMexicanSofa), 2023 Andrew vonderLuft
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -26,8 +26,8 @@ ocCaM'S, pronounced "AH-kums" is a nod to [Occam's Razor](https://en.wikipedia.o
26
26
 
27
27
  Referring to the [ComfortableMexicanSofa](https://github.com/comfy/comfortable-mexican-sofa) documentation, substituting 'Occams' for 'ComfortableMexicanSofa' where appropriate.
28
28
 
29
- * Powerful page templating capability using [Content Tags](https://github.com/comfy/comfortable-mexican-sofa/wiki/Docs:-Content-Tags)
30
- * [Multiple Sites](https://github.com/ocms/comfortable-mexican-sofa/wiki/Docs:-Sites) from a single installation
29
+ * Powerful page templating capability using [Content Tags](https://github.com/avonderluft/occams/wiki/Content-Tags)
30
+ * [Multiple Sites](https://github.com/avonderluft/occams/wiki/Sites) from a single installation
31
31
  * Multi-Language Support (i18n) (ca, cs, da, de, en, es, fi, fr, gr, hr, it, ja, nb, nl, pl, pt-BR, ru, sv, tr, uk, zh-CN, zh-TW) and page localization.
32
32
  * [CMS Seeds](https://github.com/comfy/comfortable-mexican-sofa/wiki/Docs:-CMS-Seeds) for initial content population
33
33
  * [Revision History](https://github.com/comfy/comfortable-mexican-sofa/wiki/Docs:-Revisions) to revert changes
@@ -36,13 +36,13 @@ Referring to the [ComfortableMexicanSofa](https://github.com/comfy/comfortable-m
36
36
  ## Dependencies
37
37
 
38
38
  * File attachments are handled by [ActiveStorage](https://github.com/rails/rails/tree/master/activestorage). Make sure that you can run appropriate migrations by running: `rails active_storage:install` and then `rake db:migrate`
39
- * Image resizing is done with with [ImageMagick](http://www.imagemagick.org/script/download.php), so make sure it's installed.
39
+ * Image resizing is done on Rails 7 or greater, with[ImageMagick](http://www.imagemagick.org/script/download.php), so make sure it's installed
40
40
  * Pagination is handled by [kaminari](https://github.com/amatsuda/kaminari) or [will_paginate](https://github.com/mislav/will_paginate). Please add one of those to your Gemfile.
41
41
 
42
42
  ## Compatibility
43
43
 
44
- - Install and basic functionality validated on Ruby 3.2.2. with Rails 6.1.7.4 and 7.0.6
45
- - >= Rails 7 is recommended, since performance is noticably better
44
+ - Install and basic functionality validated on Ruby 3.2.2. with Rails 6.1.7.4 and 7.0.6 and 7.0.6
45
+ - Rails 7 is recommended, since performance is noticably better
46
46
 
47
47
  ## Installation
48
48
 
@@ -89,28 +89,24 @@ After creating a Site, you need to make a Layout. Layout is the template of your
89
89
 
90
90
  Once you have a layout, you may start creating pages and populating content. It's that easy.
91
91
 
92
- ## ToDos
93
-
94
- - Linting via current version of rubocop
95
- - Image file thumbnail hover not working on Rails 7
96
- - get the original [ComfortableMexicanSofa](https://github.com/comfy/comfortable-mexican-sofa) tests working
97
- - add documentation to Occams to replace ComfortableMexicanSofa
98
-
99
92
  ## Documentation
100
93
 
101
- Refer to the [ComfortableMexicanSofa](https://github.com/comfy/comfortable-mexican-sofa) documentation, substituting 'Occams' for 'Comfy' where appropriate.
102
-
103
- For more information on how to use this CMS please refer to the [Wiki](https://github.com/comfy/comfortable-mexican-sofa/wiki). Section that might be of interest is the entry
104
- on [Content Tags](https://github.com/comfy/comfortable-mexican-sofa/wiki/Docs:-Content-Tags).
94
+ [Occams](https://github.com/avonderluft/occams)
105
95
 
106
- [Ocms Demo App](https://github.com/comfy/comfy-demo) also can be used as an
107
- example of a default Rails app with CMS installed.
96
+ For more information on how to use this CMS please refer to the [Wiki](https://github.com/avonderluft/occams/wiki). Section that might be of interest is the entry
97
+ on [Content Tags](https://github.com/comfy/avonderluft/occams/Content-Tags).
108
98
 
109
99
  #### Contributing
110
100
 
111
101
  The Occams repository can run like any Rails application in development. It's as easy to work on as any other Rails app.
112
102
  For more detail see [CONTRIBUTING](CONTRIBUTING.md)
113
103
 
104
+ #### Testing
105
+
106
+ - `bin/rails db:migrate`
107
+ - `rake db:test:prepare`
108
+ - `rake test`
109
+
114
110
  #### Acknowledgements
115
111
 
116
112
  - Obviously to Oleg Khabarov, the creator of [ComfortableMexicanSofa](https://github.com/comfy/comfortable-mexican-sofa). This is his work, with just a few updates and additions.
@@ -118,4 +114,4 @@ For more detail see [CONTRIBUTING](CONTRIBUTING.md)
118
114
 
119
115
  ---
120
116
  - [ComfortableMexicanSofa](https://github.com/comfy/comfortable-mexican-sofa) Copyright 2010-2019 Oleg Khabarov. Released under the [MIT license](LICENSE)
121
- - [Occams](https://github.com/avonderluft/occams) follows suit, being also released under the [MIT license](LICENSE)
117
+ - [Occams] Copyright 2023 Andrew vonderLuft (https://github.com/avonderluft/occams) follows suit, being also released under the [MIT license](LICENSE)
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "config/application"
3
+ require_relative 'config/application'
4
4
 
5
5
  Rails.application.load_tasks
data/TODOS.md ADDED
@@ -0,0 +1,6 @@
1
+ # ToDos
2
+
3
+ - add application console for testing
4
+ - feature to resize file_link'd images
5
+ - get the original [ComfortableMexicanSofa](https://github.com/comfy/comfortable-mexican-sofa) tests working
6
+ - add documentation to Occams to replace ComfortableMexicanSofa
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ApplicationController < ActionController::Base
4
-
5
4
  protect_from_forgery
6
-
7
5
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Occams::Paginate
4
-
5
4
  # Wrapper to deal with WillPaginate vs Kaminari nonsense
6
5
  def occams_paginate(scope, per_page: 50)
7
6
  if defined?(WillPaginate)
@@ -12,5 +11,4 @@ module Occams::Paginate
12
11
  scope
13
12
  end
14
13
  end
15
-
16
14
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Occams::ReorderAction
4
-
5
4
  extend ActiveSupport::Concern
6
5
 
7
6
  included do
@@ -15,5 +14,4 @@ module Occams::ReorderAction
15
14
  end
16
15
  head :ok
17
16
  end
18
-
19
17
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Occams::Admin::BaseController < Occams.config.admin_base_controller.to_s.constantize
4
-
5
4
  include Occams::Paginate
6
5
 
7
6
  # Authentication module must have `authenticate` method
@@ -17,6 +16,5 @@ class Occams::Admin::BaseController < Occams.config.admin_base_controller.to_s.c
17
16
 
18
17
  before_action :authenticate
19
18
 
20
- layout "occams/admin/cms"
21
-
19
+ layout 'occams/admin/cms'
22
20
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Occams::Admin::Cms::BaseController < Occams::Admin::BaseController
4
-
5
4
  before_action :load_admin_site,
6
5
  :set_locale,
7
6
  :load_seeds,
@@ -16,6 +15,7 @@ class Occams::Admin::Cms::BaseController < Occams::Admin::BaseController
16
15
  def jump
17
16
  path = Occams.config.admin_route_redirect
18
17
  return redirect_to(path) unless path.blank?
18
+
19
19
  load_admin_site
20
20
  redirect_to occams_admin_cms_site_pages_path(@site) if @site
21
21
  end
@@ -28,28 +28,27 @@ protected
28
28
  session[:site_id] = @site.id
29
29
  else
30
30
  I18n.locale = Occams.config.admin_locale || I18n.default_locale
31
- flash[:danger] = I18n.t("occams.admin.cms.base.site_not_found")
32
- return redirect_to(new_occams_admin_cms_site_path)
31
+ flash[:danger] = I18n.t('occams.admin.cms.base.site_not_found')
32
+ redirect_to(new_occams_admin_cms_site_path)
33
33
  end
34
34
  end
35
35
 
36
36
  def set_locale
37
- I18n.locale = Occams.config.admin_locale || (@site&.locale)
37
+ I18n.locale = Occams.config.admin_locale || @site&.locale
38
38
  true
39
39
  end
40
40
 
41
41
  def load_seeds
42
42
  return unless Occams.config.enable_seeds
43
43
 
44
- controllers = %w[layouts pages snippets files].collect { |c| "occams/admin/cms/" + c }
45
- if controllers.member?(params[:controller]) && params[:action] == "index"
46
- Occams::Seeds::Importer.new(@site.identifier).import!
47
- flash.now[:warning] = I18n.t("occams.admin.cms.base.seeds_enabled")
48
- end
44
+ controllers = %w[layouts pages snippets files].collect { |c| "occams/admin/cms/#{c}" }
45
+ return unless controllers.member?(params[:controller]) && params[:action] == 'index'
46
+
47
+ Occams::Seeds::Importer.new(@site.identifier).import!
48
+ flash.now[:warning] = I18n.t('occams.admin.cms.base.seeds_enabled')
49
49
  end
50
50
 
51
51
  def infer_layout
52
- false if params[:layout] == "false"
52
+ false if params[:layout] == 'false'
53
53
  end
54
-
55
54
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Occams::Admin::Cms::CategoriesController < Occams::Admin::Cms::BaseController
4
-
5
4
  before_action :load_category, only: %i[edit update destroy]
6
5
  before_action :authorize
7
6
 
@@ -36,5 +35,4 @@ protected
36
35
  def category_params
37
36
  params.fetch(:category, {}).permit!
38
37
  end
39
-
40
38
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Occams::Admin::Cms::FilesController < Occams::Admin::Cms::BaseController
4
-
5
4
  include ::Occams::ReorderAction
6
5
  self.reorder_action_resource = ::Occams::Cms::File
7
6
 
@@ -17,11 +16,11 @@ class Occams::Admin::Cms::FilesController < Occams::Admin::Cms::BaseController
17
16
  case params[:source]
18
17
 
19
18
  # Integration with Redactor 1.0 Wysiwyg
20
- when "redactor"
19
+ when 'redactor'
21
20
  file_scope = files_scope.limit(100).order(:position)
22
21
  file_hashes =
23
22
  case params[:type]
24
- when "image"
23
+ when 'image'
25
24
  file_scope.with_images.collect do |file|
26
25
  { thumb: url_for(file.attachment.variant(combine_options: Occams::Cms::File::VARIANT_SIZE[:redactor])),
27
26
  image: url_for(file.attachment),
@@ -29,10 +28,10 @@ class Occams::Admin::Cms::FilesController < Occams::Admin::Cms::BaseController
29
28
  end
30
29
  else
31
30
  file_scope.collect do |file|
32
- { title: file.label,
33
- name: file.attachment.filename,
34
- link: url_for(file.attachment),
35
- size: number_to_human_size(file.attachment.byte_size) }
31
+ { title: file.label,
32
+ name: file.attachment.filename,
33
+ link: url_for(file.attachment),
34
+ size: number_to_human_size(file.attachment.byte_size) }
36
35
  end
37
36
  end
38
37
 
@@ -42,7 +41,7 @@ class Occams::Admin::Cms::FilesController < Occams::Admin::Cms::BaseController
42
41
  files_scope = files_scope
43
42
  .includes(:categories)
44
43
  .for_category(params[:categories])
45
- .order("occams_cms_files.position")
44
+ .order('occams_cms_files.position')
46
45
  @files = occams_paginate(files_scope, per_page: 50)
47
46
  end
48
47
  end
@@ -52,7 +51,7 @@ class Occams::Admin::Cms::FilesController < Occams::Admin::Cms::BaseController
52
51
  end
53
52
 
54
53
  def create
55
- categories_scope = @site.categories.of_type("Occams::Cms::File")
54
+ categories_scope = @site.categories.of_type('Occams::Cms::File')
56
55
 
57
56
  if params[:categories]
58
57
  ids = categories_scope.where(label: params[:categories]).pluck(:id)
@@ -60,34 +59,33 @@ class Occams::Admin::Cms::FilesController < Occams::Admin::Cms::BaseController
60
59
  end
61
60
 
62
61
  # Automatically tagging upload if it's done through redactor
63
- if params[:source] == "redactor"
64
- category = categories_scope.find_or_create_by(label: "wysiwyg")
62
+ if params[:source] == 'redactor'
63
+ category = categories_scope.find_or_create_by(label: 'wysiwyg')
65
64
  @file.category_ids = [category.id]
66
65
  end
67
66
 
68
67
  @file.save!
69
68
 
70
69
  case params[:source]
71
- when "plupload"
72
- render partial: "file", object: @file
73
- when "redactor"
70
+ when 'plupload'
71
+ render partial: 'file', object: @file
72
+ when 'redactor'
74
73
  render json: {
75
74
  filelink: url_for(@file.attachment),
76
75
  filename: @file.attachment.filename
77
76
  }
78
77
  else
79
- flash[:success] = I18n.t("occams.admin.cms.files.created")
78
+ flash[:success] = I18n.t('occams.admin.cms.files.created')
80
79
  redirect_to action: :edit, id: @file
81
80
  end
82
-
83
81
  rescue ActiveRecord::RecordInvalid
84
82
  case params[:source]
85
- when "plupload"
83
+ when 'plupload'
86
84
  render body: @file.errors.full_messages.to_sentence, status: :unprocessable_entity
87
- when "redactor"
85
+ when 'redactor'
88
86
  render body: nil, status: :unprocessable_entity
89
87
  else
90
- flash.now[:danger] = I18n.t("occams.admin.cms.files.creation_failure")
88
+ flash.now[:danger] = I18n.t('occams.admin.cms.files.creation_failure')
91
89
  render action: :new
92
90
  end
93
91
  end
@@ -98,10 +96,10 @@ class Occams::Admin::Cms::FilesController < Occams::Admin::Cms::BaseController
98
96
 
99
97
  def update
100
98
  if @file.update(file_params)
101
- flash[:success] = I18n.t("occams.admin.cms.files.updated")
99
+ flash[:success] = I18n.t('occams.admin.cms.files.updated')
102
100
  redirect_to action: :edit, id: @file
103
101
  else
104
- flash.now[:danger] = I18n.t("occams.admin.cms.files.update_failure")
102
+ flash.now[:danger] = I18n.t('occams.admin.cms.files.update_failure')
105
103
  render action: :edit
106
104
  end
107
105
  end
@@ -111,7 +109,7 @@ class Occams::Admin::Cms::FilesController < Occams::Admin::Cms::BaseController
111
109
  respond_to do |format|
112
110
  format.js
113
111
  format.html do
114
- flash[:success] = I18n.t("occams.admin.cms.files.deleted")
112
+ flash[:success] = I18n.t('occams.admin.cms.files.deleted')
115
113
  redirect_to action: :index
116
114
  end
117
115
  end
@@ -126,7 +124,7 @@ protected
126
124
  def load_file
127
125
  @file = @site.files.find(params[:id])
128
126
  rescue ActiveRecord::RecordNotFound
129
- flash[:danger] = I18n.t("occams.admin.cms.files.not_found")
127
+ flash[:danger] = I18n.t('occams.admin.cms.files.not_found')
130
128
  redirect_to action: :index
131
129
  end
132
130
 
@@ -138,5 +136,4 @@ protected
138
136
  end
139
137
  params.fetch(:file, {}).permit!
140
138
  end
141
-
142
139
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Occams::Admin::Cms::LayoutsController < Occams::Admin::Cms::BaseController
4
-
5
4
  include ::Occams::ReorderAction
6
5
  self.reorder_action_resource = ::Occams::Cms::Layout
7
6
 
@@ -11,6 +10,7 @@ class Occams::Admin::Cms::LayoutsController < Occams::Admin::Cms::BaseController
11
10
 
12
11
  def index
13
12
  return redirect_to action: :new if @site.layouts.count.zero?
13
+
14
14
  @layouts = @site.layouts.roots.order(:position)
15
15
  end
16
16
 
@@ -24,25 +24,25 @@ class Occams::Admin::Cms::LayoutsController < Occams::Admin::Cms::BaseController
24
24
 
25
25
  def create
26
26
  @layout.save!
27
- flash[:success] = I18n.t("occams.admin.cms.layouts.created")
27
+ flash[:success] = I18n.t('occams.admin.cms.layouts.created')
28
28
  redirect_to action: :edit, id: @layout
29
29
  rescue ActiveRecord::RecordInvalid
30
- flash.now[:danger] = I18n.t("occams.admin.cms.layouts.creation_failure")
30
+ flash.now[:danger] = I18n.t('occams.admin.cms.layouts.creation_failure')
31
31
  render action: :new
32
32
  end
33
33
 
34
34
  def update
35
35
  @layout.update!(layout_params)
36
- flash[:success] = I18n.t("occams.admin.cms.layouts.updated")
36
+ flash[:success] = I18n.t('occams.admin.cms.layouts.updated')
37
37
  redirect_to action: :edit, id: @layout
38
38
  rescue ActiveRecord::RecordInvalid
39
- flash.now[:danger] = I18n.t("occams.admin.cms.layouts.update_failure")
39
+ flash.now[:danger] = I18n.t('occams.admin.cms.layouts.update_failure')
40
40
  render action: :edit
41
41
  end
42
42
 
43
43
  def destroy
44
44
  @layout.destroy
45
- flash[:success] = I18n.t("occams.admin.cms.layouts.deleted")
45
+ flash[:success] = I18n.t('occams.admin.cms.layouts.deleted')
46
46
  redirect_to action: :index
47
47
  end
48
48
 
@@ -52,18 +52,17 @@ protected
52
52
  @layout = @site.layouts.new(layout_params)
53
53
  @layout.parent ||= ::Occams::Cms::Layout.find_by_id(params[:parent_id])
54
54
  @layout.app_layout ||= @layout.parent.try(:app_layout)
55
- @layout.content ||= "{{ cms:wysiwyg content }}"
55
+ @layout.content ||= '{{ cms:wysiwyg content }}'
56
56
  end
57
57
 
58
58
  def load_layout
59
59
  @layout = @site.layouts.find(params[:id])
60
60
  rescue ActiveRecord::RecordNotFound
61
- flash[:danger] = I18n.t("occams.admin.cms.layouts.not_found")
61
+ flash[:danger] = I18n.t('occams.admin.cms.layouts.not_found')
62
62
  redirect_to action: :index
63
63
  end
64
64
 
65
65
  def layout_params
66
66
  params.fetch(:layout, {}).permit!
67
67
  end
68
-
69
68
  end