occams 1.0.1 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +23 -40
  3. data/CHANGELOG.md +13 -0
  4. data/Gemfile +17 -17
  5. data/LICENSE +1 -1
  6. data/README.md +15 -18
  7. data/Rakefile +1 -1
  8. data/TODOS.md +6 -0
  9. data/app/controllers/occams/admin/base_controller.rb +1 -1
  10. data/app/controllers/occams/admin/cms/base_controller.rb +7 -7
  11. data/app/controllers/occams/admin/cms/files_controller.rb +17 -17
  12. data/app/controllers/occams/admin/cms/layouts_controller.rb +7 -7
  13. data/app/controllers/occams/admin/cms/pages_controller.rb +25 -25
  14. data/app/controllers/occams/admin/cms/revisions/base_controller.rb +5 -5
  15. data/app/controllers/occams/admin/cms/revisions/layout_controller.rb +1 -1
  16. data/app/controllers/occams/admin/cms/revisions/page_controller.rb +3 -3
  17. data/app/controllers/occams/admin/cms/revisions/snippet_controller.rb +1 -1
  18. data/app/controllers/occams/admin/cms/revisions/translation_controller.rb +3 -3
  19. data/app/controllers/occams/admin/cms/sites_controller.rb +6 -6
  20. data/app/controllers/occams/admin/cms/snippets_controller.rb +6 -6
  21. data/app/controllers/occams/admin/cms/translations_controller.rb +24 -24
  22. data/app/controllers/occams/cms/assets_controller.rb +5 -5
  23. data/app/controllers/occams/cms/base_controller.rb +7 -12
  24. data/app/controllers/occams/cms/content_controller.rb +14 -10
  25. data/app/helpers/occams/admin/cms_helper.rb +3 -3
  26. data/app/helpers/occams/cms_helper.rb +8 -8
  27. data/app/models/concerns/occams/cms/with_categories.rb +3 -3
  28. data/app/models/concerns/occams/cms/with_fragments.rb +3 -3
  29. data/app/models/occams/cms/categorization.rb +1 -1
  30. data/app/models/occams/cms/category.rb +1 -1
  31. data/app/models/occams/cms/file.rb +4 -4
  32. data/app/models/occams/cms/fragment.rb +2 -2
  33. data/app/models/occams/cms/layout.rb +5 -5
  34. data/app/models/occams/cms/page.rb +6 -6
  35. data/app/models/occams/cms/revision.rb +1 -1
  36. data/app/models/occams/cms/site.rb +8 -8
  37. data/app/models/occams/cms/snippet.rb +1 -1
  38. data/app/models/occams/cms/translation.rb +1 -1
  39. data/app/views/layouts/occams/admin/cms/_left.html.haml +3 -0
  40. data/config/application.rb +4 -4
  41. data/config/boot.rb +4 -3
  42. data/config/environment.rb +1 -1
  43. data/config/environments/development.rb +2 -2
  44. data/config/environments/test.rb +1 -1
  45. data/config/initializers/occams.rb +2 -2
  46. data/config.ru +1 -1
  47. data/lib/generators/occams/cms/assets_generator.rb +3 -3
  48. data/lib/generators/occams/cms/cms_generator.rb +13 -13
  49. data/lib/generators/occams/cms/controllers_generator.rb +2 -2
  50. data/lib/generators/occams/cms/models_generator.rb +2 -2
  51. data/lib/generators/occams/cms/views_generator.rb +2 -2
  52. data/lib/generators/occams/scaffold/scaffold_generator.rb +18 -18
  53. data/lib/occams/configuration.rb +33 -33
  54. data/lib/occams/content/params_parser.rb +3 -3
  55. data/lib/occams/content/renderer.rb +8 -8
  56. data/lib/occams/content/tag.rb +1 -1
  57. data/lib/occams/content/tags/asset.rb +13 -13
  58. data/lib/occams/content/tags/audio.rb +41 -0
  59. data/lib/occams/content/tags/checkbox.rb +4 -4
  60. data/lib/occams/content/tags/date.rb +2 -2
  61. data/lib/occams/content/tags/datetime.rb +4 -4
  62. data/lib/occams/content/tags/file.rb +8 -8
  63. data/lib/occams/content/tags/file_link.rb +8 -8
  64. data/lib/occams/content/tags/files.rb +5 -5
  65. data/lib/occams/content/tags/fragment.rb +4 -4
  66. data/lib/occams/content/tags/helper.rb +6 -6
  67. data/lib/occams/content/tags/markdown.rb +2 -2
  68. data/lib/occams/content/tags/mixins/file_content.rb +3 -3
  69. data/lib/occams/content/tags/number.rb +1 -1
  70. data/lib/occams/content/tags/page_file_link.rb +8 -8
  71. data/lib/occams/content/tags/partial.rb +5 -5
  72. data/lib/occams/content/tags/snippet.rb +3 -3
  73. data/lib/occams/content/tags/template.rb +5 -5
  74. data/lib/occams/content/tags/text.rb +1 -1
  75. data/lib/occams/content/tags/textarea.rb +1 -1
  76. data/lib/occams/content/tags/wysiwyg.rb +1 -1
  77. data/lib/occams/content.rb +23 -22
  78. data/lib/occams/engine.rb +10 -10
  79. data/lib/occams/extensions/acts_as_tree.rb +1 -1
  80. data/lib/occams/extensions/has_revisions.rb +3 -3
  81. data/lib/occams/form_builder.rb +4 -4
  82. data/lib/occams/render_methods.rb +2 -2
  83. data/lib/occams/routes/cms.rb +3 -3
  84. data/lib/occams/routes/cms_admin.rb +6 -6
  85. data/lib/occams/routing.rb +2 -2
  86. data/lib/occams/seeds/file/exporter.rb +7 -11
  87. data/lib/occams/seeds/file/importer.rb +5 -5
  88. data/lib/occams/seeds/layout/exporter.rb +9 -9
  89. data/lib/occams/seeds/layout/importer.rb +9 -9
  90. data/lib/occams/seeds/page/exporter.rb +19 -21
  91. data/lib/occams/seeds/page/importer.rb +14 -14
  92. data/lib/occams/seeds/snippet/exporter.rb +6 -6
  93. data/lib/occams/seeds/snippet/importer.rb +6 -6
  94. data/lib/occams/seeds.rb +5 -5
  95. data/lib/occams/version.rb +1 -1
  96. data/lib/occams/view_hooks.rb +1 -1
  97. data/lib/occams.rb +24 -24
  98. data/lib/tasks/cms_seeds.rake +2 -2
  99. data/occams.gemspec +22 -21
  100. metadata +8 -6
  101. data/LICENSE.comfy +0 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f36d04aa7fd573bb40f6a209c41b7bd49386f3124355425551b984e01e439e9
4
- data.tar.gz: a45311a36a5eb674f2b0bbb30eecf702db38d7828debd69277b62a8d8af9e08a
3
+ metadata.gz: f030fa6c8dd687cc40cba6d81f64035f233c93ffd6b0b7c7f63b5ca90846c5d6
4
+ data.tar.gz: 3e739fe2c866bd741e2f5c7b2901bbc2ef898a6891d6d0c5c54d7a0037a2d8b8
5
5
  SHA512:
6
- metadata.gz: 38fa2734074d1b7415f4a3f00bb6e471a8da1294cf57aead091f5754d020e9f5cd1945eef342b6a1545eb7ee4a3a8d1c8253e9176920bb147c40e236ab581b17
7
- data.tar.gz: 958e68e0579f56d27709f35b012c197c835a3ab7b14a3b220ff14d4c0c85afdac6787499d3e9b1574cc77af9382c2c245822d29734a1aeedf44978db06c0a087
6
+ metadata.gz: ae30e9cb660dcf2a31980a5d0de6d2da4d007ea5973d8e86a91e85c409bd2733d1554e64d8085d821745d37820c5e1a9a8b6c49ebde9254247fec315c9a9bac7
7
+ data.tar.gz: 7d18607b4253d86bff9cf8e3be92541385b33d474d188e1a5da22c94f3e339dc62bf86548a564838867d068d6c847ecda379b516c65b4f01d4f6fe03da6fb79b
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,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.0.3 - 8/15/2023
4
+
5
+ - Added a [cms:audio tag](https://github.com/avonderluft/occams/wiki/Content-Tags#audio) for an embedded audio player
6
+ - Some formatting of admin menu footer
7
+
8
+ ## v1.0.2 - 8/14/2023
9
+
10
+ - Fixed image rendering which rubocop broke in v1.0.1
11
+ - Show unpublished pages in Rails development mode
12
+ - Show Rails ENV at foot of Admin menu, along with versions of Occams, Rails and Ruby
13
+ - Updated documentation at [Occams Wiki](https://github.com/avonderluft/occams/wiki)
14
+ - Comprehensive rubocop linting
15
+
3
16
  ## v1.0.1 - 8/7/2023
4
17
 
5
18
  - Fixed image thumbnail hover for Rails 7
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+
45
+ - Rails 7 is recommended, since performance is noticably better
46
46
 
47
47
  ## Installation
48
48
 
@@ -89,27 +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
- - get the original [ComfortableMexicanSofa](https://github.com/comfy/comfortable-mexican-sofa) tests working
96
- - add documentation to Occams to replace ComfortableMexicanSofa
97
-
98
92
  ## Documentation
99
93
 
100
- Refer to the [ComfortableMexicanSofa](https://github.com/comfy/comfortable-mexican-sofa) documentation, substituting 'Occams' for 'Comfy' where appropriate.
101
-
102
- 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
103
- on [Content Tags](https://github.com/comfy/comfortable-mexican-sofa/wiki/Docs:-Content-Tags).
94
+ [Occams](https://github.com/avonderluft/occams)
104
95
 
105
- [Ocms Demo App](https://github.com/comfy/comfy-demo) also can be used as an
106
- 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).
107
98
 
108
99
  #### Contributing
109
100
 
110
101
  The Occams repository can run like any Rails application in development. It's as easy to work on as any other Rails app.
111
102
  For more detail see [CONTRIBUTING](CONTRIBUTING.md)
112
103
 
104
+ #### Testing
105
+
106
+ - `bin/rails db:migrate`
107
+ - `rake db:test:prepare`
108
+ - `rake test`
109
+
113
110
  #### Acknowledgements
114
111
 
115
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.
@@ -117,4 +114,4 @@ For more detail see [CONTRIBUTING](CONTRIBUTING.md)
117
114
 
118
115
  ---
119
116
  - [ComfortableMexicanSofa](https://github.com/comfy/comfortable-mexican-sofa) Copyright 2010-2019 Oleg Khabarov. Released under the [MIT license](LICENSE)
120
- - [Occams](https://github.com/avonderluft/occams) follows suit, being also released under the [MIT license](LICENSE)
117
+ - [Occams](https://github.com/avonderluft/occams) Copyright 2023 Andrew vonderLuft, following suit, 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
+ - add feature to resize file_link'd images
5
+ - get the original [ComfortableMexicanSofa](https://github.com/comfy/comfortable-mexican-sofa) tests working
6
+ - add and update documentation to Occams to replace ComfortableMexicanSofa
@@ -16,5 +16,5 @@ class Occams::Admin::BaseController < Occams.config.admin_base_controller.to_s.c
16
16
 
17
17
  before_action :authenticate
18
18
 
19
- layout "occams/admin/cms"
19
+ layout 'occams/admin/cms'
20
20
  end
@@ -28,7 +28,7 @@ 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")
31
+ flash[:danger] = I18n.t('occams.admin.cms.base.site_not_found')
32
32
  redirect_to(new_occams_admin_cms_site_path)
33
33
  end
34
34
  end
@@ -41,14 +41,14 @@ protected
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
54
  end
@@ -16,11 +16,11 @@ class Occams::Admin::Cms::FilesController < Occams::Admin::Cms::BaseController
16
16
  case params[:source]
17
17
 
18
18
  # Integration with Redactor 1.0 Wysiwyg
19
- when "redactor"
19
+ when 'redactor'
20
20
  file_scope = files_scope.limit(100).order(:position)
21
21
  file_hashes =
22
22
  case params[:type]
23
- when "image"
23
+ when 'image'
24
24
  file_scope.with_images.collect do |file|
25
25
  { thumb: url_for(file.attachment.variant(combine_options: Occams::Cms::File::VARIANT_SIZE[:redactor])),
26
26
  image: url_for(file.attachment),
@@ -41,7 +41,7 @@ class Occams::Admin::Cms::FilesController < Occams::Admin::Cms::BaseController
41
41
  files_scope = files_scope
42
42
  .includes(:categories)
43
43
  .for_category(params[:categories])
44
- .order("occams_cms_files.position")
44
+ .order('occams_cms_files.position')
45
45
  @files = occams_paginate(files_scope, per_page: 50)
46
46
  end
47
47
  end
@@ -51,7 +51,7 @@ class Occams::Admin::Cms::FilesController < Occams::Admin::Cms::BaseController
51
51
  end
52
52
 
53
53
  def create
54
- categories_scope = @site.categories.of_type("Occams::Cms::File")
54
+ categories_scope = @site.categories.of_type('Occams::Cms::File')
55
55
 
56
56
  if params[:categories]
57
57
  ids = categories_scope.where(label: params[:categories]).pluck(:id)
@@ -59,33 +59,33 @@ class Occams::Admin::Cms::FilesController < Occams::Admin::Cms::BaseController
59
59
  end
60
60
 
61
61
  # Automatically tagging upload if it's done through redactor
62
- if params[:source] == "redactor"
63
- category = categories_scope.find_or_create_by(label: "wysiwyg")
62
+ if params[:source] == 'redactor'
63
+ category = categories_scope.find_or_create_by(label: 'wysiwyg')
64
64
  @file.category_ids = [category.id]
65
65
  end
66
66
 
67
67
  @file.save!
68
68
 
69
69
  case params[:source]
70
- when "plupload"
71
- render partial: "file", object: @file
72
- when "redactor"
70
+ when 'plupload'
71
+ render partial: 'file', object: @file
72
+ when 'redactor'
73
73
  render json: {
74
74
  filelink: url_for(@file.attachment),
75
75
  filename: @file.attachment.filename
76
76
  }
77
77
  else
78
- flash[:success] = I18n.t("occams.admin.cms.files.created")
78
+ flash[:success] = I18n.t('occams.admin.cms.files.created')
79
79
  redirect_to action: :edit, id: @file
80
80
  end
81
81
  rescue ActiveRecord::RecordInvalid
82
82
  case params[:source]
83
- when "plupload"
83
+ when 'plupload'
84
84
  render body: @file.errors.full_messages.to_sentence, status: :unprocessable_entity
85
- when "redactor"
85
+ when 'redactor'
86
86
  render body: nil, status: :unprocessable_entity
87
87
  else
88
- flash.now[:danger] = I18n.t("occams.admin.cms.files.creation_failure")
88
+ flash.now[:danger] = I18n.t('occams.admin.cms.files.creation_failure')
89
89
  render action: :new
90
90
  end
91
91
  end
@@ -96,10 +96,10 @@ class Occams::Admin::Cms::FilesController < Occams::Admin::Cms::BaseController
96
96
 
97
97
  def update
98
98
  if @file.update(file_params)
99
- flash[:success] = I18n.t("occams.admin.cms.files.updated")
99
+ flash[:success] = I18n.t('occams.admin.cms.files.updated')
100
100
  redirect_to action: :edit, id: @file
101
101
  else
102
- flash.now[:danger] = I18n.t("occams.admin.cms.files.update_failure")
102
+ flash.now[:danger] = I18n.t('occams.admin.cms.files.update_failure')
103
103
  render action: :edit
104
104
  end
105
105
  end
@@ -109,7 +109,7 @@ class Occams::Admin::Cms::FilesController < Occams::Admin::Cms::BaseController
109
109
  respond_to do |format|
110
110
  format.js
111
111
  format.html do
112
- flash[:success] = I18n.t("occams.admin.cms.files.deleted")
112
+ flash[:success] = I18n.t('occams.admin.cms.files.deleted')
113
113
  redirect_to action: :index
114
114
  end
115
115
  end
@@ -124,7 +124,7 @@ protected
124
124
  def load_file
125
125
  @file = @site.files.find(params[:id])
126
126
  rescue ActiveRecord::RecordNotFound
127
- flash[:danger] = I18n.t("occams.admin.cms.files.not_found")
127
+ flash[:danger] = I18n.t('occams.admin.cms.files.not_found')
128
128
  redirect_to action: :index
129
129
  end
130
130
 
@@ -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,13 +52,13 @@ 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
 
@@ -15,7 +15,7 @@ class Occams::Admin::Cms::PagesController < Occams::Admin::Cms::BaseController
15
15
  def index
16
16
  return redirect_to action: :new if site_has_no_pages?
17
17
 
18
- return index_for_redactor if params[:source] == "redactor"
18
+ return index_for_redactor if params[:source] == 'redactor'
19
19
 
20
20
  @pages_by_parent = pages_grouped_by_parent
21
21
 
@@ -37,25 +37,25 @@ class Occams::Admin::Cms::PagesController < Occams::Admin::Cms::BaseController
37
37
 
38
38
  def create
39
39
  @page.save!
40
- flash[:success] = I18n.t("occams.admin.cms.pages.created")
40
+ flash[:success] = I18n.t('occams.admin.cms.pages.created')
41
41
  redirect_to action: :edit, id: @page
42
42
  rescue ActiveRecord::RecordInvalid
43
- flash.now[:danger] = I18n.t("occams.admin.cms.pages.creation_failure")
43
+ flash.now[:danger] = I18n.t('occams.admin.cms.pages.creation_failure')
44
44
  render action: :new
45
45
  end
46
46
 
47
47
  def update
48
48
  @page.save!
49
- flash[:success] = I18n.t("occams.admin.cms.pages.updated")
49
+ flash[:success] = I18n.t('occams.admin.cms.pages.updated')
50
50
  redirect_to action: :edit, id: @page
51
51
  rescue ActiveRecord::RecordInvalid
52
- flash.now[:danger] = I18n.t("occams.admin.cms.pages.update_failure")
52
+ flash.now[:danger] = I18n.t('occams.admin.cms.pages.update_failure')
53
53
  render action: :edit
54
54
  end
55
55
 
56
56
  def destroy
57
57
  @page.destroy
58
- flash[:success] = I18n.t("occams.admin.cms.pages.deleted")
58
+ flash[:success] = I18n.t('occams.admin.cms.pages.deleted')
59
59
  redirect_to action: :index
60
60
  end
61
61
 
@@ -64,7 +64,7 @@ class Occams::Admin::Cms::PagesController < Occams::Admin::Cms::BaseController
64
64
  @page.layout = @site.layouts.find_by(id: params[:layout_id])
65
65
 
66
66
  render(
67
- partial: "occams/admin/cms/fragments/form_fragments",
67
+ partial: 'occams/admin/cms/fragments/form_fragments',
68
68
  locals: { record: @page, scope: :page },
69
69
  layout: false
70
70
  )
@@ -95,7 +95,7 @@ protected
95
95
  end
96
96
 
97
97
  page_select_options = [{
98
- name: I18n.t("occams.admin.cms.pages.form.choose_link"),
98
+ name: I18n.t('occams.admin.cms.pages.form.choose_link'),
99
99
  url: false
100
100
  }] + tree_walker.call(@site.pages.root, [], 0)
101
101
 
@@ -111,10 +111,10 @@ protected
111
111
  end
112
112
 
113
113
  def check_for_layouts
114
- if @site.layouts.count.zero?
115
- flash[:danger] = I18n.t("occams.admin.cms.pages.layout_not_found")
116
- redirect_to new_occams_admin_cms_site_layout_path(@site)
117
- end
114
+ return unless @site.layouts.count.zero?
115
+
116
+ flash[:danger] = I18n.t('occams.admin.cms.pages.layout_not_found')
117
+ redirect_to new_occams_admin_cms_site_layout_path(@site)
118
118
  end
119
119
 
120
120
  def build_page
@@ -127,26 +127,26 @@ protected
127
127
  @page = @site.pages.find(params[:id])
128
128
  @page.attributes = page_params
129
129
  rescue ActiveRecord::RecordNotFound
130
- flash[:danger] = I18n.t("occams.admin.cms.pages.not_found")
130
+ flash[:danger] = I18n.t('occams.admin.cms.pages.not_found')
131
131
  redirect_to action: :index
132
132
  end
133
133
 
134
134
  def preview_page
135
- if params[:preview]
136
- layout = @page.layout.app_layout.blank? ? false : @page.layout.app_layout
137
- @cms_site = @page.site
138
- @cms_layout = @page.layout
139
- @cms_page = @page
135
+ return unless params[:preview]
140
136
 
141
- # Make sure to use the site locale to render the preview becaue it might
142
- # be different from the admin locale.
143
- I18n.locale = @cms_site.locale
137
+ layout = @page.layout.app_layout.blank? ? false : @page.layout.app_layout
138
+ @cms_site = @page.site
139
+ @cms_layout = @page.layout
140
+ @cms_page = @page
144
141
 
145
- # Chrome chokes on content with iframes. Issue #434
146
- response.headers["X-XSS-Protection"] = "0"
142
+ # Make sure to use the site locale to render the preview becaue it might
143
+ # be different from the admin locale.
144
+ I18n.locale = @cms_site.locale
147
145
 
148
- render inline: @page.render, layout: layout, content_type: "text/html"
149
- end
146
+ # Chrome chokes on content with iframes. Issue #434
147
+ response.headers['X-XSS-Protection'] = '0'
148
+
149
+ render inline: @page.render, layout: layout, content_type: 'text/html'
150
150
  end
151
151
 
152
152
  def page_params
@@ -20,29 +20,29 @@ class Occams::Admin::Cms::Revisions::BaseController < Occams::Admin::Cms::BaseCo
20
20
  @current_content = @record.revision_fields.each_with_object({}) { |f, c| c[f] = @record.send(f) }
21
21
  @versioned_content = @record.revision_fields.each_with_object({}) { |f, c| c[f] = @revision.data[f] }
22
22
 
23
- render "occams/admin/cms/revisions/show"
23
+ render 'occams/admin/cms/revisions/show'
24
24
  end
25
25
 
26
26
  def revert
27
27
  @record.restore_from_revision(@revision)
28
- flash[:success] = I18n.t("occams.admin.cms.revisions.reverted")
28
+ flash[:success] = I18n.t('occams.admin.cms.revisions.reverted')
29
29
  redirect_to record_path
30
30
  end
31
31
 
32
32
  protected
33
33
 
34
34
  def load_record
35
- raise "not implemented"
35
+ raise 'not implemented'
36
36
  end
37
37
 
38
38
  def load_revision
39
39
  @revision = @record.revisions.find(params[:id])
40
40
  rescue ActiveRecord::RecordNotFound
41
- flash[:danger] = I18n.t("occams.admin.cms.revisions.not_found")
41
+ flash[:danger] = I18n.t('occams.admin.cms.revisions.not_found')
42
42
  redirect_to record_path
43
43
  end
44
44
 
45
45
  def record_path
46
- raise "no implemented"
46
+ raise 'no implemented'
47
47
  end
48
48
  end
@@ -6,7 +6,7 @@ private
6
6
  def load_record
7
7
  @record = @site.layouts.find(params[:layout_id])
8
8
  rescue ActiveRecord::RecordNotFound
9
- flash[:danger] = I18n.t("occams.admin.cms.revisions.record_not_found")
9
+ flash[:danger] = I18n.t('occams.admin.cms.revisions.record_not_found')
10
10
  redirect_to occams_admin_cms_site_layouts_path(@site)
11
11
  end
12
12
 
@@ -6,11 +6,11 @@ class Occams::Admin::Cms::Revisions::PageController < Occams::Admin::Cms::Revisi
6
6
  c[b.identifier] = b.content
7
7
  end
8
8
  @versioned_content = @record.fragments.each_with_object({}) do |b, c|
9
- d = @revision.data["fragments_attributes"].detect { |r| r[:identifier] == b.identifier }
9
+ d = @revision.data['fragments_attributes'].detect { |r| r[:identifier] == b.identifier }
10
10
  c[b.identifier] = d.try(:[], :content)
11
11
  end
12
12
 
13
- render "occams/admin/cms/revisions/show"
13
+ render 'occams/admin/cms/revisions/show'
14
14
  end
15
15
 
16
16
  private
@@ -18,7 +18,7 @@ private
18
18
  def load_record
19
19
  @record = @site.pages.find(params[:page_id])
20
20
  rescue ActiveRecord::RecordNotFound
21
- flash[:danger] = I18n.t("occams.admin.cms.revisions.record_not_found")
21
+ flash[:danger] = I18n.t('occams.admin.cms.revisions.record_not_found')
22
22
  redirect_to occams_admin_cms_site_pages_path(@site)
23
23
  end
24
24