comfy_middle_seat 3.2.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/coveralls.yml +4 -0
- data/CHANGELOG.md +56 -3
- data/CONTRIBUTING.md +8 -5
- data/Gemfile +1 -1
- data/README.md +66 -29
- data/Rakefile +3 -3
- data/app/assets/javascripts/comfy/admin/cms/application.js +2 -0
- data/app/assets/javascripts/comfy/admin/cms/base.js +6 -1
- data/app/assets/javascripts/comfy/admin/cms/codemirror.js +17 -0
- data/app/assets/javascripts/comfy/admin/cms/dirty_forms.js +201 -0
- data/app/assets/javascripts/comfy/admin/cms/draft_forms.js +468 -0
- data/app/assets/javascripts/comfy/admin/cms/page_fragments.js +393 -22
- data/app/assets/javascripts/comfy/admin/cms/wysiwyg.js +21 -0
- data/app/assets/javascripts/comfy/vendor/redactor/filemanager.js +48 -30
- data/app/assets/javascripts/comfy/vendor/redactor/imagemanager.js +43 -25
- data/app/assets/stylesheets/comfy/admin/cms/base.sass +23 -0
- data/app/controllers/comfy/admin/base_controller.rb +3 -3
- data/app/controllers/comfy/admin/cms/base_controller.rb +12 -7
- data/app/controllers/comfy/admin/cms/files_controller.rb +1 -1
- data/app/controllers/comfy/admin/cms/pages_controller.rb +76 -16
- data/app/controllers/comfy/admin/cms/revisions/base_controller.rb +39 -1
- data/app/controllers/comfy/admin/cms/revisions/page_controller.rb +9 -8
- data/app/controllers/comfy/admin/cms/revisions/translation_controller.rb +14 -8
- data/app/controllers/comfy/admin/cms/sites_controller.rb +1 -1
- data/app/controllers/comfy/admin/cms/translations_controller.rb +3 -1
- data/app/controllers/comfy/cms/base_controller.rb +1 -1
- data/app/controllers/comfy/cms/content_controller.rb +5 -5
- data/app/controllers/concerns/comfy/reorder_action.rb +24 -4
- data/app/helpers/comfy/admin/cms_helper.rb +28 -3
- data/app/helpers/comfy/cms_helper.rb +1 -1
- data/app/models/comfy/cms/file.rb +25 -3
- data/app/models/comfy/cms/layout.rb +8 -6
- data/app/models/comfy/cms/page.rb +22 -0
- data/app/models/comfy/cms/site.rb +3 -3
- data/app/models/comfy/cms/snippet.rb +8 -3
- data/app/models/concerns/comfy/cms/with_fragments.rb +2 -2
- data/app/views/comfy/admin/cms/categories/_index.html.haml +1 -1
- data/app/views/comfy/admin/cms/categories/_show.html.haml +1 -1
- data/app/views/comfy/admin/cms/files/_file.html.haml +1 -1
- data/app/views/comfy/admin/cms/files/index.html.haml +9 -2
- data/app/views/comfy/admin/cms/fragments/_form_fragments.html.haml +2 -2
- data/app/views/comfy/admin/cms/pages/_form.html.haml +2 -1
- data/app/views/comfy/admin/cms/pages/_index_branch.html.haml +11 -10
- data/app/views/comfy/admin/cms/pages/edit.html.haml +3 -1
- data/app/views/comfy/admin/cms/pages/index.html.haml +9 -2
- data/app/views/comfy/admin/cms/pages/new.html.haml +3 -1
- data/app/views/comfy/admin/cms/pages/toggle_branch.js.erb +2 -2
- data/app/views/comfy/admin/cms/revisions/show.html.haml +25 -7
- data/app/views/comfy/admin/cms/shared/_search.html.haml +9 -0
- data/app/views/comfy/admin/cms/sites/_form.html.haml +1 -1
- data/app/views/comfy/admin/cms/translations/_form.html.haml +2 -1
- data/app/views/comfy/admin/cms/translations/edit.html.haml +3 -1
- data/app/views/comfy/admin/cms/translations/new.html.haml +3 -1
- data/app/views/layouts/comfy/admin/cms/_flash.html.haml +1 -1
- data/app/views/layouts/comfy/admin/cms/_head.html.haml +3 -1
- data/app/views/layouts/comfy/admin/cms/_left.html.haml +2 -2
- data/comfy_middle_seat.gemspec +10 -5
- data/config/application.rb +3 -2
- data/config/cms_routes.rb +1 -1
- data/config/environment.rb +1 -1
- data/config/environments/development.rb +1 -1
- data/config/environments/production.rb +1 -1
- data/config/environments/test.rb +1 -1
- data/config/initializers/{comfortable_media_surfer.rb → comfy_middle_seat.rb} +4 -4
- data/config/locales/ar.yml +14 -0
- data/config/locales/ca.yml +14 -0
- data/config/locales/cs.yml +14 -0
- data/config/locales/da.yml +14 -0
- data/config/locales/de.yml +14 -0
- data/config/locales/en.yml +14 -0
- data/config/locales/es.yml +14 -0
- data/config/locales/fi.yml +14 -0
- data/config/locales/fr.yml +14 -0
- data/config/locales/gr.yml +14 -0
- data/config/locales/hr.yml +14 -0
- data/config/locales/it.yml +14 -0
- data/config/locales/ja.yml +14 -0
- data/config/locales/nb.yml +14 -0
- data/config/locales/nl.yml +14 -0
- data/config/locales/pl.yml +14 -0
- data/config/locales/pt-BR.yml +14 -0
- data/config/locales/ru.yml +14 -0
- data/config/locales/sk.yml +14 -0
- data/config/locales/sv.yml +14 -0
- data/config/locales/tr.yml +14 -0
- data/config/locales/uk.yml +14 -0
- data/config/locales/zh-CN.yml +14 -0
- data/config/locales/zh-TW.yml +14 -0
- data/config.ru +1 -1
- data/exe/comfy-middle-seat-upgrade +34 -0
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/access_control/admin_authentication.rb +4 -4
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/access_control/admin_authorization.rb +1 -1
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/access_control/public_authentication.rb +1 -1
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/access_control/public_authorization.rb +1 -1
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/configuration.rb +7 -7
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/block.rb +1 -1
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/params_parser.rb +1 -1
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/renderer.rb +10 -10
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tag.rb +4 -4
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/asset.rb +4 -4
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/audio.rb +3 -3
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/breadcrumbs.rb +3 -3
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/checkbox.rb +3 -3
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/children.rb +3 -3
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/date.rb +3 -3
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/datetime.rb +3 -3
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/file.rb +5 -5
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/file_link.rb +4 -4
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/files.rb +3 -3
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/fragment.rb +2 -2
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/helper.rb +4 -4
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/image.rb +4 -4
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/markdown.rb +3 -3
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/mixins/file_content.rb +1 -1
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/number.rb +3 -3
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/page_file_link.rb +5 -5
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/partial.rb +4 -4
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/siblings.rb +3 -3
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/snippet.rb +3 -3
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/template.rb +4 -4
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/text.rb +3 -3
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/textarea.rb +3 -3
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/wysiwyg.rb +3 -3
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags.rb +1 -1
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/content.rb +1 -1
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/engine.rb +4 -4
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/error.rb +4 -4
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/extensions/acts_as_tree.rb +3 -3
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/extensions/has_revisions.rb +4 -4
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/extensions.rb +1 -1
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/form_builder.rb +2 -2
- data/lib/comfy_middle_seat/initializer_upgrader.rb +115 -0
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/render_methods.rb +7 -7
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/routing.rb +3 -2
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/seeds/file/exporter.rb +5 -5
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/seeds/file/importer.rb +5 -5
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/seeds/layout/exporter.rb +4 -4
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/seeds/layout/importer.rb +5 -5
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/seeds/page/exporter.rb +5 -5
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/seeds/page/importer.rb +7 -7
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/seeds/snippet/exporter.rb +4 -4
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/seeds/snippet/importer.rb +5 -5
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/seeds.rb +4 -4
- data/lib/comfy_middle_seat/version.rb +2 -2
- data/lib/{comfortable_media_surfer → comfy_middle_seat}/view_hooks.rb +2 -2
- data/lib/comfy_middle_seat.rb +54 -1
- data/lib/generators/comfy/cms/README +3 -11
- data/lib/generators/comfy/cms/cms_generator.rb +2 -2
- data/lib/generators/comfy/scaffold/templates/tests/controller.rb.tt +2 -2
- data/lib/tasks/cms_seeds.rake +8 -8
- data/package-lock.json +2 -2
- data/package.json +1 -1
- metadata +68 -62
- data/lib/comfortable_media_surfer/version.rb +0 -3
- data/lib/comfortable_media_surfer.rb +0 -56
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
# `namespace`:
|
|
9
9
|
# Just a string that allows grouping of form elements in the admin area
|
|
10
10
|
#
|
|
11
|
-
class
|
|
11
|
+
class ComfyMiddleSeat::Content::Tags::Fragment < ComfyMiddleSeat::Content::Tag
|
|
12
12
|
attr_accessor :renderable
|
|
13
13
|
attr_reader :identifier, :namespace
|
|
14
14
|
|
|
@@ -48,7 +48,7 @@ class ComfortableMediaSurfer::Content::Tags::Fragment < ComfortableMediaSurfer::
|
|
|
48
48
|
|
|
49
49
|
# Tag renders its own form inputs via `form_field(template, index)`
|
|
50
50
|
# For example:
|
|
51
|
-
# class MyTag <
|
|
51
|
+
# class MyTag < ComfyMiddleSeat::Content::Tags::Fragment
|
|
52
52
|
# def form_field(view, index, &block)
|
|
53
53
|
# # omit yield if you don't want default wrapper
|
|
54
54
|
# yield view.text_area "input_name", "value"
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
# Whitelist is can be used to control what helpers are available.
|
|
8
8
|
# By default there's a blacklist of methods that should not be called.
|
|
9
9
|
#
|
|
10
|
-
class
|
|
10
|
+
class ComfyMiddleSeat::Content::Tags::Helper < ComfyMiddleSeat::Content::Tag
|
|
11
11
|
BLACKLIST = %w[eval class_eval instance_eval render].freeze
|
|
12
12
|
|
|
13
13
|
attr_reader :method_name
|
|
@@ -39,7 +39,7 @@ class ComfortableMediaSurfer::Content::Tags::Helper < ComfortableMediaSurfer::Co
|
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def render
|
|
42
|
-
whitelist =
|
|
42
|
+
whitelist = ComfyMiddleSeat.config.allowed_helpers
|
|
43
43
|
if whitelist.is_a?(Array)
|
|
44
44
|
content if whitelist.map!(&:to_s).member?(method_name)
|
|
45
45
|
else
|
|
@@ -48,6 +48,6 @@ class ComfortableMediaSurfer::Content::Tags::Helper < ComfortableMediaSurfer::Co
|
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
:helper,
|
|
51
|
+
ComfyMiddleSeat::Content::Renderer.register_tag(
|
|
52
|
+
:helper, ComfyMiddleSeat::Content::Tags::Helper
|
|
53
53
|
)
|
|
@@ -14,8 +14,8 @@ require_relative 'mixins/file_content'
|
|
|
14
14
|
# `gravity` - imagemagick option. For example: "center"
|
|
15
15
|
# `crop` - imagemagick option. For example: "100x50+0+0"
|
|
16
16
|
|
|
17
|
-
class
|
|
18
|
-
include
|
|
17
|
+
class ComfyMiddleSeat::Content::Tags::Image < ComfyMiddleSeat::Content::Tag
|
|
18
|
+
include ComfyMiddleSeat::Content::Tags::Mixins::FileContent
|
|
19
19
|
|
|
20
20
|
attr_reader :identifier, :as, :variant_attrs
|
|
21
21
|
|
|
@@ -51,6 +51,6 @@ class ComfortableMediaSurfer::Content::Tags::Image < ComfortableMediaSurfer::Con
|
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
:image,
|
|
54
|
+
ComfyMiddleSeat::Content::Renderer.register_tag(
|
|
55
|
+
:image, ComfyMiddleSeat::Content::Tags::Image
|
|
56
56
|
)
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# Tag for text content that is going to be rendered using textarea with markdown
|
|
4
4
|
# {{ cms:markdown identifier }}
|
|
5
5
|
#
|
|
6
|
-
class
|
|
6
|
+
class ComfyMiddleSeat::Content::Tags::Markdown < ComfyMiddleSeat::Content::Tags::Fragment
|
|
7
7
|
def render
|
|
8
8
|
renderable ? Kramdown::Document.new(content.to_s).to_html : ''
|
|
9
9
|
end
|
|
@@ -17,6 +17,6 @@ class ComfortableMediaSurfer::Content::Tags::Markdown < ComfortableMediaSurfer::
|
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
:markdown,
|
|
20
|
+
ComfyMiddleSeat::Content::Renderer.register_tag(
|
|
21
|
+
:markdown, ComfyMiddleSeat::Content::Tags::Markdown
|
|
22
22
|
)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
# A mixin for tags that returns the file as their content.
|
|
4
|
-
module
|
|
4
|
+
module ComfyMiddleSeat::Content::Tags::Mixins
|
|
5
5
|
module FileContent
|
|
6
6
|
# @param [ActiveStorage::Blob] file
|
|
7
7
|
# @param ["link", "image", "url"] as
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# Tag for text content that is going to be rendered using number input
|
|
4
4
|
# {{ cms:number identifier }}
|
|
5
5
|
#
|
|
6
|
-
class
|
|
6
|
+
class ComfyMiddleSeat::Content::Tags::Number < ComfyMiddleSeat::Content::Tags::Fragment
|
|
7
7
|
def form_field(object_name, view, index)
|
|
8
8
|
name = "#{object_name}[fragments_attributes][#{index}][content]"
|
|
9
9
|
options = { id: form_field_id, class: 'form-control' }
|
|
@@ -13,6 +13,6 @@ class ComfortableMediaSurfer::Content::Tags::Number < ComfortableMediaSurfer::Co
|
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
:number,
|
|
16
|
+
ComfyMiddleSeat::Content::Renderer.register_tag(
|
|
17
|
+
:number, ComfyMiddleSeat::Content::Tags::Number
|
|
18
18
|
)
|
|
@@ -25,8 +25,8 @@ require_relative 'mixins/file_content'
|
|
|
25
25
|
# `gravity` - imagemagick option. For example: "center"
|
|
26
26
|
# `crop` - imagemagick option. For example: "100x50+0+0"
|
|
27
27
|
#
|
|
28
|
-
class
|
|
29
|
-
include
|
|
28
|
+
class ComfyMiddleSeat::Content::Tags::PageFileLink < ComfyMiddleSeat::Content::Tag
|
|
29
|
+
include ComfyMiddleSeat::Content::Tags::Mixins::FileContent
|
|
30
30
|
|
|
31
31
|
# @return [String] A `cms:file(s)` identifier.
|
|
32
32
|
attr_reader :identifier
|
|
@@ -40,7 +40,7 @@ class ComfortableMediaSurfer::Content::Tags::PageFileLink < ComfortableMediaSurf
|
|
|
40
40
|
# @return [String] Used to refer to a file in a {{ cms:files }} tag.
|
|
41
41
|
attr_reader :filename
|
|
42
42
|
|
|
43
|
-
# @param (see
|
|
43
|
+
# @param (see ComfyMiddleSeat::Content::Tag#initialize)
|
|
44
44
|
def initialize(context:, params: [], source: nil)
|
|
45
45
|
super
|
|
46
46
|
|
|
@@ -81,6 +81,6 @@ class ComfortableMediaSurfer::Content::Tags::PageFileLink < ComfortableMediaSurf
|
|
|
81
81
|
end
|
|
82
82
|
end
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
:page_file_link,
|
|
84
|
+
ComfyMiddleSeat::Content::Renderer.register_tag(
|
|
85
|
+
:page_file_link, ComfyMiddleSeat::Content::Tags::PageFileLink
|
|
86
86
|
)
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# <%= render partial: "path/to/partial", locals: {foo: bar, zip: zoop} %>
|
|
7
7
|
# Whitelist is can be used to control what partials are renderable.
|
|
8
8
|
#
|
|
9
|
-
class
|
|
9
|
+
class ComfyMiddleSeat::Content::Tags::Partial < ComfyMiddleSeat::Content::Tag
|
|
10
10
|
attr_reader :path, :locals
|
|
11
11
|
|
|
12
12
|
def initialize(context:, params: [], source: nil)
|
|
@@ -33,7 +33,7 @@ class ComfortableMediaSurfer::Content::Tags::Partial < ComfortableMediaSurfer::C
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
def render
|
|
36
|
-
whitelist =
|
|
36
|
+
whitelist = ComfyMiddleSeat.config.allowed_partials
|
|
37
37
|
if whitelist.is_a?(Array)
|
|
38
38
|
whitelist.member?(@path) ? content : ''
|
|
39
39
|
else
|
|
@@ -42,6 +42,6 @@ class ComfortableMediaSurfer::Content::Tags::Partial < ComfortableMediaSurfer::C
|
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
:partial,
|
|
45
|
+
ComfyMiddleSeat::Content::Renderer.register_tag(
|
|
46
|
+
:partial, ComfyMiddleSeat::Content::Tags::Partial
|
|
47
47
|
)
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
#
|
|
18
18
|
# style and exclude parameters are optional
|
|
19
19
|
|
|
20
|
-
class
|
|
20
|
+
class ComfyMiddleSeat::Content::Tags::Siblings < ComfyMiddleSeat::Content::Tag
|
|
21
21
|
attr_reader :locals, :style, :sibs
|
|
22
22
|
attr_accessor :links
|
|
23
23
|
|
|
@@ -61,6 +61,6 @@ class ComfortableMediaSurfer::Content::Tags::Siblings < ComfortableMediaSurfer::
|
|
|
61
61
|
end
|
|
62
62
|
end
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
:siblings,
|
|
64
|
+
ComfyMiddleSeat::Content::Renderer.register_tag(
|
|
65
|
+
:siblings, ComfyMiddleSeat::Content::Tags::Siblings
|
|
66
66
|
)
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# {{cms:snippet identifier}}
|
|
5
5
|
# Snippets may have more tags in them like fragments, so they may be expanded too.
|
|
6
6
|
#
|
|
7
|
-
class
|
|
7
|
+
class ComfyMiddleSeat::Content::Tags::Snippet < ComfyMiddleSeat::Content::Tag
|
|
8
8
|
attr_reader :identifier
|
|
9
9
|
|
|
10
10
|
def initialize(context:, params: [], source: nil)
|
|
@@ -31,6 +31,6 @@ class ComfortableMediaSurfer::Content::Tags::Snippet < ComfortableMediaSurfer::C
|
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
:snippet,
|
|
34
|
+
ComfyMiddleSeat::Content::Renderer.register_tag(
|
|
35
|
+
:snippet, ComfyMiddleSeat::Content::Tags::Snippet
|
|
36
36
|
)
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# <%= render template: "template/path" %>
|
|
7
7
|
# Whitelist is can be used to control what templates are available.
|
|
8
8
|
#
|
|
9
|
-
class
|
|
9
|
+
class ComfyMiddleSeat::Content::Tags::Template < ComfyMiddleSeat::Content::Tag
|
|
10
10
|
attr_reader :path
|
|
11
11
|
|
|
12
12
|
def initialize(context:, params: [], source: nil)
|
|
@@ -28,7 +28,7 @@ class ComfortableMediaSurfer::Content::Tags::Template < ComfortableMediaSurfer::
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
def render
|
|
31
|
-
whitelist =
|
|
31
|
+
whitelist = ComfyMiddleSeat.config.allowed_templates
|
|
32
32
|
if whitelist.is_a?(Array)
|
|
33
33
|
whitelist.member?(@path) ? content : ''
|
|
34
34
|
else
|
|
@@ -37,6 +37,6 @@ class ComfortableMediaSurfer::Content::Tags::Template < ComfortableMediaSurfer::
|
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
:template,
|
|
40
|
+
ComfyMiddleSeat::Content::Renderer.register_tag(
|
|
41
|
+
:template, ComfyMiddleSeat::Content::Tags::Template
|
|
42
42
|
)
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# Tag for text content that is going to be rendered using text input
|
|
4
4
|
# {{ cms:text identifier }}
|
|
5
5
|
#
|
|
6
|
-
class
|
|
6
|
+
class ComfyMiddleSeat::Content::Tags::Text < ComfyMiddleSeat::Content::Tags::Fragment
|
|
7
7
|
def form_field(object_name, view, index)
|
|
8
8
|
name = "#{object_name}[fragments_attributes][#{index}][content]"
|
|
9
9
|
options = { id: form_field_id, class: 'form-control' }
|
|
@@ -13,6 +13,6 @@ class ComfortableMediaSurfer::Content::Tags::Text < ComfortableMediaSurfer::Cont
|
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
:text,
|
|
16
|
+
ComfyMiddleSeat::Content::Renderer.register_tag(
|
|
17
|
+
:text, ComfyMiddleSeat::Content::Tags::Text
|
|
18
18
|
)
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# {{ cms:textarea identifier }}
|
|
5
5
|
#
|
|
6
6
|
|
|
7
|
-
class
|
|
7
|
+
class ComfyMiddleSeat::Content::Tags::Textarea < ComfyMiddleSeat::Content::Tags::Fragment
|
|
8
8
|
def form_field(object_name, view, index)
|
|
9
9
|
name = "#{object_name}[fragments_attributes][#{index}][content]"
|
|
10
10
|
options = { id: form_field_id, data: { 'cms-cm-mode' => 'text/html' } }
|
|
@@ -14,6 +14,6 @@ class ComfortableMediaSurfer::Content::Tags::Textarea < ComfortableMediaSurfer::
|
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
:textarea,
|
|
17
|
+
ComfyMiddleSeat::Content::Renderer.register_tag(
|
|
18
|
+
:textarea, ComfyMiddleSeat::Content::Tags::Textarea
|
|
19
19
|
)
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
# {{ cms:wysiwyg identifier }}
|
|
6
6
|
#
|
|
7
7
|
#
|
|
8
|
-
class
|
|
8
|
+
class ComfyMiddleSeat::Content::Tags::Wysiwyg < ComfyMiddleSeat::Content::Tags::Fragment
|
|
9
9
|
def form_field(object_name, view, index)
|
|
10
10
|
name = "#{object_name}[fragments_attributes][#{index}][content]"
|
|
11
11
|
options = { id: form_field_id, data: { 'cms-rich-text' => true } }
|
|
@@ -14,6 +14,6 @@ class ComfortableMediaSurfer::Content::Tags::Wysiwyg < ComfortableMediaSurfer::C
|
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
:wysiwyg,
|
|
17
|
+
ComfyMiddleSeat::Content::Renderer.register_tag(
|
|
18
|
+
:wysiwyg, ComfyMiddleSeat::Content::Tags::Wysiwyg
|
|
19
19
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'comfy_middle_seat'
|
|
4
4
|
require 'rails'
|
|
5
5
|
require 'rails-i18n'
|
|
6
6
|
require 'comfy_bootstrap_form'
|
|
@@ -8,15 +8,15 @@ require 'active_link_to'
|
|
|
8
8
|
require 'kramdown'
|
|
9
9
|
require 'haml-rails'
|
|
10
10
|
|
|
11
|
-
module
|
|
11
|
+
module ComfyMiddleSeat
|
|
12
12
|
class Engine < ::Rails::Engine
|
|
13
|
-
initializer '
|
|
13
|
+
initializer 'comfy_middle_seat.setup_assets' do |app|
|
|
14
14
|
app.config.assets.paths << root.join('app/assets/builds')
|
|
15
15
|
app.config.assets.precompile += %w[comfy/admin/cms/application.js comfy/admin/cms/application.css]
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
config.to_prepare do
|
|
19
|
-
Dir.glob("#{Rails.root}app/decorators/
|
|
19
|
+
Dir.glob("#{Rails.root}app/decorators/comfy_middle_seat/*_decorator*.rb").each do |c|
|
|
20
20
|
require_dependency(c)
|
|
21
21
|
end
|
|
22
22
|
end
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module ComfyMiddleSeat
|
|
4
4
|
class Error < StandardError
|
|
5
5
|
end
|
|
6
6
|
|
|
7
|
-
class MissingSite <
|
|
7
|
+
class MissingSite < ComfyMiddleSeat::Error
|
|
8
8
|
def initialize(identifier)
|
|
9
9
|
super("Cannot find CMS Site with identifier: #{identifier}")
|
|
10
10
|
end
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
class MissingLayout <
|
|
13
|
+
class MissingLayout < ComfyMiddleSeat::Error
|
|
14
14
|
def initialize(identifier)
|
|
15
15
|
super("Cannot find CMS Layout with identifier: #{identifier}")
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
class MissingPage <
|
|
19
|
+
class MissingPage < ComfyMiddleSeat::Error
|
|
20
20
|
def initialize(path)
|
|
21
21
|
super("Cannot find CMS Page at #{path}")
|
|
22
22
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module ComfyMiddleSeat::Extensions::ActsAsTree
|
|
4
4
|
def self.included(base)
|
|
5
5
|
base.extend(ClassMethods)
|
|
6
6
|
end
|
|
@@ -30,7 +30,7 @@ module ComfortableMediaSurfer::Extensions::ActsAsTree
|
|
|
30
30
|
dependent: configuration[:dependent]
|
|
31
31
|
|
|
32
32
|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
|
33
|
-
include
|
|
33
|
+
include ComfyMiddleSeat::Extensions::ActsAsTree::InstanceMethods
|
|
34
34
|
|
|
35
35
|
scope :roots, -> {
|
|
36
36
|
where("#{configuration[:foreign_key]} IS NULL").
|
|
@@ -110,5 +110,5 @@ module ComfortableMediaSurfer::Extensions::ActsAsTree
|
|
|
110
110
|
end
|
|
111
111
|
|
|
112
112
|
ActiveSupport.on_load :active_record do
|
|
113
|
-
include
|
|
113
|
+
include ComfyMiddleSeat::Extensions::ActsAsTree
|
|
114
114
|
end
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module ComfyMiddleSeat::Extensions::HasRevisions
|
|
4
4
|
def self.included(base)
|
|
5
5
|
base.send :extend, ClassMethods
|
|
6
6
|
end
|
|
7
7
|
|
|
8
8
|
module ClassMethods
|
|
9
9
|
def cms_has_revisions_for(*fields)
|
|
10
|
-
include
|
|
10
|
+
include ComfyMiddleSeat::Extensions::HasRevisions::InstanceMethods
|
|
11
11
|
|
|
12
12
|
attr_accessor :revision_data
|
|
13
13
|
|
|
@@ -42,7 +42,7 @@ module ComfortableMediaSurfer::Extensions::HasRevisions
|
|
|
42
42
|
def create_revision
|
|
43
43
|
return unless revision_data
|
|
44
44
|
|
|
45
|
-
limit =
|
|
45
|
+
limit = ComfyMiddleSeat.config.revisions_limit.to_i
|
|
46
46
|
|
|
47
47
|
# creating revision
|
|
48
48
|
if limit != 0
|
|
@@ -64,5 +64,5 @@ module ComfortableMediaSurfer::Extensions::HasRevisions
|
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
ActiveSupport.on_load :active_record do
|
|
67
|
-
include
|
|
67
|
+
include ComfyMiddleSeat::Extensions::HasRevisions
|
|
68
68
|
end
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
class
|
|
3
|
+
class ComfyMiddleSeat::FormBuilder < ComfyBootstrapForm::FormBuilder
|
|
4
4
|
# Renders form input for a fragment
|
|
5
5
|
#
|
|
6
6
|
# @param [Comfy::Cms::Page] record
|
|
7
|
-
# @param [
|
|
7
|
+
# @param [ComfyMiddleSeat::Content::Tag] tag
|
|
8
8
|
# @param [Integer] index
|
|
9
9
|
def fragment_field(tag, index)
|
|
10
10
|
tag.form_field(object_name, @template, index) do |tag_input|
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
require_relative 'version'
|
|
5
|
+
|
|
6
|
+
class ComfyMiddleSeat::InitializerUpgrader
|
|
7
|
+
class Error < StandardError; end
|
|
8
|
+
|
|
9
|
+
LEGACY_PATH = 'config/initializers/comfortable_media_surfer.rb'
|
|
10
|
+
CURRENT_PATH = 'config/initializers/comfy_middle_seat.rb'
|
|
11
|
+
REPLACEMENTS = {
|
|
12
|
+
'ComfortableMediaSurfer' => 'ComfyMiddleSeat',
|
|
13
|
+
'comfortable_media_surfer' => 'comfy_middle_seat',
|
|
14
|
+
'comfortable-media-surfer' => 'comfy-middle-seat'
|
|
15
|
+
}.freeze
|
|
16
|
+
|
|
17
|
+
def initialize(root: Dir.pwd, output: $stdout)
|
|
18
|
+
@root = File.expand_path(root)
|
|
19
|
+
@output = output
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def call(dry_run: false)
|
|
23
|
+
legacy_path = expand(LEGACY_PATH)
|
|
24
|
+
current_path = expand(CURRENT_PATH)
|
|
25
|
+
|
|
26
|
+
if File.exist?(legacy_path) && File.exist?(current_path)
|
|
27
|
+
raise Error, "Both #{LEGACY_PATH} and #{CURRENT_PATH} exist; merge them manually before rerunning."
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
if File.exist?(legacy_path)
|
|
31
|
+
migrate(legacy_path, current_path, dry_run: dry_run)
|
|
32
|
+
elsif File.exist?(current_path)
|
|
33
|
+
update(current_path, dry_run: dry_run)
|
|
34
|
+
else
|
|
35
|
+
raise Error, "No CMS initializer found at #{LEGACY_PATH} or #{CURRENT_PATH}."
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
def migrate(source, destination, dry_run:)
|
|
42
|
+
backup = backup_path(source)
|
|
43
|
+
ensure_backup_available!(backup)
|
|
44
|
+
content = upgraded_content(source)
|
|
45
|
+
|
|
46
|
+
if dry_run
|
|
47
|
+
output "Would back up #{relative(source)} to #{relative(backup)}."
|
|
48
|
+
output "Would create #{relative(destination)} with ComfyMiddleSeat references."
|
|
49
|
+
output "Would remove #{relative(source)} after a successful conversion."
|
|
50
|
+
return
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
FileUtils.cp(source, backup, preserve: true)
|
|
54
|
+
write(destination, content, mode: File.stat(source).mode)
|
|
55
|
+
FileUtils.rm(source)
|
|
56
|
+
output "Upgraded #{LEGACY_PATH} to #{CURRENT_PATH}."
|
|
57
|
+
output "Original initializer preserved at #{relative(backup)}."
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def update(path, dry_run:)
|
|
61
|
+
content = upgraded_content(path)
|
|
62
|
+
if content == File.binread(path)
|
|
63
|
+
output "#{CURRENT_PATH} is already up to date."
|
|
64
|
+
return
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
backup = backup_path(path)
|
|
68
|
+
ensure_backup_available!(backup)
|
|
69
|
+
|
|
70
|
+
if dry_run
|
|
71
|
+
output "Would back up #{relative(path)} to #{relative(backup)}."
|
|
72
|
+
output "Would update legacy references in #{relative(path)}."
|
|
73
|
+
return
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
FileUtils.cp(path, backup, preserve: true)
|
|
77
|
+
write(path, content, mode: File.stat(path).mode)
|
|
78
|
+
output "Updated legacy references in #{CURRENT_PATH}."
|
|
79
|
+
output "Original initializer preserved at #{relative(backup)}."
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def upgraded_content(path)
|
|
83
|
+
REPLACEMENTS.reduce(File.binread(path)) do |content, (legacy, current)|
|
|
84
|
+
content.gsub(legacy, current)
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def write(path, content, mode:)
|
|
89
|
+
FileUtils.mkdir_p(File.dirname(path))
|
|
90
|
+
File.binwrite(path, content)
|
|
91
|
+
File.chmod(mode & 0o7777, path)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def ensure_backup_available!(path)
|
|
95
|
+
return unless File.exist?(path)
|
|
96
|
+
|
|
97
|
+
raise Error, "Backup already exists at #{relative(path)}; move or remove it before rerunning."
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def backup_path(path)
|
|
101
|
+
"#{path}.bak"
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def expand(path)
|
|
105
|
+
File.join(@root, path)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def relative(path)
|
|
109
|
+
path.delete_prefix("#{@root}/")
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def output(message)
|
|
113
|
+
@output.puts(message)
|
|
114
|
+
end
|
|
115
|
+
end
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module ComfyMiddleSeat::RenderMethods
|
|
4
4
|
def self.included(base)
|
|
5
5
|
# If application controller doesn't have template associated with it
|
|
6
6
|
# CMS will attempt to find one. This is so you don't have to explicitly
|
|
7
7
|
# call render cms_page: '/something'
|
|
8
8
|
base.rescue_from 'ActionView::MissingTemplate' do |e|
|
|
9
9
|
render cms_page: request.path
|
|
10
|
-
rescue
|
|
10
|
+
rescue ComfyMiddleSeat::MissingPage, ComfyMiddleSeat::MissingSite
|
|
11
11
|
raise e
|
|
12
12
|
end
|
|
13
13
|
end
|
|
@@ -37,13 +37,13 @@ module ComfortableMediaSurfer::RenderMethods
|
|
|
37
37
|
return super unless options.is_a?(Hash)
|
|
38
38
|
|
|
39
39
|
if (site_identifier = options.delete(:cms_site)) && !(@cms_site = Comfy::Cms::Site.find_by_identifier(site_identifier))
|
|
40
|
-
raise
|
|
40
|
+
raise ComfyMiddleSeat::MissingSite, site_identifier
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
if ((page_path = options.delete(:cms_page)) || (layout_identifier = options.delete(:cms_layout))) && !@cms_site ||= Comfy::Cms::Site.find_site(
|
|
44
44
|
request.host_with_port.downcase, request.fullpath
|
|
45
45
|
)
|
|
46
|
-
raise
|
|
46
|
+
raise ComfyMiddleSeat::MissingSite, "#{request.host.downcase}/#{request.fullpath}"
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
if page_path
|
|
@@ -59,7 +59,7 @@ module ComfortableMediaSurfer::RenderMethods
|
|
|
59
59
|
path.gsub!(%r{^/#{@cms_site.path}}, '') if @cms_site.path.present?
|
|
60
60
|
|
|
61
61
|
unless (@cms_page = @cms_site.pages.find_by_full_path(path))
|
|
62
|
-
raise
|
|
62
|
+
raise ComfyMiddleSeat::MissingPage, path
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
@cms_page.translate!
|
|
@@ -82,7 +82,7 @@ module ComfortableMediaSurfer::RenderMethods
|
|
|
82
82
|
|
|
83
83
|
def render_cms_layout(identifier, options = {}, locals = {}, &)
|
|
84
84
|
unless (@cms_layout = @cms_site.layouts.find_by_identifier(identifier))
|
|
85
|
-
raise
|
|
85
|
+
raise ComfyMiddleSeat::MissingLayout, identifier
|
|
86
86
|
end
|
|
87
87
|
|
|
88
88
|
cms_app_layout = @cms_layout.app_layout
|
|
@@ -102,5 +102,5 @@ module ComfortableMediaSurfer::RenderMethods
|
|
|
102
102
|
end
|
|
103
103
|
|
|
104
104
|
ActiveSupport.on_load :action_controller_base do
|
|
105
|
-
include
|
|
105
|
+
include ComfyMiddleSeat::RenderMethods
|
|
106
106
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module ComfyMiddleSeat::Routing
|
|
4
4
|
class ActionDispatch::Routing::Mapper
|
|
5
5
|
def comfy_route_cms_admin(path: 'admin')
|
|
6
6
|
scope module: :comfy, as: :comfy do
|
|
@@ -17,6 +17,7 @@ module ComfortableMediaSurfer::Routing
|
|
|
17
17
|
concern :with_revisions do |options|
|
|
18
18
|
resources :revisions, **options, only: %i[index show] do
|
|
19
19
|
patch :revert, on: :member
|
|
20
|
+
get :preview, on: :member if options[:controller].in?(%w[revisions/page revisions/translation])
|
|
20
21
|
end
|
|
21
22
|
end
|
|
22
23
|
|
|
@@ -66,7 +67,7 @@ module ComfortableMediaSurfer::Routing
|
|
|
66
67
|
|
|
67
68
|
class ActionDispatch::Routing::Mapper
|
|
68
69
|
def comfy_route_cms(options = {})
|
|
69
|
-
|
|
70
|
+
ComfyMiddleSeat.configuration.public_cms_path = options[:path]
|
|
70
71
|
|
|
71
72
|
scope module: :comfy, as: :comfy do
|
|
72
73
|
namespace :cms, path: options[:path] do
|