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.
Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/coveralls.yml +4 -0
  3. data/CHANGELOG.md +56 -3
  4. data/CONTRIBUTING.md +8 -5
  5. data/Gemfile +1 -1
  6. data/README.md +66 -29
  7. data/Rakefile +3 -3
  8. data/app/assets/javascripts/comfy/admin/cms/application.js +2 -0
  9. data/app/assets/javascripts/comfy/admin/cms/base.js +6 -1
  10. data/app/assets/javascripts/comfy/admin/cms/codemirror.js +17 -0
  11. data/app/assets/javascripts/comfy/admin/cms/dirty_forms.js +201 -0
  12. data/app/assets/javascripts/comfy/admin/cms/draft_forms.js +468 -0
  13. data/app/assets/javascripts/comfy/admin/cms/page_fragments.js +393 -22
  14. data/app/assets/javascripts/comfy/admin/cms/wysiwyg.js +21 -0
  15. data/app/assets/javascripts/comfy/vendor/redactor/filemanager.js +48 -30
  16. data/app/assets/javascripts/comfy/vendor/redactor/imagemanager.js +43 -25
  17. data/app/assets/stylesheets/comfy/admin/cms/base.sass +23 -0
  18. data/app/controllers/comfy/admin/base_controller.rb +3 -3
  19. data/app/controllers/comfy/admin/cms/base_controller.rb +12 -7
  20. data/app/controllers/comfy/admin/cms/files_controller.rb +1 -1
  21. data/app/controllers/comfy/admin/cms/pages_controller.rb +76 -16
  22. data/app/controllers/comfy/admin/cms/revisions/base_controller.rb +39 -1
  23. data/app/controllers/comfy/admin/cms/revisions/page_controller.rb +9 -8
  24. data/app/controllers/comfy/admin/cms/revisions/translation_controller.rb +14 -8
  25. data/app/controllers/comfy/admin/cms/sites_controller.rb +1 -1
  26. data/app/controllers/comfy/admin/cms/translations_controller.rb +3 -1
  27. data/app/controllers/comfy/cms/base_controller.rb +1 -1
  28. data/app/controllers/comfy/cms/content_controller.rb +5 -5
  29. data/app/controllers/concerns/comfy/reorder_action.rb +24 -4
  30. data/app/helpers/comfy/admin/cms_helper.rb +28 -3
  31. data/app/helpers/comfy/cms_helper.rb +1 -1
  32. data/app/models/comfy/cms/file.rb +25 -3
  33. data/app/models/comfy/cms/layout.rb +8 -6
  34. data/app/models/comfy/cms/page.rb +22 -0
  35. data/app/models/comfy/cms/site.rb +3 -3
  36. data/app/models/comfy/cms/snippet.rb +8 -3
  37. data/app/models/concerns/comfy/cms/with_fragments.rb +2 -2
  38. data/app/views/comfy/admin/cms/categories/_index.html.haml +1 -1
  39. data/app/views/comfy/admin/cms/categories/_show.html.haml +1 -1
  40. data/app/views/comfy/admin/cms/files/_file.html.haml +1 -1
  41. data/app/views/comfy/admin/cms/files/index.html.haml +9 -2
  42. data/app/views/comfy/admin/cms/fragments/_form_fragments.html.haml +2 -2
  43. data/app/views/comfy/admin/cms/pages/_form.html.haml +2 -1
  44. data/app/views/comfy/admin/cms/pages/_index_branch.html.haml +11 -10
  45. data/app/views/comfy/admin/cms/pages/edit.html.haml +3 -1
  46. data/app/views/comfy/admin/cms/pages/index.html.haml +9 -2
  47. data/app/views/comfy/admin/cms/pages/new.html.haml +3 -1
  48. data/app/views/comfy/admin/cms/pages/toggle_branch.js.erb +2 -2
  49. data/app/views/comfy/admin/cms/revisions/show.html.haml +25 -7
  50. data/app/views/comfy/admin/cms/shared/_search.html.haml +9 -0
  51. data/app/views/comfy/admin/cms/sites/_form.html.haml +1 -1
  52. data/app/views/comfy/admin/cms/translations/_form.html.haml +2 -1
  53. data/app/views/comfy/admin/cms/translations/edit.html.haml +3 -1
  54. data/app/views/comfy/admin/cms/translations/new.html.haml +3 -1
  55. data/app/views/layouts/comfy/admin/cms/_flash.html.haml +1 -1
  56. data/app/views/layouts/comfy/admin/cms/_head.html.haml +3 -1
  57. data/app/views/layouts/comfy/admin/cms/_left.html.haml +2 -2
  58. data/comfy_middle_seat.gemspec +10 -5
  59. data/config/application.rb +3 -2
  60. data/config/cms_routes.rb +1 -1
  61. data/config/environment.rb +1 -1
  62. data/config/environments/development.rb +1 -1
  63. data/config/environments/production.rb +1 -1
  64. data/config/environments/test.rb +1 -1
  65. data/config/initializers/{comfortable_media_surfer.rb → comfy_middle_seat.rb} +4 -4
  66. data/config/locales/ar.yml +14 -0
  67. data/config/locales/ca.yml +14 -0
  68. data/config/locales/cs.yml +14 -0
  69. data/config/locales/da.yml +14 -0
  70. data/config/locales/de.yml +14 -0
  71. data/config/locales/en.yml +14 -0
  72. data/config/locales/es.yml +14 -0
  73. data/config/locales/fi.yml +14 -0
  74. data/config/locales/fr.yml +14 -0
  75. data/config/locales/gr.yml +14 -0
  76. data/config/locales/hr.yml +14 -0
  77. data/config/locales/it.yml +14 -0
  78. data/config/locales/ja.yml +14 -0
  79. data/config/locales/nb.yml +14 -0
  80. data/config/locales/nl.yml +14 -0
  81. data/config/locales/pl.yml +14 -0
  82. data/config/locales/pt-BR.yml +14 -0
  83. data/config/locales/ru.yml +14 -0
  84. data/config/locales/sk.yml +14 -0
  85. data/config/locales/sv.yml +14 -0
  86. data/config/locales/tr.yml +14 -0
  87. data/config/locales/uk.yml +14 -0
  88. data/config/locales/zh-CN.yml +14 -0
  89. data/config/locales/zh-TW.yml +14 -0
  90. data/config.ru +1 -1
  91. data/exe/comfy-middle-seat-upgrade +34 -0
  92. data/lib/{comfortable_media_surfer → comfy_middle_seat}/access_control/admin_authentication.rb +4 -4
  93. data/lib/{comfortable_media_surfer → comfy_middle_seat}/access_control/admin_authorization.rb +1 -1
  94. data/lib/{comfortable_media_surfer → comfy_middle_seat}/access_control/public_authentication.rb +1 -1
  95. data/lib/{comfortable_media_surfer → comfy_middle_seat}/access_control/public_authorization.rb +1 -1
  96. data/lib/{comfortable_media_surfer → comfy_middle_seat}/configuration.rb +7 -7
  97. data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/block.rb +1 -1
  98. data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/params_parser.rb +1 -1
  99. data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/renderer.rb +10 -10
  100. data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tag.rb +4 -4
  101. data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/asset.rb +4 -4
  102. data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/audio.rb +3 -3
  103. data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/breadcrumbs.rb +3 -3
  104. data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/checkbox.rb +3 -3
  105. data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/children.rb +3 -3
  106. data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/date.rb +3 -3
  107. data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/datetime.rb +3 -3
  108. data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/file.rb +5 -5
  109. data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/file_link.rb +4 -4
  110. data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/files.rb +3 -3
  111. data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/fragment.rb +2 -2
  112. data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/helper.rb +4 -4
  113. data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/image.rb +4 -4
  114. data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/markdown.rb +3 -3
  115. data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/mixins/file_content.rb +1 -1
  116. data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/number.rb +3 -3
  117. data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/page_file_link.rb +5 -5
  118. data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/partial.rb +4 -4
  119. data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/siblings.rb +3 -3
  120. data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/snippet.rb +3 -3
  121. data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/template.rb +4 -4
  122. data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/text.rb +3 -3
  123. data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/textarea.rb +3 -3
  124. data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags/wysiwyg.rb +3 -3
  125. data/lib/{comfortable_media_surfer → comfy_middle_seat}/content/tags.rb +1 -1
  126. data/lib/{comfortable_media_surfer → comfy_middle_seat}/content.rb +1 -1
  127. data/lib/{comfortable_media_surfer → comfy_middle_seat}/engine.rb +4 -4
  128. data/lib/{comfortable_media_surfer → comfy_middle_seat}/error.rb +4 -4
  129. data/lib/{comfortable_media_surfer → comfy_middle_seat}/extensions/acts_as_tree.rb +3 -3
  130. data/lib/{comfortable_media_surfer → comfy_middle_seat}/extensions/has_revisions.rb +4 -4
  131. data/lib/{comfortable_media_surfer → comfy_middle_seat}/extensions.rb +1 -1
  132. data/lib/{comfortable_media_surfer → comfy_middle_seat}/form_builder.rb +2 -2
  133. data/lib/comfy_middle_seat/initializer_upgrader.rb +115 -0
  134. data/lib/{comfortable_media_surfer → comfy_middle_seat}/render_methods.rb +7 -7
  135. data/lib/{comfortable_media_surfer → comfy_middle_seat}/routing.rb +3 -2
  136. data/lib/{comfortable_media_surfer → comfy_middle_seat}/seeds/file/exporter.rb +5 -5
  137. data/lib/{comfortable_media_surfer → comfy_middle_seat}/seeds/file/importer.rb +5 -5
  138. data/lib/{comfortable_media_surfer → comfy_middle_seat}/seeds/layout/exporter.rb +4 -4
  139. data/lib/{comfortable_media_surfer → comfy_middle_seat}/seeds/layout/importer.rb +5 -5
  140. data/lib/{comfortable_media_surfer → comfy_middle_seat}/seeds/page/exporter.rb +5 -5
  141. data/lib/{comfortable_media_surfer → comfy_middle_seat}/seeds/page/importer.rb +7 -7
  142. data/lib/{comfortable_media_surfer → comfy_middle_seat}/seeds/snippet/exporter.rb +4 -4
  143. data/lib/{comfortable_media_surfer → comfy_middle_seat}/seeds/snippet/importer.rb +5 -5
  144. data/lib/{comfortable_media_surfer → comfy_middle_seat}/seeds.rb +4 -4
  145. data/lib/comfy_middle_seat/version.rb +2 -2
  146. data/lib/{comfortable_media_surfer → comfy_middle_seat}/view_hooks.rb +2 -2
  147. data/lib/comfy_middle_seat.rb +54 -1
  148. data/lib/generators/comfy/cms/README +3 -11
  149. data/lib/generators/comfy/cms/cms_generator.rb +2 -2
  150. data/lib/generators/comfy/scaffold/templates/tests/controller.rb.tt +2 -2
  151. data/lib/tasks/cms_seeds.rake +8 -8
  152. data/package-lock.json +2 -2
  153. data/package.json +1 -1
  154. metadata +68 -62
  155. data/lib/comfortable_media_surfer/version.rb +0 -3
  156. data/lib/comfortable_media_surfer.rb +0 -56
@@ -13,8 +13,9 @@ class Comfy::Cms::Snippet < ActiveRecord::Base
13
13
  # -- Callbacks ---------------------------------------------------------------
14
14
  before_validation :assign_label
15
15
  before_create :assign_position
16
- after_save :clear_page_content_cache
17
- after_destroy :clear_page_content_cache
16
+ after_commit :clear_page_content_cache,
17
+ on: %i[create update destroy],
18
+ if: :page_content_cache_stale?
18
19
 
19
20
  # -- Validations -------------------------------------------------------------
20
21
  validates :label,
@@ -33,7 +34,11 @@ protected
33
34
  # When snippet is changed or removed we need to blow away all page caches as
34
35
  # we don't know where it was used.
35
36
  def clear_page_content_cache
36
- Comfy::Cms::Page.where(id: site.pages.pluck(:id)).update_all(content_cache: nil)
37
+ site.pages.update_all(content_cache: nil)
38
+ end
39
+
40
+ def page_content_cache_stale?
41
+ destroyed? || saved_changes?
37
42
  end
38
43
 
39
44
  def assign_position
@@ -77,7 +77,7 @@ module Comfy::Cms::WithFragments
77
77
  # duplicate tags on the layout. That's wierd (but still works).
78
78
  def fragment_nodes
79
79
  nodes
80
- .grep(ComfortableMediaSurfer::Content::Tags::Fragment)
80
+ .grep(ComfyMiddleSeat::Content::Tags::Fragment)
81
81
  .uniq(&:identifier)
82
82
  end
83
83
 
@@ -111,7 +111,7 @@ module Comfy::Cms::WithFragments
111
111
  protected
112
112
 
113
113
  def renderer
114
- ComfortableMediaSurfer::Content::Renderer.new(self)
114
+ ComfyMiddleSeat::Content::Renderer.new(self)
115
115
  end
116
116
 
117
117
  def nodes
@@ -4,7 +4,7 @@
4
4
  .categories
5
5
  .category
6
6
  - active_class = params[:categories].blank?? "active" : nil
7
- = link_to t('.all'), {categories: nil}, class: "btn btn-sm btn-light btn-block #{active_class}"
7
+ = link_to t('.all'), {categories: nil, q: params[:q].presence}, class: "btn btn-sm btn-light btn-block #{active_class}"
8
8
  - @site.categories.of_type(type).each do |category|
9
9
  = render "comfy/admin/cms/categories/show", category: category, read: true
10
10
  %button.toggle-cat-edit.btn.btn-secondary.btn-sm.btn-block{type: "button"}
@@ -6,7 +6,7 @@
6
6
  - if read
7
7
  - active_class = active ? "active" : nil
8
8
  - categories = active ? categories.reject{|c| c == category.label} : categories << category.label
9
- - url = "?#{{categories: categories}.to_query}"
9
+ - url = "?#{{categories: categories, q: params[:q].presence}.compact.to_query}"
10
10
  = link_to category.label, url, class: "btn btn-sm btn-light btn-block text-left text-truncate #{active_class}"
11
11
  - else
12
12
  .btn-group.d-flex
@@ -5,7 +5,7 @@
5
5
  .row
6
6
  .col-md-5.item
7
7
  .item-controls.d-none.d-lg-block
8
- - if !params[:categories].present? && @site.files.count > 1
8
+ - if !params[:categories].present? && !params[:q].present? && @site.files.count > 1
9
9
  .dragger
10
10
  %i.fas.fa-bars
11
11
  .item-content
@@ -21,10 +21,17 @@
21
21
 
22
22
  = comfy_admin_partial "comfy/admin/cms/partials/files_before"
23
23
 
24
+ = render "comfy/admin/cms/shared/search",
25
+ url: comfy_admin_cms_site_files_path(@site),
26
+ placeholder: t(".search_placeholder")
27
+
24
28
  = comfy_paginate @files
25
29
 
26
- %ul.list.sortable.cms-uploader-filelist
27
- = render partial: "file", collection: @files
30
+ - if @files.present?
31
+ %ul.list.cms-uploader-filelist{class: ("sortable" unless params[:categories].present? || params[:q].present?)}
32
+ = render partial: "file", collection: @files
33
+ - else
34
+ .alert.alert-info= t(".no_results")
28
35
 
29
36
  = comfy_admin_partial "comfy/admin/cms/partials/files_after"
30
37
 
@@ -25,7 +25,7 @@
25
25
  .tab-content
26
26
  - frag_index = 0
27
27
 
28
- - builder_opts = { builder: ComfortableMediaSurfer::FormBuilder, bootstrap: { layout: :horizontal }}
28
+ - builder_opts = { builder: ComfyMiddleSeat::FormBuilder, bootstrap: { layout: :horizontal }}
29
29
  = fields scope, model: record, **builder_opts do |form|
30
30
  - namespace.each_with_index do |(name, tags), index|
31
31
  .tab-pane{id: "ns-#{name}", class: index == 0 ? "active" : nil}
@@ -33,6 +33,6 @@
33
33
  = form.fragment_field(tag, frag_index)
34
34
  - frag_index += 1
35
35
 
36
- - rescue ComfortableMediaSurfer::Content::Renderer::SyntaxError, ComfortableMediaSurfer::Content::Tag::Error => e
36
+ - rescue ComfyMiddleSeat::Content::Renderer::SyntaxError, ComfyMiddleSeat::Content::Tag::Error => e
37
37
  .alert.alert-danger
38
38
  = e
@@ -9,7 +9,8 @@
9
9
  = form.select :parent_id, options, bootstrap: {custom_control: true}
10
10
 
11
11
  - if (options = ::Comfy::Cms::Layout.options_for_select(@site)).present?
12
- = form.select :layout_id, options, {bootstrap: {custom_control: true}}, {data: {url: form_fragments_comfy_admin_cms_site_page_path(@site, @page.id.to_i)}, id: "fragments-toggle"}
12
+ - fragments_data = {url: form_fragments_comfy_admin_cms_site_page_path(@site, @page.id.to_i), loading_message: t("comfy.admin.cms.fragments.loading", default: "Loading layout content…"), error_message: t("comfy.admin.cms.fragments.load_error", default: "Layout content could not be loaded. Your current content has been kept."), discard_message: t("comfy.admin.cms.fragments.discard_confirmation", default: "Some content cannot be preserved in the selected layout. Replace it anyway?")}
13
+ = form.select :layout_id, options, {bootstrap: {custom_control: true}}, {data: fragments_data, id: "fragments-toggle"}
13
14
 
14
15
  = comfy_admin_partial "comfy/admin/cms/partials/page_form_inner", form: form
15
16
 
@@ -1,16 +1,16 @@
1
- - page ||= index_branch
2
- - children = @pages_by_parent[page.id]
3
- - siblings = @pages_by_parent[page.parent_id]
4
- - has_children = children.present?
5
- - has_siblings = siblings.size > 1
6
- - branch_open = (session[:cms_page_tree] || []).member?(page.id.to_s) || page.root?
7
- - category_view = params[:categories].present?
1
+ - page ||= index_branch
2
+ - filter_view = params[:categories].present? || params[:q].present?
3
+ - children = filter_view ? [] : @pages_by_parent.fetch(page.id, [])
4
+ - siblings = filter_view ? [] : @pages_by_parent.fetch(page.parent_id, [])
5
+ - has_children = children.present? || page.children_count.to_i.positive?
6
+ - has_siblings = siblings.size > 1
7
+ - branch_open = page_branch_open?(page)
8
8
 
9
9
  %li{id: dom_id(page), data: {id: page.id}}
10
10
  .row
11
11
 
12
12
  .col-md-6.item
13
- - unless category_view
13
+ - unless filter_view
14
14
  .item-controls
15
15
  - if has_siblings
16
16
  .dragger.d-none.d-md-block
@@ -37,8 +37,9 @@
37
37
  .btn-group.btn-group-sm
38
38
  = link_to t(".add_child_page"), new_comfy_admin_cms_site_page_path(@site, parent_id: page.id), class: "btn btn-outline-secondary"
39
39
  = link_to t(".edit"), edit_comfy_admin_cms_site_page_path(@site, page), class: "btn btn-outline-secondary"
40
- = link_to t(".delete"), comfy_admin_cms_site_page_path(@site, page), method: :delete, data: {confirm: t('.are_you_sure')}, class: "btn btn-danger"
40
+ - unless page.root?
41
+ = link_to t(".delete"), comfy_admin_cms_site_page_path(@site, page), method: :delete, data: {confirm: t('.are_you_sure')}, class: "btn btn-danger"
41
42
 
42
- - if !category_view && has_children && branch_open
43
+ - if !filter_view && has_children && branch_open
43
44
  %ul.list.children.sortable.pl-md-3
44
45
  = render partial: "index_branch", collection: children
@@ -10,5 +10,7 @@
10
10
  = link_to t('.publish_children', default: 'Publish children'), publish_children_comfy_admin_cms_site_page_path(@site, @page), method: :patch, data: {confirm: t('.publish_children_confirmation', default: 'Publish all child pages?')}, class: 'btn btn-success'
11
11
  = link_to t('.unpublish_children', default: 'Unpublish children'), unpublish_children_comfy_admin_cms_site_page_path(@site, @page), method: :patch, data: {confirm: t('.unpublish_children_confirmation', default: 'Unpublish all child pages?')}, class: 'btn btn-outline-secondary'
12
12
 
13
- = comfy_form_with model: @page, scope: :page, url: {action: :update}, html: {multipart: true} do |form|
13
+ - draft_data = cms_draft_form_data('site', @site.id, 'page', @page.id, record: @page)
14
+ = comfy_form_with model: @page, scope: :page, url: {action: :update}, html: {multipart: true, data: draft_data} do |form|
15
+ = hidden_field_tag :cms_draft_key, draft_data[:cms_draft_key]
14
16
  = render form
@@ -7,7 +7,14 @@
7
7
 
8
8
  = comfy_admin_partial "comfy/admin/cms/partials/pages_before"
9
9
 
10
- %ul.list.sortable
11
- = render partial: "index_branch", collection: @pages
10
+ = render "comfy/admin/cms/shared/search",
11
+ url: comfy_admin_cms_site_pages_path(@site),
12
+ placeholder: t(".search_placeholder")
13
+
14
+ - if @pages.present?
15
+ %ul.list{class: ("sortable" unless params[:categories].present? || params[:q].present?)}
16
+ = render partial: "index_branch", collection: @pages
17
+ - else
18
+ .alert.alert-info= t(".no_results")
12
19
 
13
20
  = comfy_admin_partial "comfy/admin/cms/partials/pages_after"
@@ -1,5 +1,7 @@
1
1
  .page-header
2
2
  %h2= t('.title')
3
3
 
4
- = comfy_form_with model: @page, scope: :page, url: {action: :create}, html: {multipart: true} do |form|
4
+ - draft_data = cms_draft_form_data('site', @site.id, 'page', 'new', 'parent', @page.parent_id || 'root', record: @page)
5
+ = comfy_form_with model: @page, scope: :page, url: {action: :create}, html: {multipart: true, data: draft_data} do |form|
6
+ = hidden_field_tag :cms_draft_key, draft_data[:cms_draft_key]
5
7
  = render form
@@ -2,11 +2,11 @@
2
2
  var li = document.querySelector('li#comfy_cms_page_<%=@page.id%>');
3
3
  var toggle = li.querySelector('.item .toggle');
4
4
  toggle.classList.toggle('open');
5
- <% if session[:cms_page_tree].member?(@page.id.to_s) %>
5
+ <% if @branch_open %>
6
6
  if(!li.querySelector('ul.children')) {
7
7
  var childrenList = document.createElement('ul');
8
8
  childrenList.className = 'children sortable pl-md-3';
9
- childrenList.innerHTML = '<%= escape_javascript(render partial: "index_branch", collection: @page.children) %>';
9
+ childrenList.innerHTML = '<%= escape_javascript(render partial: "index_branch", collection: @pages_by_parent.fetch(@page.id, [])) %>';
10
10
  li.appendChild(childrenList);
11
11
  CMS.sortableList.dispose();
12
12
  CMS.sortableList.init();
@@ -1,20 +1,36 @@
1
+ - selected_timestamp = l(@revision.created_at, format: "%Y-%m-%d %H:%M:%S %Z")
2
+
1
3
  - content_for :right_column do
2
4
  .box.revisions
3
5
  - @record.revisions.order(created_at: :desc).each do |revision|
4
- = active_link_to l(revision.created_at, format: :short), { id: revision.id }, class: "btn btn-sm btn-light d-block text-primary mb-1"
6
+ - timestamp = l(revision.created_at, format: "%Y-%m-%d %H:%M:%S %Z")
7
+ - label = t('.revision_link', default: 'Revision #%{id} — snapshot replaced at %{timestamp}', id: revision.id, timestamp: timestamp)
8
+ = active_link_to label, {id: revision.id}, class: "btn btn-sm btn-light d-block text-primary text-left mb-1"
5
9
 
6
10
  .page-header
7
11
  %h2
8
- = t('.title')
12
+ = t('.title', default: 'Revisions for')
9
13
  = @record.class.to_s.demodulize
10
14
 
15
+ .revision-summary
16
+ %h3.h5= t('.selected_revision', default: 'Selected revision #%{id}', id: @revision.id)
17
+ %p.mb-2
18
+ = t('.snapshot_explanation', default: 'This snapshot contains the content that was replaced at %{timestamp}. The comparison shows how the currently saved content differs from that snapshot.', timestamp: selected_timestamp)
19
+ .revision-legend{aria: {label: t('.legend', default: 'Change legend')}}
20
+ %span.revision-legend-item
21
+ %span.revision-legend-swatch.added{aria: {hidden: true}}
22
+ = t('.added', default: 'Added since snapshot')
23
+ %span.revision-legend-item
24
+ %span.revision-legend-swatch.removed{aria: {hidden: true}}
25
+ = t('.removed', default: 'Removed since snapshot')
26
+
11
27
  .row.d-none.d-lg-flex
12
28
  .col-lg-10.ml-auto
13
29
  .row
14
30
  .col-lg-6
15
- .label= t('.previous')
31
+ .label= t('.selected_snapshot', default: 'Selected snapshot')
16
32
  .col-lg-6
17
- .label= t('.current')
33
+ .label= t('.current_content', default: 'Current saved content (changes highlighted)')
18
34
 
19
35
  - @current_content.each do |label, content|
20
36
  .row.revision
@@ -30,7 +46,9 @@
30
46
  .current.d-none= content
31
47
  .content
32
48
 
33
- = comfy_form_with model: @revision, url: { action: :revert } do |form|
49
+ = comfy_form_with model: @revision, url: {action: :revert} do |form|
34
50
  = form.form_actions do
35
- = submit_tag t(".update"), class: "btn btn-primary"
36
- = link_to t(".cancel"), record_path, class: "btn btn-link"
51
+ = submit_tag t('.update', default: 'Restore selected snapshot'), class: 'btn btn-primary'
52
+ - if preview_path
53
+ = link_to t('.preview', default: 'Preview selected snapshot'), preview_path, class: 'btn btn-info', target: 'comfy-cms-revision-preview', rel: 'noopener'
54
+ = link_to t('.cancel', default: 'Cancel'), record_path, class: 'btn btn-link'
@@ -0,0 +1,9 @@
1
+ = form_tag url, method: :get, class: "mb-3", role: "search" do
2
+ - Array(params[:categories]).each do |category|
3
+ = hidden_field_tag "categories[]", category
4
+ .input-group
5
+ = search_field_tag :q, params[:q], class: "form-control", placeholder: placeholder, aria: {label: placeholder}
6
+ .input-group-append
7
+ = submit_tag t("comfy.admin.cms.search.submit"), name: nil, class: "btn btn-primary"
8
+ - if params[:q].present?
9
+ = link_to t("comfy.admin.cms.search.clear"), url_for(q: nil, categories: params[:categories]), class: "btn btn-outline-secondary"
@@ -5,7 +5,7 @@
5
5
  = form.text_field :hostname
6
6
  = form.text_field :path
7
7
 
8
- - locales = ComfortableMediaSurfer.config.locales.to_a.collect{|l| ["#{l[1]} (#{l[0]})", l[0]]}
8
+ - locales = ComfyMiddleSeat.config.locales.to_a.collect{|l| ["#{l[1]} (#{l[0]})", l[0]]}
9
9
  = form.select :locale, locales, bootstrap: {custom_control: true}
10
10
 
11
11
  = comfy_admin_partial "comfy/admin/cms/partials/site_form_after", form: form
@@ -5,7 +5,8 @@
5
5
  = form.text_field :label
6
6
 
7
7
  - if (options = ::Comfy::Cms::Layout.options_for_select(@site)).present?
8
- = form.select :layout_id, options, {}, {data: {url: form_fragments_comfy_admin_cms_site_page_translation_path(@site, @page, @translation.id.to_i)}, id: "fragments-toggle"}
8
+ - fragments_data = {url: form_fragments_comfy_admin_cms_site_page_translation_path(@site, @page, @translation.id.to_i), loading_message: t("comfy.admin.cms.fragments.loading", default: "Loading layout content…"), error_message: t("comfy.admin.cms.fragments.load_error", default: "Layout content could not be loaded. Your current content has been kept."), discard_message: t("comfy.admin.cms.fragments.discard_confirmation", default: "Some content cannot be preserved in the selected layout. Replace it anyway?")}
9
+ = form.select :layout_id, options, {}, {data: fragments_data, id: "fragments-toggle"}
9
10
 
10
11
  #form-fragments-container
11
12
  = render "comfy/admin/cms/fragments/form_fragments", record: @translation, scope: :translation
@@ -6,5 +6,7 @@
6
6
  .page-header
7
7
  %h2= t('.title')
8
8
 
9
- = comfy_form_with model: @translation, scope: :translation, url: {action: :update}, html: {multipart: true} do |form|
9
+ - draft_data = cms_draft_form_data('site', @site.id, 'page', @page.id, 'translation', @translation.id, record: @translation)
10
+ = comfy_form_with model: @translation, scope: :translation, url: {action: :update}, html: {multipart: true, data: draft_data} do |form|
11
+ = hidden_field_tag :cms_draft_key, draft_data[:cms_draft_key]
10
12
  = render form
@@ -1,5 +1,7 @@
1
1
  .page-header
2
2
  %h2= t(".title")
3
3
 
4
- = comfy_form_with model: @translation, scope: :translation, url: {action: :create}, html: {multipart: true} do |form|
4
+ - draft_data = cms_draft_form_data('site', @site.id, 'page', @page.id, 'translation', 'new', record: @translation)
5
+ = comfy_form_with model: @translation, scope: :translation, url: {action: :create}, html: {multipart: true, data: draft_data} do |form|
6
+ = hidden_field_tag :cms_draft_key, draft_data[:cms_draft_key]
5
7
  = render form
@@ -1,4 +1,4 @@
1
- - flash.each do |type, message|
1
+ - flash.to_hash.except('cms_saved_draft_key').each do |type, message|
2
2
  .alert{:class => "alert-#{type}"}
3
3
  %button.close{:type => 'button', :class => "close", :data => {:dismiss => 'alert'}} &times;
4
4
  = message
@@ -1,11 +1,13 @@
1
1
  %head
2
- %title= ComfortableMediaSurfer.config.cms_title
2
+ %title= ComfyMiddleSeat.config.cms_title
3
3
 
4
4
  %meta{"http-equiv" => "Content-type", content: "text/html; charset=utf-8"}
5
5
  %meta{charset: "utf-8"}
6
6
  %meta{name: "viewport", content: "width=device-width, initial-scale=1, shrink-to-fit=no"}
7
7
 
8
8
  = csrf_meta_tag
9
+ - if flash[:cms_saved_draft_key].present?
10
+ %meta{name: "cms-saved-draft-key", content: flash[:cms_saved_draft_key]}
9
11
 
10
12
  - if @site && @site.persisted?
11
13
  %meta{name: "cms-file-upload-path", content: comfy_admin_cms_site_files_path(@site)}
@@ -35,8 +35,8 @@
35
35
  = comfy_admin_partial "comfy/admin/cms/partials/navigation_after"
36
36
 
37
37
  .left-footer
38
- = link_to 'ComfortableMediaSurfer', 'https://github.com/shakacode/comfortable-media-surfer', target: '_blank'
39
- %span.version= ComfortableMediaSurfer::VERSION
38
+ = link_to 'ComfyMiddleSeat', 'https://github.com/avonderluft/comfy-middle-seat', target: '_blank'
39
+ %span.version= ComfyMiddleSeat::VERSION
40
40
  %br
41
41
  = link_to 'Rails', 'https://rubyonrails.org', target: '_blank'
42
42
  %span.version= Rails::version
@@ -1,19 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  $LOAD_PATH.unshift File.expand_path('lib', __dir__)
4
- require 'comfortable_media_surfer/version'
4
+ require 'comfy_middle_seat/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'comfy_middle_seat'
8
- spec.version = ComfortableMediaSurfer::VERSION
8
+ spec.version = ComfyMiddleSeat::VERSION
9
9
  spec.authors = ['Oleg Khabarov', 'Andrew vonderLuft']
10
10
  spec.email = ['wonder@hey.com']
11
- spec.homepage = 'https://github.com/avonderluft/comfortable-media-surfer'
11
+ spec.homepage = 'https://github.com/avonderluft/comfy-middle-seat'
12
12
  spec.summary = 'Rails 7.2+ CMS Engine'
13
- spec.description = 'Comfy Middle Seat is a Rails 7.2+ CMS Engine forked from ComfortableMediaSurfer'
13
+ spec.description = 'Comfy Middle Seat is a Rails 7.2+ CMS engine.'
14
14
  spec.license = 'MIT'
15
15
 
16
- spec.post_install_message = 'Please run rake comfy:compile_assets to compile assets.'
16
+ spec.post_install_message = <<~MESSAGE
17
+ Please run rake comfy:compile_assets to compile assets.
18
+ Upgrading from comfortable_media_surfer? Run bundle exec comfy-middle-seat-upgrade --dry-run first.
19
+ MESSAGE
20
+ spec.bindir = 'exe'
21
+ spec.executables = ['comfy-middle-seat-upgrade']
17
22
 
18
23
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
24
  f.match(%r{^(test|doc)/})
@@ -8,7 +8,7 @@ require 'rails/all'
8
8
  # you've limited to :test, :development, or :production.
9
9
  Bundler.require(*Rails.groups)
10
10
 
11
- module ComfortableMediaSurfer
11
+ module ComfyMiddleSeat
12
12
  class Application < Rails::Application
13
13
  # Ensuring that ActiveStorage routes are loaded before Comfy's globbing
14
14
  # route. Without this file serving routes are inaccessible.
@@ -32,7 +32,8 @@ module ComfortableMediaSurfer
32
32
  # not contain `.rb` files, or that should not be reloaded or eager loaded.
33
33
  # Common ones are `templates`, `generators`, or `middleware`, for example.
34
34
  config.add_autoload_paths_to_load_path = false
35
- config.autoload_lib(ignore: %w[generators])
35
+ # These gem entrypoints are explicitly required and retain the ComfyMiddleSeat namespace.
36
+ config.autoload_lib(ignore: %w[generators comfy_middle_seat.rb comfy_middle_seat])
36
37
  end
37
38
 
38
39
  # Making sure we don't load our dev routes as part of the engine
data/config/cms_routes.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # We can't have this in config/routes.rb as they will get pulled in into parent
4
4
  # application automatically. We want user to manually place them.
5
- ComfortableMediaSurfer::Application.routes.draw do
5
+ ComfyMiddleSeat::Application.routes.draw do
6
6
  comfy_route :cms_admin
7
7
  comfy_route :cms
8
8
  end
@@ -4,4 +4,4 @@
4
4
  require_relative 'application'
5
5
 
6
6
  # Initialize the rails application
7
- ComfortableMediaSurfer::Application.initialize!
7
+ ComfyMiddleSeat::Application.initialize!
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'active_support/core_ext/integer/time'
4
4
 
5
- defined?(ComfortableMediaSurfer::Application) && ComfortableMediaSurfer::Application.configure do
5
+ defined?(ComfyMiddleSeat::Application) && ComfyMiddleSeat::Application.configure do
6
6
  # Settings specified here will take precedence over those in config/application.rb.
7
7
 
8
8
  # In the development environment your application's code is reloaded any time
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'active_support/core_ext/integer/time'
4
4
 
5
- defined?(ComfortableMediaSurfer::Application) && ComfortableMediaSurfer::Application.configure do
5
+ defined?(ComfyMiddleSeat::Application) && ComfyMiddleSeat::Application.configure do
6
6
  # Settings specified here will take precedence over those in config/application.rb.
7
7
 
8
8
  # Code is not reloaded between requests.
@@ -7,7 +7,7 @@ require 'active_support/core_ext/integer/time'
7
7
  # your test database is "scratch space" for the test suite and is wiped
8
8
  # and recreated between test runs. Don't rely on the data there!
9
9
 
10
- defined?(ComfortableMediaSurfer::Application) && ComfortableMediaSurfer::Application.configure do
10
+ defined?(ComfyMiddleSeat::Application) && ComfyMiddleSeat::Application.configure do
11
11
  # Settings specified here will take precedence over those in config/application.rb.
12
12
 
13
13
  config.active_job.queue_adapter = :test # added for Rails 7.1
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- ComfortableMediaSurfer.configure do |config|
3
+ ComfyMiddleSeat.configure do |config|
4
4
  # Title of the admin area
5
5
  # config.cms_title = 'Comfy CMS Engine'
6
6
 
@@ -88,10 +88,10 @@ ComfortableMediaSurfer.configure do |config|
88
88
  # }
89
89
  end
90
90
 
91
- # Default credentials for ComfortableMediaSurfer::AccessControl::AdminAuthentication
91
+ # Default credentials for ComfyMiddleSeat::AccessControl::AdminAuthentication
92
92
  # YOU REALLY WANT TO CHANGE THIS BEFORE PUTTING YOUR SITE LIVE
93
- ComfortableMediaSurfer::AccessControl::AdminAuthentication.username = 'user'
94
- ComfortableMediaSurfer::AccessControl::AdminAuthentication.password = 'pass'
93
+ ComfyMiddleSeat::AccessControl::AdminAuthentication.username = 'user'
94
+ ComfyMiddleSeat::AccessControl::AdminAuthentication.password = 'pass'
95
95
 
96
96
  # Uncomment this module and `config.admin_auth` above to use custom admin authentication
97
97
  # module ComfyAdminAuthentication
@@ -64,6 +64,13 @@ ar:
64
64
  snippets: مقتطفات
65
65
  files: ملفات
66
66
 
67
+ forms:
68
+ unsaved_changes: لديك تغييرات غير محفوظة. هل أنت متأكد أنك تريد مغادرة هذه الصفحة؟
69
+
70
+ search:
71
+ submit: بحث
72
+ clear: مسح
73
+
67
74
  sites:
68
75
  created: موقع جديد تم انشاءه
69
76
  creation_failure: فشل في إنشاء الموقع
@@ -129,6 +136,8 @@ ar:
129
136
  index:
130
137
  title: الصفحات
131
138
  new_link: إنشاء صفحة جديدة
139
+ search_placeholder: البحث في الصفحات حسب العنوان أو الاسم المختصر أو المسار أو المحتوى
140
+ no_results: لم يتم العثور على صفحات.
132
141
  index_branch:
133
142
  toggle: تبديل
134
143
  add_child_page: أضف صفحة فرعية
@@ -152,6 +161,9 @@ ar:
152
161
  choose_link: اختر الصفحة...
153
162
 
154
163
  fragments:
164
+ loading: جارٍ تحميل محتوى التخطيط…
165
+ load_error: تعذر تحميل محتوى التخطيط. تم الاحتفاظ بالمحتوى الحالي.
166
+ discard_confirmation: لا يمكن الاحتفاظ ببعض المحتوى في التخطيط المحدد. هل تريد استبداله على أي حال؟
155
167
  form_fragments:
156
168
  no_tags: |-
157
169
  لا يحتوي التخطيط على علامات محتوى محددة.<br/>
@@ -235,6 +247,8 @@ ar:
235
247
  title: ملفات
236
248
  new_link: رفع ملف جديد
237
249
  button: رفع الملفات
250
+ search_placeholder: البحث في الملفات حسب العنوان أو الوصف أو اسم الملف
251
+ no_results: لم يتم العثور على ملفات.
238
252
  new:
239
253
  title: ملف جديد
240
254
  edit:
@@ -64,6 +64,13 @@ ca:
64
64
  snippets: Fragments
65
65
  files: Arxius
66
66
 
67
+ forms:
68
+ unsaved_changes: Teniu canvis sense desar. Esteu segur que voleu sortir d'aquesta pàgina?
69
+
70
+ search:
71
+ submit: Cerca
72
+ clear: Neteja
73
+
67
74
  sites:
68
75
  created: S'ha creat el lloc
69
76
  creation_failure: El lloc no s'ha pogut ser crear
@@ -129,6 +136,8 @@ ca:
129
136
  index:
130
137
  title: Pàgines
131
138
  new_link: Crea una nova pàgina
139
+ search_placeholder: Cerca pàgines per nom, slug, ruta o contingut
140
+ no_results: No s'ha trobat cap pàgina.
132
141
  index_branch:
133
142
  toggle: Canvia
134
143
  add_child_page: Afegeix una pàgina filla
@@ -152,6 +161,9 @@ ca:
152
161
  choose_link: Sel·leccioneu una pàgina…
153
162
 
154
163
  fragments:
164
+ loading: S'està carregant el contingut del disseny…
165
+ load_error: No s'ha pogut carregar el contingut del disseny. S'ha conservat el contingut actual.
166
+ discard_confirmation: Part del contingut no es pot conservar en el disseny seleccionat. Voleu substituir-lo igualment?
155
167
  form_fragments:
156
168
  no_tags: |-
157
169
  La plantilla no té etiquetes de contingut definides.<br/>
@@ -235,6 +247,8 @@ ca:
235
247
  title: Arxius
236
248
  new_link: Puja un nou arxiu
237
249
  button: Carrega els arxius
250
+ search_placeholder: Cerca arxius per nom, descripció o nom de fitxer
251
+ no_results: No s'ha trobat cap arxiu.
238
252
  new:
239
253
  title: Nou arxiu
240
254
  edit:
@@ -64,6 +64,13 @@ cs:
64
64
  snippets: Úryvky
65
65
  files: Soubory
66
66
 
67
+ forms:
68
+ unsaved_changes: Máte neuložené změny. Opravdu chcete tuto stránku opustit?
69
+
70
+ search:
71
+ submit: Hledat
72
+ clear: Vymazat
73
+
67
74
  sites:
68
75
  created: Web vytvořen
69
76
  creation_failure: Nepodařilo se vytvořit web
@@ -129,6 +136,8 @@ cs:
129
136
  index:
130
137
  title: Stránky
131
138
  new_link: Vytvořit novou stránku
139
+ search_placeholder: Hledat stránky podle popisu, části URL, cesty nebo obsahu
140
+ no_results: Nebyly nalezeny žádné stránky.
132
141
  index_branch:
133
142
  toggle: Přepnout
134
143
  add_child_page: Přidat podstránku
@@ -152,6 +161,9 @@ cs:
152
161
  choose_link: Select page...
153
162
 
154
163
  fragments:
164
+ loading: Načítání obsahu rozložení…
165
+ load_error: Obsah rozložení se nepodařilo načíst. Váš aktuální obsah byl zachován.
166
+ discard_confirmation: Některý obsah nelze ve vybraném rozložení zachovat. Přesto ho nahradit?
155
167
  form_fragments:
156
168
  no_tags: |-
157
169
  Rozložení nedefinuje žádné obsahové značky.<br/>
@@ -235,6 +247,8 @@ cs:
235
247
  title: Soubory
236
248
  new_link: Nahrát nový soubor
237
249
  button: Nahrát soubory
250
+ search_placeholder: Hledat soubory podle názvu, popisu nebo názvu souboru
251
+ no_results: Nebyly nalezeny žádné soubory.
238
252
  new:
239
253
  title: Nový soubor
240
254
  edit: