occams 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/issue_template.md +2 -4
- data/CHANGELOG.md +10 -3
- data/README.md +0 -1
- data/app/controllers/application_controller.rb +0 -2
- data/app/controllers/concerns/occams/paginate.rb +0 -2
- data/app/controllers/concerns/occams/reorder_action.rb +0 -2
- data/app/controllers/occams/admin/base_controller.rb +0 -2
- data/app/controllers/occams/admin/cms/base_controller.rb +3 -4
- data/app/controllers/occams/admin/cms/categories_controller.rb +0 -2
- data/app/controllers/occams/admin/cms/files_controller.rb +4 -7
- data/app/controllers/occams/admin/cms/layouts_controller.rb +1 -2
- data/app/controllers/occams/admin/cms/pages_controller.rb +4 -5
- data/app/controllers/occams/admin/cms/revisions/base_controller.rb +0 -2
- data/app/controllers/occams/admin/cms/revisions/layout_controller.rb +0 -2
- data/app/controllers/occams/admin/cms/revisions/page_controller.rb +0 -2
- data/app/controllers/occams/admin/cms/revisions/snippet_controller.rb +0 -2
- data/app/controllers/occams/admin/cms/revisions/translation_controller.rb +0 -2
- data/app/controllers/occams/admin/cms/sites_controller.rb +1 -2
- data/app/controllers/occams/admin/cms/snippets_controller.rb +1 -2
- data/app/controllers/occams/admin/cms/translations_controller.rb +3 -5
- data/app/controllers/occams/cms/assets_controller.rb +0 -2
- data/app/controllers/occams/cms/base_controller.rb +0 -2
- data/app/controllers/occams/cms/content_controller.rb +5 -6
- data/app/helpers/occams/admin/cms_helper.rb +0 -2
- data/app/helpers/occams/cms_helper.rb +5 -2
- data/app/models/concerns/occams/cms/with_categories.rb +5 -7
- data/app/models/concerns/occams/cms/with_fragments.rb +7 -9
- data/app/models/occams/cms/categorization.rb +2 -4
- data/app/models/occams/cms/category.rb +4 -6
- data/app/models/occams/cms/file.rb +9 -9
- data/app/models/occams/cms/fragment.rb +3 -4
- data/app/models/occams/cms/layout.rb +6 -7
- data/app/models/occams/cms/page.rb +16 -13
- data/app/models/occams/cms/revision.rb +0 -2
- data/app/models/occams/cms/site.rb +8 -9
- data/app/models/occams/cms/snippet.rb +4 -6
- data/app/models/occams/cms/translation.rb +4 -5
- data/app/views/layouts/occams/admin/cms/_left.html.haml +4 -0
- data/app/views/occams/admin/cms/files/_file.html.haml +1 -1
- data/config/application.rb +0 -2
- data/config.ru +1 -1
- data/lib/generators/occams/cms/assets_generator.rb +0 -2
- data/lib/generators/occams/cms/cms_generator.rb +3 -5
- data/lib/generators/occams/cms/controllers_generator.rb +0 -2
- data/lib/generators/occams/cms/models_generator.rb +0 -2
- data/lib/generators/occams/cms/views_generator.rb +0 -2
- data/lib/generators/occams/scaffold/scaffold_generator.rb +1 -2
- data/lib/occams/access_control/admin_authentication.rb +0 -2
- data/lib/occams/access_control/admin_authorization.rb +0 -2
- data/lib/occams/access_control/public_authentication.rb +0 -2
- data/lib/occams/access_control/public_authorization.rb +0 -2
- data/lib/occams/configuration.rb +21 -23
- data/lib/occams/content/block.rb +0 -2
- data/lib/occams/content/params_parser.rb +9 -11
- data/lib/occams/content/renderer.rb +7 -10
- data/lib/occams/content/tag.rb +0 -2
- data/lib/occams/content/tags/asset.rb +0 -2
- data/lib/occams/content/tags/checkbox.rb +0 -2
- data/lib/occams/content/tags/date.rb +0 -2
- data/lib/occams/content/tags/datetime.rb +0 -2
- data/lib/occams/content/tags/file.rb +5 -7
- data/lib/occams/content/tags/file_link.rb +1 -2
- data/lib/occams/content/tags/files.rb +5 -7
- data/lib/occams/content/tags/fragment.rb +0 -2
- data/lib/occams/content/tags/helper.rb +0 -2
- data/lib/occams/content/tags/markdown.rb +0 -2
- data/lib/occams/content/tags/mixins/file_content.rb +1 -2
- data/lib/occams/content/tags/number.rb +0 -2
- data/lib/occams/content/tags/page_file_link.rb +1 -2
- data/lib/occams/content/tags/partial.rb +0 -2
- data/lib/occams/content/tags/snippet.rb +0 -2
- data/lib/occams/content/tags/template.rb +0 -2
- data/lib/occams/content/tags/text.rb +0 -2
- data/lib/occams/content/tags/textarea.rb +0 -2
- data/lib/occams/content/tags/wysiwyg.rb +0 -2
- data/lib/occams/engine.rb +1 -3
- data/lib/occams/error.rb +0 -8
- data/lib/occams/extensions/acts_as_tree.rb +14 -20
- data/lib/occams/extensions/has_revisions.rb +5 -9
- data/lib/occams/form_builder.rb +2 -6
- data/lib/occams/render_methods.rb +9 -15
- data/lib/occams/routes/cms.rb +0 -2
- data/lib/occams/routes/cms_admin.rb +1 -3
- data/lib/occams/routing.rb +0 -2
- data/lib/occams/seeds/file/exporter.rb +2 -4
- data/lib/occams/seeds/file/importer.rb +9 -13
- data/lib/occams/seeds/layout/exporter.rb +2 -4
- data/lib/occams/seeds/layout/importer.rb +3 -5
- data/lib/occams/seeds/page/exporter.rb +7 -9
- data/lib/occams/seeds/page/importer.rb +3 -5
- data/lib/occams/seeds/snippet/exporter.rb +3 -5
- data/lib/occams/seeds/snippet/importer.rb +1 -3
- data/lib/occams/seeds.rb +1 -7
- data/lib/occams/version.rb +1 -3
- data/lib/occams/view_hooks.rb +0 -2
- data/lib/occams.rb +0 -4
- data/lib/tasks/cms_seeds.rake +2 -2
- data/occams.gemspec +13 -13
- metadata +62 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f36d04aa7fd573bb40f6a209c41b7bd49386f3124355425551b984e01e439e9
|
4
|
+
data.tar.gz: a45311a36a5eb674f2b0bbb30eecf702db38d7828debd69277b62a8d8af9e08a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38fa2734074d1b7415f4a3f00bb6e471a8da1294cf57aead091f5754d020e9f5cd1945eef342b6a1545eb7ee4a3a8d1c8253e9176920bb147c40e236ab581b17
|
7
|
+
data.tar.gz: 958e68e0579f56d27709f35b012c197c835a3ab7b14a3b220ff14d4c0c85afdac6787499d3e9b1574cc77af9382c2c245822d29734a1aeedf44978db06c0a087
|
data/.github/issue_template.md
CHANGED
@@ -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
|
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
|
-
-
|
6
|
-
-
|
7
|
-
-
|
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,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
|
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
|
-
|
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 ||
|
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:
|
33
|
-
name:
|
34
|
-
link:
|
35
|
-
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:
|
69
|
-
locals:
|
70
|
-
layout:
|
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:
|
51
|
-
locals:
|
52
|
-
layout:
|
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:
|
39
|
-
layout:
|
40
|
-
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
|
-
|
10
|
-
|
11
|
-
|
8
|
+
as: :categorized,
|
9
|
+
class_name: "Occams::Cms::Categorization",
|
10
|
+
dependent: :destroy
|
12
11
|
has_many :categories,
|
13
|
-
|
14
|
-
|
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
|
-
|
10
|
+
class_name: "Occams::Cms::Layout"
|
12
11
|
|
13
12
|
has_many :fragments,
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
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
|
-
|
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
|
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
|
-
|
9
|
+
polymorphic: true
|
11
10
|
|
12
11
|
# -- Validations -------------------------------------------------------------
|
13
12
|
validates :category_id,
|
14
|
-
|
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
|
-
|
9
|
+
dependent: :destroy
|
11
10
|
|
12
11
|
# -- Validations ----------------------------------------------------------
|
13
12
|
validates :label,
|
14
|
-
|
15
|
-
|
13
|
+
presence: true,
|
14
|
+
uniqueness: { scope: %i[categorized_type site_id] }
|
16
15
|
validates :categorized_type,
|
17
|
-
|
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
|