occams 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/.github/issue_template.md +2 -4
  3. data/CHANGELOG.md +10 -3
  4. data/README.md +0 -1
  5. data/app/controllers/application_controller.rb +0 -2
  6. data/app/controllers/concerns/occams/paginate.rb +0 -2
  7. data/app/controllers/concerns/occams/reorder_action.rb +0 -2
  8. data/app/controllers/occams/admin/base_controller.rb +0 -2
  9. data/app/controllers/occams/admin/cms/base_controller.rb +3 -4
  10. data/app/controllers/occams/admin/cms/categories_controller.rb +0 -2
  11. data/app/controllers/occams/admin/cms/files_controller.rb +4 -7
  12. data/app/controllers/occams/admin/cms/layouts_controller.rb +1 -2
  13. data/app/controllers/occams/admin/cms/pages_controller.rb +4 -5
  14. data/app/controllers/occams/admin/cms/revisions/base_controller.rb +0 -2
  15. data/app/controllers/occams/admin/cms/revisions/layout_controller.rb +0 -2
  16. data/app/controllers/occams/admin/cms/revisions/page_controller.rb +0 -2
  17. data/app/controllers/occams/admin/cms/revisions/snippet_controller.rb +0 -2
  18. data/app/controllers/occams/admin/cms/revisions/translation_controller.rb +0 -2
  19. data/app/controllers/occams/admin/cms/sites_controller.rb +1 -2
  20. data/app/controllers/occams/admin/cms/snippets_controller.rb +1 -2
  21. data/app/controllers/occams/admin/cms/translations_controller.rb +3 -5
  22. data/app/controllers/occams/cms/assets_controller.rb +0 -2
  23. data/app/controllers/occams/cms/base_controller.rb +0 -2
  24. data/app/controllers/occams/cms/content_controller.rb +5 -6
  25. data/app/helpers/occams/admin/cms_helper.rb +0 -2
  26. data/app/helpers/occams/cms_helper.rb +5 -2
  27. data/app/models/concerns/occams/cms/with_categories.rb +5 -7
  28. data/app/models/concerns/occams/cms/with_fragments.rb +7 -9
  29. data/app/models/occams/cms/categorization.rb +2 -4
  30. data/app/models/occams/cms/category.rb +4 -6
  31. data/app/models/occams/cms/file.rb +9 -9
  32. data/app/models/occams/cms/fragment.rb +3 -4
  33. data/app/models/occams/cms/layout.rb +6 -7
  34. data/app/models/occams/cms/page.rb +16 -13
  35. data/app/models/occams/cms/revision.rb +0 -2
  36. data/app/models/occams/cms/site.rb +8 -9
  37. data/app/models/occams/cms/snippet.rb +4 -6
  38. data/app/models/occams/cms/translation.rb +4 -5
  39. data/app/views/layouts/occams/admin/cms/_left.html.haml +4 -0
  40. data/app/views/occams/admin/cms/files/_file.html.haml +1 -1
  41. data/config/application.rb +0 -2
  42. data/config.ru +1 -1
  43. data/lib/generators/occams/cms/assets_generator.rb +0 -2
  44. data/lib/generators/occams/cms/cms_generator.rb +3 -5
  45. data/lib/generators/occams/cms/controllers_generator.rb +0 -2
  46. data/lib/generators/occams/cms/models_generator.rb +0 -2
  47. data/lib/generators/occams/cms/views_generator.rb +0 -2
  48. data/lib/generators/occams/scaffold/scaffold_generator.rb +1 -2
  49. data/lib/occams/access_control/admin_authentication.rb +0 -2
  50. data/lib/occams/access_control/admin_authorization.rb +0 -2
  51. data/lib/occams/access_control/public_authentication.rb +0 -2
  52. data/lib/occams/access_control/public_authorization.rb +0 -2
  53. data/lib/occams/configuration.rb +21 -23
  54. data/lib/occams/content/block.rb +0 -2
  55. data/lib/occams/content/params_parser.rb +9 -11
  56. data/lib/occams/content/renderer.rb +7 -10
  57. data/lib/occams/content/tag.rb +0 -2
  58. data/lib/occams/content/tags/asset.rb +0 -2
  59. data/lib/occams/content/tags/checkbox.rb +0 -2
  60. data/lib/occams/content/tags/date.rb +0 -2
  61. data/lib/occams/content/tags/datetime.rb +0 -2
  62. data/lib/occams/content/tags/file.rb +5 -7
  63. data/lib/occams/content/tags/file_link.rb +1 -2
  64. data/lib/occams/content/tags/files.rb +5 -7
  65. data/lib/occams/content/tags/fragment.rb +0 -2
  66. data/lib/occams/content/tags/helper.rb +0 -2
  67. data/lib/occams/content/tags/markdown.rb +0 -2
  68. data/lib/occams/content/tags/mixins/file_content.rb +1 -2
  69. data/lib/occams/content/tags/number.rb +0 -2
  70. data/lib/occams/content/tags/page_file_link.rb +1 -2
  71. data/lib/occams/content/tags/partial.rb +0 -2
  72. data/lib/occams/content/tags/snippet.rb +0 -2
  73. data/lib/occams/content/tags/template.rb +0 -2
  74. data/lib/occams/content/tags/text.rb +0 -2
  75. data/lib/occams/content/tags/textarea.rb +0 -2
  76. data/lib/occams/content/tags/wysiwyg.rb +0 -2
  77. data/lib/occams/engine.rb +1 -3
  78. data/lib/occams/error.rb +0 -8
  79. data/lib/occams/extensions/acts_as_tree.rb +14 -20
  80. data/lib/occams/extensions/has_revisions.rb +5 -9
  81. data/lib/occams/form_builder.rb +2 -6
  82. data/lib/occams/render_methods.rb +9 -15
  83. data/lib/occams/routes/cms.rb +0 -2
  84. data/lib/occams/routes/cms_admin.rb +1 -3
  85. data/lib/occams/routing.rb +0 -2
  86. data/lib/occams/seeds/file/exporter.rb +2 -4
  87. data/lib/occams/seeds/file/importer.rb +9 -13
  88. data/lib/occams/seeds/layout/exporter.rb +2 -4
  89. data/lib/occams/seeds/layout/importer.rb +3 -5
  90. data/lib/occams/seeds/page/exporter.rb +7 -9
  91. data/lib/occams/seeds/page/importer.rb +3 -5
  92. data/lib/occams/seeds/snippet/exporter.rb +3 -5
  93. data/lib/occams/seeds/snippet/importer.rb +1 -3
  94. data/lib/occams/seeds.rb +1 -7
  95. data/lib/occams/version.rb +1 -3
  96. data/lib/occams/view_hooks.rb +0 -2
  97. data/lib/occams.rb +0 -4
  98. data/lib/tasks/cms_seeds.rake +2 -2
  99. data/occams.gemspec +13 -13
  100. metadata +62 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8dcda75b6239c3fb7e71b35c45c3b5674373bd96d9c14457776af68ff8b1a391
4
- data.tar.gz: 003f1604af55a848c28214b6fcccbb2863ec797adad4515580d933ddb9078c79
3
+ metadata.gz: 2f36d04aa7fd573bb40f6a209c41b7bd49386f3124355425551b984e01e439e9
4
+ data.tar.gz: a45311a36a5eb674f2b0bbb30eecf702db38d7828debd69277b62a8d8af9e08a
5
5
  SHA512:
6
- metadata.gz: 6a7f7f9b4317cefb3961cd916b75f4df6bd8247686f80224926bc5cde93f255e840b567cf506e03112c069e755ffa9810840eff605905fe39ec65471a9c17658
7
- data.tar.gz: 68ed2b0e79500d11ac2c940f4b89c33a894a388b26eec05cfec13d6c28198bc61ec945ad49367df83546d7d40e0b36dab379e6dd4fa6bfca7f206b35424ce964
6
+ metadata.gz: 38fa2734074d1b7415f4a3f00bb6e471a8da1294cf57aead091f5754d020e9f5cd1945eef342b6a1545eb7ee4a3a8d1c8253e9176920bb147c40e236ab581b17
7
+ data.tar.gz: 958e68e0579f56d27709f35b012c197c835a3ab7b14a3b220ff14d4c0c85afdac6787499d3e9b1574cc77af9382c2c245822d29734a1aeedf44978db06c0a087
@@ -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/CHANGELOG.md CHANGED
@@ -1,7 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.0.1 - 8/7/2023
4
+
5
+ - Fixed image thumbnail hover for Rails 7
6
+ - Added display of Rails and Ruby versions along with Occams version at foot of Admin menu
7
+ - Refined gemspec dependencies
8
+ - Tweaked with a bunch of rubocop linting
9
+
3
10
  ## v1.0.0 - 8/5/2023
4
11
 
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
12
+ - Copied the original [ComfortableMexicanSofa](https://github.com/comfy/comfortable-mexican-sofa)
13
+ - Added the changes from [Restarone's fork](https://github.com/restarone/comfortable-mexican-sofa) (23 commits)
14
+ - Added the ability to write snippets in Markdown
data/README.md CHANGED
@@ -92,7 +92,6 @@ Once you have a layout, you may start creating pages and populating content. It'
92
92
  ## ToDos
93
93
 
94
94
  - Linting via current version of rubocop
95
- - Image file thumbnail hover not working on Rails 7
96
95
  - get the original [ComfortableMexicanSofa](https://github.com/comfy/comfortable-mexican-sofa) tests working
97
96
  - add documentation to Occams to replace ComfortableMexicanSofa
98
97
 
@@ -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
@@ -18,5 +17,4 @@ class Occams::Admin::BaseController < Occams.config.admin_base_controller.to_s.c
18
17
  before_action :authenticate
19
18
 
20
19
  layout "occams/admin/cms"
21
-
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
@@ -29,12 +29,12 @@ protected
29
29
  else
30
30
  I18n.locale = Occams.config.admin_locale || I18n.default_locale
31
31
  flash[:danger] = I18n.t("occams.admin.cms.base.site_not_found")
32
- return redirect_to(new_occams_admin_cms_site_path)
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
 
@@ -51,5 +51,4 @@ protected
51
51
  def infer_layout
52
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
 
@@ -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
 
@@ -79,7 +78,6 @@ class Occams::Admin::Cms::FilesController < Occams::Admin::Cms::BaseController
79
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
83
  when "plupload"
@@ -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
 
@@ -65,5 +65,4 @@ protected
65
65
  def layout_params
66
66
  params.fetch(:layout, {}).permit!
67
67
  end
68
-
69
68
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Occams::Admin::Cms::PagesController < Occams::Admin::Cms::BaseController
4
-
5
4
  include ::Occams::ReorderAction
6
5
  self.reorder_action_resource = ::Occams::Cms::Page
7
6
 
@@ -65,9 +64,9 @@ class Occams::Admin::Cms::PagesController < Occams::Admin::Cms::BaseController
65
64
  @page.layout = @site.layouts.find_by(id: params[:layout_id])
66
65
 
67
66
  render(
68
- partial: "occams/admin/cms/fragments/form_fragments",
69
- locals: { record: @page, scope: :page },
70
- layout: false
67
+ partial: "occams/admin/cms/fragments/form_fragments",
68
+ locals: { record: @page, scope: :page },
69
+ layout: false
71
70
  )
72
71
  end
73
72
 
@@ -86,6 +85,7 @@ protected
86
85
  def index_for_redactor
87
86
  tree_walker = ->(page, list, offset) do
88
87
  return unless page.present?
88
+
89
89
  label = "#{'. . ' * offset}#{page.label}"
90
90
  list << { name: label, url: page.url(relative: true) }
91
91
  page.children.each do |child_page|
@@ -152,5 +152,4 @@ protected
152
152
  def page_params
153
153
  params.fetch(:page, {}).permit!
154
154
  end
155
-
156
155
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Occams::Admin::Cms::Revisions::BaseController < Occams::Admin::Cms::BaseController
4
-
5
4
  helper_method :record_path
6
5
 
7
6
  before_action :load_record
@@ -46,5 +45,4 @@ protected
46
45
  def record_path
47
46
  raise "no implemented"
48
47
  end
49
-
50
48
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Occams::Admin::Cms::Revisions::LayoutController < Occams::Admin::Cms::Revisions::BaseController
4
-
5
4
  private
6
5
 
7
6
  def load_record
@@ -14,5 +13,4 @@ private
14
13
  def record_path
15
14
  edit_occams_admin_cms_site_layout_path(@site, @record)
16
15
  end
17
-
18
16
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Occams::Admin::Cms::Revisions::PageController < Occams::Admin::Cms::Revisions::BaseController
4
-
5
4
  def show
6
5
  @current_content = @record.fragments.each_with_object({}) do |b, c|
7
6
  c[b.identifier] = b.content
@@ -26,5 +25,4 @@ private
26
25
  def record_path
27
26
  edit_occams_admin_cms_site_page_path(@site, @record)
28
27
  end
29
-
30
28
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Occams::Admin::Cms::Revisions::SnippetController < Occams::Admin::Cms::Revisions::BaseController
4
-
5
4
  private
6
5
 
7
6
  def load_record
@@ -14,5 +13,4 @@ private
14
13
  def record_path
15
14
  edit_occams_admin_cms_site_snippet_path(@site, @record)
16
15
  end
17
-
18
16
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Occams::Admin::Cms::Revisions::TranslationController < Occams::Admin::Cms::Revisions::BaseController
4
-
5
4
  def show
6
5
  @current_content = @record.fragments.each_with_object({}) do |b, c|
7
6
  c[b.identifier] = b.content
@@ -27,5 +26,4 @@ private
27
26
  def record_path
28
27
  edit_occams_admin_cms_site_page_translation_path(@site, @page, @record)
29
28
  end
30
-
31
29
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Occams::Admin::Cms::SitesController < Occams::Admin::Cms::BaseController
4
-
5
4
  skip_before_action :load_admin_site,
6
5
  :load_seeds
7
6
 
@@ -11,6 +10,7 @@ class Occams::Admin::Cms::SitesController < Occams::Admin::Cms::BaseController
11
10
 
12
11
  def index
13
12
  return redirect_to action: :new if ::Occams::Cms::Site.count.zero?
13
+
14
14
  @site = ::Occams::Cms::Site.find_by_id(session[:site_id])
15
15
  @sites = ::Occams::Cms::Site.all
16
16
  end
@@ -65,5 +65,4 @@ protected
65
65
  def site_params
66
66
  params.fetch(:site, {}).permit!
67
67
  end
68
-
69
68
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Occams::Admin::Cms::SnippetsController < Occams::Admin::Cms::BaseController
4
-
5
4
  include ::Occams::ReorderAction
6
5
  self.reorder_action_resource = ::Occams::Cms::Snippet
7
6
 
@@ -11,6 +10,7 @@ class Occams::Admin::Cms::SnippetsController < Occams::Admin::Cms::BaseControlle
11
10
 
12
11
  def index
13
12
  return redirect_to action: :new if @site.snippets.count.zero?
13
+
14
14
  @snippets = @site.snippets.includes(:categories).for_category(params[:categories]).order(:position)
15
15
  end
16
16
 
@@ -62,5 +62,4 @@ protected
62
62
  def snippet_params
63
63
  params.fetch(:snippet, {}).permit!
64
64
  end
65
-
66
65
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Occams::Admin::Cms::TranslationsController < Occams::Admin::Cms::BaseController
4
-
5
4
  helper_method :translation_select_options
6
5
 
7
6
  before_action :load_page
@@ -47,9 +46,9 @@ class Occams::Admin::Cms::TranslationsController < Occams::Admin::Cms::BaseContr
47
46
  @translation.layout = @site.layouts.find_by(id: params[:layout_id])
48
47
 
49
48
  render(
50
- partial: "occams/admin/cms/fragments/form_fragments",
51
- locals: { record: @translation, scope: :translation },
52
- layout: false
49
+ partial: "occams/admin/cms/fragments/form_fragments",
50
+ locals: { record: @translation, scope: :translation },
51
+ layout: false
53
52
  )
54
53
  end
55
54
 
@@ -103,5 +102,4 @@ private
103
102
  render inline: @translation.render, layout: layout, content_type: "text/html"
104
103
  end
105
104
  end
106
-
107
105
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Occams::Cms::AssetsController < Occams::Cms::BaseController
4
-
5
4
  skip_before_action :verify_authenticity_token, raise: false
6
5
 
7
6
  before_action :load_cms_layout,
@@ -36,5 +35,4 @@ protected
36
35
  response.headers["Cache-Control"] = "public, max-age=#{1.year.to_i}"
37
36
  end
38
37
  end
39
-
40
38
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Occams::Cms::BaseController < Occams.config.public_base_controller.to_s.constantize
4
-
5
4
  before_action :load_cms_site
6
5
 
7
6
  helper Occams::CmsHelper
@@ -29,5 +28,4 @@ protected
29
28
  raise ActionController::RoutingError, "Site Not Found"
30
29
  end
31
30
  end
32
-
33
31
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Occams::Cms::ContentController < Occams::Cms::BaseController
4
-
5
4
  # Authentication module must have `authenticate` method
6
5
  include Occams.config.public_auth.to_s.constantize
7
6
 
@@ -35,9 +34,9 @@ class Occams::Cms::ContentController < Occams::Cms::BaseController
35
34
  protected
36
35
 
37
36
  def render_page(status = :ok)
38
- render inline: @cms_page.content_cache,
39
- layout: app_layout,
40
- status: status,
37
+ render inline: @cms_page.content_cache,
38
+ layout: app_layout,
39
+ status: status,
41
40
  content_type: mime_type
42
41
  end
43
42
 
@@ -49,11 +48,13 @@ protected
49
48
 
50
49
  def app_layout
51
50
  return false if request.xhr? || !@cms_layout
51
+
52
52
  @cms_layout.app_layout.present? ? @cms_layout.app_layout : false
53
53
  end
54
54
 
55
55
  def load_seeds
56
56
  return unless Occams.config.enable_seeds
57
+
57
58
  Occams::Seeds::Importer.new(@cms_site.identifier).import!
58
59
  end
59
60
 
@@ -79,9 +80,7 @@ protected
79
80
  @cms_layout = @cms_page.layout
80
81
 
81
82
  @cms_page
82
-
83
83
  rescue ActiveRecord::RecordNotFound
84
84
  nil
85
85
  end
86
-
87
86
  end
@@ -3,7 +3,6 @@
3
3
  module Occams
4
4
  module Admin
5
5
  module CmsHelper
6
-
7
6
  # Wrapper around Occams::FormBuilder
8
7
  def occams_form_with(**options, &block)
9
8
  form_options = options.merge(builder: Occams::FormBuilder)
@@ -43,7 +42,6 @@ module Occams
43
42
  as = ", as: image" if file.attachment.image?
44
43
  "{{ cms:file_link #{file.id}#{as} }}"
45
44
  end
46
-
47
45
  end
48
46
  end
49
47
  end
@@ -2,7 +2,6 @@
2
2
 
3
3
  module Occams
4
4
  module CmsHelper
5
-
6
5
  # Raw content of a page fragment. This is how you get content from unrenderable
7
6
  # tags like {{cms:fragment meta, render: false}}
8
7
  # Example:
@@ -11,6 +10,7 @@ module Occams
11
10
  def cms_fragment_content(identifier, page = @cms_page)
12
11
  frag = page&.fragments&.detect { |f| f.identifier == identifier.to_s }
13
12
  return "" unless frag
13
+
14
14
  case frag.tag
15
15
  when "date", "datetime"
16
16
  frag.datetime
@@ -29,6 +29,7 @@ module Occams
29
29
  def cms_fragment_render(identifier, page = @cms_page)
30
30
  node = page.fragment_nodes.detect { |n| n.identifier == identifier.to_s }
31
31
  return "" unless node
32
+
32
33
  node.renderable = true
33
34
  render inline: page.render([node])
34
35
  end
@@ -40,6 +41,7 @@ module Occams
40
41
  cms_site ||= cms_site_detect
41
42
  snippet = cms_site&.snippets&.find_by_identifier(identifier)
42
43
  return "" unless snippet
44
+
43
45
  snippet.content
44
46
  end
45
47
 
@@ -49,6 +51,7 @@ module Occams
49
51
  cms_site ||= cms_site_detect
50
52
  snippet = cms_site&.snippets&.find_by_identifier(identifier)
51
53
  return "" unless snippet
54
+
52
55
  r = Occams::Content::Renderer.new(snippet)
53
56
  render inline: r.render(r.nodes(r.tokenize(snippet.content)))
54
57
  end
@@ -62,12 +65,12 @@ module Occams
62
65
  # Wrapper to deal with Kaminari vs WillPaginate
63
66
  def occams_paginate(collection)
64
67
  return unless collection
68
+
65
69
  if defined?(WillPaginate)
66
70
  will_paginate collection
67
71
  elsif defined?(Kaminari)
68
72
  paginate collection, theme: "occams"
69
73
  end
70
74
  end
71
-
72
75
  end
73
76
  end
@@ -1,17 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Occams::Cms::WithCategories
4
-
5
4
  extend ActiveSupport::Concern
6
5
 
7
6
  included do
8
7
  has_many :categorizations,
9
- as: :categorized,
10
- class_name: "Occams::Cms::Categorization",
11
- dependent: :destroy
8
+ as: :categorized,
9
+ class_name: "Occams::Cms::Categorization",
10
+ dependent: :destroy
12
11
  has_many :categories,
13
- through: :categorizations,
14
- class_name: "Occams::Cms::Category"
12
+ through: :categorizations,
13
+ class_name: "Occams::Cms::Category"
15
14
 
16
15
  attr_writer :category_ids
17
16
 
@@ -49,5 +48,4 @@ module Occams::Cms::WithCategories
49
48
  ids_to_remove = existing_ids - ids_to_add
50
49
  categorizations.where(category_id: ids_to_remove).destroy_all
51
50
  end
52
-
53
51
  end
@@ -1,25 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Occams::Cms::WithFragments
4
-
5
4
  extend ActiveSupport::Concern
6
5
 
7
6
  included do
8
7
  attr_accessor :fragments_attributes_changed
9
8
 
10
9
  belongs_to :layout,
11
- class_name: "Occams::Cms::Layout"
10
+ class_name: "Occams::Cms::Layout"
12
11
 
13
12
  has_many :fragments,
14
- class_name: "Occams::Cms::Fragment",
15
- as: :record,
16
- autosave: true,
17
- dependent: :destroy
13
+ class_name: "Occams::Cms::Fragment",
14
+ as: :record,
15
+ autosave: true,
16
+ dependent: :destroy
18
17
 
19
18
  before_save :clear_content_cache
20
19
 
21
20
  validates :layout,
22
- presence: true
21
+ presence: true
23
22
  end
24
23
 
25
24
  # Array of fragment hashes in the following format:
@@ -54,7 +53,7 @@ module Occams::Cms::WithFragments
54
53
  end
55
54
 
56
55
  # Snapshop of page fragments data used primarily for saving revisions
57
- def fragments_attributes(was = false)
56
+ def fragments_attributes(was: false)
58
57
  fragments.collect do |frag|
59
58
  attrs = {}
60
59
  %i[identifier tag content datetime boolean].each do |column|
@@ -121,5 +120,4 @@ protected
121
120
  tokens = layout.content_tokens
122
121
  renderer.nodes(tokens)
123
122
  end
124
-
125
123
  end
@@ -1,16 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Occams::Cms::Categorization < ActiveRecord::Base
4
-
5
4
  self.table_name = "occams_cms_categorizations"
6
5
 
7
6
  # -- Relationships -----------------------------------------------------------
8
7
  belongs_to :category
9
8
  belongs_to :categorized,
10
- polymorphic: true
9
+ polymorphic: true
11
10
 
12
11
  # -- Validations -------------------------------------------------------------
13
12
  validates :category_id,
14
- uniqueness: { scope: %i[categorized_type categorized_id] }
15
-
13
+ uniqueness: { scope: %i[categorized_type categorized_id] }
16
14
  end
@@ -1,24 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Occams::Cms::Category < ActiveRecord::Base
4
-
5
4
  self.table_name = "occams_cms_categories"
6
5
 
7
6
  # -- Relationships --------------------------------------------------------
8
7
  belongs_to :site
9
8
  has_many :categorizations,
10
- dependent: :destroy
9
+ dependent: :destroy
11
10
 
12
11
  # -- Validations ----------------------------------------------------------
13
12
  validates :label,
14
- presence: true,
15
- uniqueness: { scope: %i[categorized_type site_id] }
13
+ presence: true,
14
+ uniqueness: { scope: %i[categorized_type site_id] }
16
15
  validates :categorized_type,
17
- presence: true
16
+ presence: true
18
17
 
19
18
  # -- Scopes ---------------------------------------------------------------
20
19
  scope :of_type, ->(type) {
21
20
  where(categorized_type: type)
22
21
  }
23
-
24
22
  end