comfortable_mexican_sofa 2.0.12 → 2.0.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/.travis.yml +5 -2
  4. data/Gemfile +5 -0
  5. data/Rakefile +2 -0
  6. data/app/assets/javascripts/comfy/admin/cms/application.js +40 -0
  7. data/app/assets/javascripts/comfy/admin/cms/base.js +46 -0
  8. data/app/assets/javascripts/comfy/admin/cms/categories.js +17 -0
  9. data/app/assets/javascripts/comfy/admin/cms/codemirror.js +31 -0
  10. data/app/assets/javascripts/comfy/admin/cms/custom.js +1 -0
  11. data/app/assets/javascripts/comfy/admin/cms/diff.js +10 -0
  12. data/app/assets/javascripts/comfy/admin/cms/file_link.js +67 -0
  13. data/app/assets/javascripts/comfy/admin/cms/file_upload.js +194 -0
  14. data/app/assets/javascripts/comfy/admin/cms/files_modal.js +40 -0
  15. data/app/assets/javascripts/comfy/admin/cms/page_fragments.js +22 -0
  16. data/app/assets/javascripts/comfy/admin/cms/slugify.js +34 -0
  17. data/app/assets/javascripts/comfy/admin/cms/sortable_list.js +40 -0
  18. data/app/assets/javascripts/comfy/admin/cms/timepicker.js +30 -0
  19. data/app/assets/javascripts/comfy/admin/cms/wysiwyg.js +65 -0
  20. data/app/assets/javascripts/comfy/vendor/redactor.js +12 -6
  21. data/app/assets/stylesheets/comfy/admin/cms/base.sass +32 -35
  22. data/app/controllers/application_controller.rb +2 -0
  23. data/app/controllers/comfy/admin/base_controller.rb +3 -1
  24. data/app/controllers/comfy/admin/cms/base_controller.rb +9 -1
  25. data/app/controllers/comfy/admin/cms/categories_controller.rb +2 -0
  26. data/app/controllers/comfy/admin/cms/files_controller.rb +3 -1
  27. data/app/controllers/comfy/admin/cms/layouts_controller.rb +2 -0
  28. data/app/controllers/comfy/admin/cms/pages_controller.rb +4 -1
  29. data/app/controllers/comfy/admin/cms/revisions/base_controller.rb +2 -0
  30. data/app/controllers/comfy/admin/cms/revisions/layout_controller.rb +2 -0
  31. data/app/controllers/comfy/admin/cms/revisions/page_controller.rb +2 -0
  32. data/app/controllers/comfy/admin/cms/revisions/snippet_controller.rb +2 -0
  33. data/app/controllers/comfy/admin/cms/revisions/translation_controller.rb +2 -0
  34. data/app/controllers/comfy/admin/cms/sites_controller.rb +2 -0
  35. data/app/controllers/comfy/admin/cms/snippets_controller.rb +2 -0
  36. data/app/controllers/comfy/admin/cms/translations_controller.rb +8 -0
  37. data/app/controllers/comfy/cms/assets_controller.rb +2 -0
  38. data/app/controllers/comfy/cms/base_controller.rb +4 -2
  39. data/app/controllers/comfy/cms/content_controller.rb +3 -1
  40. data/app/controllers/concerns/comfy/paginate.rb +2 -0
  41. data/app/controllers/concerns/comfy/reorder_action.rb +2 -0
  42. data/app/helpers/comfy/admin/cms_helper.rb +19 -0
  43. data/app/helpers/comfy/cms_helper.rb +4 -2
  44. data/app/models/comfy/cms/categorization.rb +2 -0
  45. data/app/models/comfy/cms/category.rb +2 -0
  46. data/app/models/comfy/cms/file.rb +2 -0
  47. data/app/models/comfy/cms/fragment.rb +3 -1
  48. data/app/models/comfy/cms/layout.rb +3 -1
  49. data/app/models/comfy/cms/page.rb +3 -1
  50. data/app/models/comfy/cms/revision.rb +2 -0
  51. data/app/models/comfy/cms/site.rb +5 -1
  52. data/app/models/comfy/cms/snippet.rb +2 -0
  53. data/app/models/comfy/cms/translation.rb +2 -0
  54. data/app/models/concerns/comfy/cms/with_categories.rb +2 -0
  55. data/app/models/concerns/comfy/cms/with_fragments.rb +2 -0
  56. data/app/views/comfy/admin/cms/categories/_index.html.haml +3 -3
  57. data/app/views/comfy/admin/cms/categories/create.js.erb +1 -1
  58. data/app/views/comfy/admin/cms/categories/destroy.js.erb +8 -3
  59. data/app/views/comfy/admin/cms/files/_file.html.haml +9 -10
  60. data/app/views/comfy/admin/cms/files/_modal.html.haml +1 -2
  61. data/app/views/comfy/admin/cms/files/destroy.js.erb +4 -0
  62. data/app/views/comfy/admin/cms/files/index.html.haml +10 -10
  63. data/app/views/comfy/admin/cms/fragments/_form_fragment_attachments.html.haml +15 -6
  64. data/app/views/comfy/admin/cms/fragments/_form_fragments.html.haml +17 -21
  65. data/app/views/comfy/admin/cms/pages/_form.html.haml +3 -2
  66. data/app/views/comfy/admin/cms/pages/toggle_branch.js.erb +3 -1
  67. data/app/views/comfy/admin/cms/translations/_form.html.haml +3 -2
  68. data/app/views/layouts/comfy/admin/cms.html.haml +0 -1
  69. data/app/views/layouts/comfy/admin/cms/_body.html.haml +1 -0
  70. data/app/views/layouts/comfy/admin/cms/_left.html.haml +1 -1
  71. data/comfortable_mexican_sofa.gemspec +3 -2
  72. data/config.ru +2 -0
  73. data/config/application.rb +2 -0
  74. data/config/boot.rb +2 -0
  75. data/config/cms_routes.rb +2 -0
  76. data/config/environment.rb +2 -0
  77. data/config/environments/development.rb +2 -0
  78. data/config/environments/test.rb +2 -0
  79. data/config/initializers/comfortable_mexican_sofa.rb +2 -0
  80. data/lib/comfortable_mexican_sofa.rb +2 -0
  81. data/lib/comfortable_mexican_sofa/access_control/admin_authentication.rb +2 -0
  82. data/lib/comfortable_mexican_sofa/access_control/admin_authorization.rb +2 -0
  83. data/lib/comfortable_mexican_sofa/access_control/public_authentication.rb +2 -0
  84. data/lib/comfortable_mexican_sofa/access_control/public_authorization.rb +2 -0
  85. data/lib/comfortable_mexican_sofa/configuration.rb +3 -0
  86. data/lib/comfortable_mexican_sofa/content.rb +3 -0
  87. data/lib/comfortable_mexican_sofa/content/block.rb +2 -0
  88. data/lib/comfortable_mexican_sofa/content/params_parser.rb +59 -41
  89. data/lib/comfortable_mexican_sofa/content/renderer.rb +18 -4
  90. data/lib/comfortable_mexican_sofa/content/tag.rb +20 -5
  91. data/lib/comfortable_mexican_sofa/content/tags/asset.rb +2 -0
  92. data/lib/comfortable_mexican_sofa/content/tags/checkbox.rb +10 -3
  93. data/lib/comfortable_mexican_sofa/content/tags/date.rb +3 -1
  94. data/lib/comfortable_mexican_sofa/content/tags/datetime.rb +3 -1
  95. data/lib/comfortable_mexican_sofa/content/tags/file.rb +21 -27
  96. data/lib/comfortable_mexican_sofa/content/tags/file_link.rb +23 -24
  97. data/lib/comfortable_mexican_sofa/content/tags/files.rb +11 -9
  98. data/lib/comfortable_mexican_sofa/content/tags/fragment.rb +11 -1
  99. data/lib/comfortable_mexican_sofa/content/tags/helper.rb +3 -1
  100. data/lib/comfortable_mexican_sofa/content/tags/markdown.rb +3 -1
  101. data/lib/comfortable_mexican_sofa/content/tags/mixins/file_content.rb +38 -0
  102. data/lib/comfortable_mexican_sofa/content/tags/number.rb +3 -1
  103. data/lib/comfortable_mexican_sofa/content/tags/page_file_link.rb +82 -0
  104. data/lib/comfortable_mexican_sofa/content/tags/partial.rb +3 -1
  105. data/lib/comfortable_mexican_sofa/content/tags/snippet.rb +2 -0
  106. data/lib/comfortable_mexican_sofa/content/tags/template.rb +3 -1
  107. data/lib/comfortable_mexican_sofa/content/tags/text.rb +3 -1
  108. data/lib/comfortable_mexican_sofa/content/tags/textarea.rb +3 -1
  109. data/lib/comfortable_mexican_sofa/content/tags/wysiwyg.rb +3 -1
  110. data/lib/comfortable_mexican_sofa/engine.rb +2 -1
  111. data/lib/comfortable_mexican_sofa/error.rb +2 -0
  112. data/lib/comfortable_mexican_sofa/extensions/acts_as_tree.rb +2 -0
  113. data/lib/comfortable_mexican_sofa/extensions/has_revisions.rb +2 -0
  114. data/lib/comfortable_mexican_sofa/form_builder.rb +24 -17
  115. data/lib/comfortable_mexican_sofa/render_methods.rb +2 -0
  116. data/lib/comfortable_mexican_sofa/routes/cms.rb +2 -0
  117. data/lib/comfortable_mexican_sofa/routes/cms_admin.rb +2 -0
  118. data/lib/comfortable_mexican_sofa/routing.rb +2 -0
  119. data/lib/comfortable_mexican_sofa/seeds.rb +3 -1
  120. data/lib/comfortable_mexican_sofa/seeds/file/exporter.rb +2 -0
  121. data/lib/comfortable_mexican_sofa/seeds/file/importer.rb +2 -0
  122. data/lib/comfortable_mexican_sofa/seeds/layout/exporter.rb +2 -0
  123. data/lib/comfortable_mexican_sofa/seeds/layout/importer.rb +2 -0
  124. data/lib/comfortable_mexican_sofa/seeds/page/exporter.rb +2 -0
  125. data/lib/comfortable_mexican_sofa/seeds/page/importer.rb +2 -0
  126. data/lib/comfortable_mexican_sofa/seeds/snippet/exporter.rb +2 -0
  127. data/lib/comfortable_mexican_sofa/seeds/snippet/importer.rb +2 -0
  128. data/lib/comfortable_mexican_sofa/version.rb +3 -1
  129. data/lib/comfortable_mexican_sofa/view_hooks.rb +2 -0
  130. data/lib/generators/comfy/cms/assets_generator.rb +2 -0
  131. data/lib/generators/comfy/cms/cms_generator.rb +6 -4
  132. data/lib/generators/comfy/cms/controllers_generator.rb +2 -0
  133. data/lib/generators/comfy/cms/models_generator.rb +2 -0
  134. data/lib/generators/comfy/cms/views_generator.rb +2 -0
  135. data/lib/generators/comfy/scaffold/scaffold_generator.rb +6 -2
  136. data/lib/tasks/cms_seeds.rake +2 -0
  137. metadata +20 -26
  138. data/app/assets/javascripts/comfy/admin/cms/application.js.coffee +0 -30
  139. data/app/assets/javascripts/comfy/admin/cms/base.js.coffee +0 -224
  140. data/app/assets/javascripts/comfy/admin/cms/custom.js.coffee +0 -1
  141. data/app/assets/javascripts/comfy/admin/cms/files.js.coffee +0 -29
  142. data/app/assets/javascripts/comfy/admin/cms/uploader.js.coffee +0 -140
  143. data/app/views/comfy/admin/cms/files/create.js.erb +0 -1
  144. data/app/views/comfy/admin/cms/files/destroy.js.coffee +0 -2
  145. data/app/views/comfy/admin/cms/pages/form_fragments.js.erb +0 -1
  146. data/app/views/comfy/admin/cms/translations/form_fragments.js.erb +0 -1
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Comfy::Admin::Cms::Revisions::BaseController < Comfy::Admin::Cms::BaseController
2
4
 
3
5
  helper_method :record_path
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Comfy::Admin::Cms::Revisions::LayoutController < Comfy::Admin::Cms::Revisions::BaseController
2
4
 
3
5
  private
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Comfy::Admin::Cms::Revisions::PageController < Comfy::Admin::Cms::Revisions::BaseController
2
4
 
3
5
  def show
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Comfy::Admin::Cms::Revisions::SnippetController < Comfy::Admin::Cms::Revisions::BaseController
2
4
 
3
5
  private
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Comfy::Admin::Cms::Revisions::TranslationController < Comfy::Admin::Cms::Revisions::BaseController
2
4
 
3
5
  def show
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Comfy::Admin::Cms::SitesController < Comfy::Admin::Cms::BaseController
2
4
 
3
5
  skip_before_action :load_admin_site,
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Comfy::Admin::Cms::SnippetsController < Comfy::Admin::Cms::BaseController
2
4
 
3
5
  include ::Comfy::ReorderAction
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Comfy::Admin::Cms::TranslationsController < Comfy::Admin::Cms::BaseController
2
4
 
3
5
  helper_method :translation_select_options
@@ -43,6 +45,12 @@ class Comfy::Admin::Cms::TranslationsController < Comfy::Admin::Cms::BaseControl
43
45
  def form_fragments
44
46
  @translation = @page.translations.find_by(id: params[:id]) || @page.translations.new
45
47
  @translation.layout = @site.layouts.find_by(id: params[:layout_id])
48
+
49
+ render(
50
+ partial: "comfy/admin/cms/fragments/form_fragments",
51
+ locals: { record: @translation, scope: :translation },
52
+ layout: false
53
+ )
46
54
  end
47
55
 
48
56
  private
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Comfy::Cms::AssetsController < Comfy::Cms::BaseController
2
4
 
3
5
  skip_before_action :verify_authenticity_token
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Comfy::Cms::BaseController < ApplicationController
2
4
 
3
5
  before_action :load_cms_site
@@ -16,9 +18,9 @@ protected
16
18
 
17
19
  if @cms_site
18
20
  if @cms_site.path.present? && !params[:site_id]
19
- if params[:cms_path] && params[:cms_path].match(%r{\A#{@cms_site.path}})
21
+ if params[:cms_path]&.match(%r{\A#{@cms_site.path}})
20
22
  params[:cms_path].gsub!(%r{\A#{@cms_site.path}}, "")
21
- params[:cms_path] && params[:cms_path].gsub!(%r{\A/}, "")
23
+ params[:cms_path]&.gsub!(%r{\A/}, "")
22
24
  else
23
25
  raise ActionController::RoutingError, "Site Not Found"
24
26
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Comfy::Cms::ContentController < Comfy::Cms::BaseController
2
4
 
3
5
  # Authentication module must have `authenticate` method
@@ -42,7 +44,7 @@ protected
42
44
  # it's possible to control mimetype of a page by creating a `mime_type` field
43
45
  def mime_type
44
46
  mime_block = @cms_page.fragments.detect { |f| f.identifier == "mime_type" }
45
- mime_block && mime_block.content || "text/html"
47
+ mime_block&.content || "text/html"
46
48
  end
47
49
 
48
50
  def app_layout
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Comfy::Paginate
2
4
 
3
5
  # Wrapper to deal with WillPaginate vs Kaminari nonsense
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Comfy::ReorderAction
2
4
 
3
5
  extend ActiveSupport::Concern
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Comfy
2
4
  module Admin
3
5
  module CmsHelper
@@ -25,6 +27,23 @@ module Comfy
25
27
  ComfortableMexicanSofa::ViewHooks.render(name, self, options)
26
28
  end
27
29
 
30
+ # @param [String] fragment_id
31
+ # @param [ActiveStorage::Blob] attachment
32
+ # @param [Boolean] multiple
33
+ # @return [String] {{ cms:page_file_link #{fragment_id}, ... }}
34
+ def cms_page_file_link_tag(fragment_id:, attachment:, multiple:)
35
+ filename = ", filename: \"#{attachment.filename}\"" if multiple
36
+ as = ", as: image" if attachment.image?
37
+ "{{ cms:page_file_link #{fragment_id}#{filename}#{as} }}"
38
+ end
39
+
40
+ # @param [Comfy::Cms::File] file
41
+ # @return [String] {{ cms:file_link #{file.id}, ... }}
42
+ def cms_file_link_tag(file)
43
+ as = ", as: image" if file.attachment.image?
44
+ "{{ cms:file_link #{file.id}#{as} }}"
45
+ end
46
+
28
47
  end
29
48
  end
30
49
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Comfy
2
4
  module CmsHelper
3
5
 
@@ -7,7 +9,7 @@ module Comfy
7
9
  # cms_fragment_content(:left_column, CmsPage.first)
8
10
  # cms_fragment_content(:left_column) # if @cms_page is present
9
11
  def cms_fragment_content(identifier, page = @cms_page)
10
- frag = page && page.fragments.detect { |f| f.identifier == identifier.to_s }
12
+ frag = page&.fragments&.detect { |f| f.identifier == identifier.to_s }
11
13
  return "" unless frag
12
14
  case frag.tag
13
15
  when "date", "datetime"
@@ -41,7 +43,7 @@ module Comfy
41
43
  end
42
44
  cms_site = Comfy::Cms::Site.find_site(host, path)
43
45
  end
44
- snippet = cms_site && cms_site.snippets.find_by_identifier(identifier)
46
+ snippet = cms_site&.snippets&.find_by_identifier(identifier)
45
47
  return "" unless snippet
46
48
  snippet.content
47
49
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Comfy::Cms::Categorization < ActiveRecord::Base
2
4
 
3
5
  self.table_name = "comfy_cms_categorizations"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Comfy::Cms::Category < ActiveRecord::Base
2
4
 
3
5
  self.table_name = "comfy_cms_categories"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Comfy::Cms::File < ActiveRecord::Base
2
4
 
3
5
  self.table_name = "comfy_cms_files"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Comfy::Cms::Fragment < ActiveRecord::Base
2
4
 
3
5
  self.table_name = "comfy_cms_fragments"
@@ -48,7 +50,7 @@ protected
48
50
  # If we're dealing with a single file
49
51
  if tag == "file"
50
52
  @files = [@files.first]
51
- attachments.purge_later if attachments
53
+ attachments&.purge_later
52
54
  end
53
55
 
54
56
  attachments.attach(@files)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Comfy::Cms::Layout < ActiveRecord::Base
2
4
 
3
5
  self.table_name = "comfy_cms_layouts"
@@ -95,7 +97,7 @@ protected
95
97
  end
96
98
 
97
99
  def assign_position
98
- return if position.to_i > 0
100
+ return if position.to_i.positive?
99
101
  max = site.layouts.where(parent_id: parent_id).maximum(:position)
100
102
  self.position = max ? max + 1 : 0
101
103
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Comfy::Cms::Page < ActiveRecord::Base
2
4
 
3
5
  self.table_name = "comfy_cms_pages"
@@ -123,7 +125,7 @@ protected
123
125
 
124
126
  def assign_position
125
127
  return unless self.parent
126
- return if position.to_i > 0
128
+ return if position.to_i.positive?
127
129
  max = self.parent.children.maximum(:position)
128
130
  self.position = max ? max + 1 : 0
129
131
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Comfy::Cms::Revision < ActiveRecord::Base
2
4
 
3
5
  self.table_name = "comfy_cms_revisions"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Comfy::Cms::Site < ActiveRecord::Base
2
4
 
3
5
  self.table_name = "comfy_cms_sites"
@@ -36,7 +38,9 @@ class Comfy::Cms::Site < ActiveRecord::Base
36
38
  cms_site = nil
37
39
 
38
40
  public_cms_path = ComfortableMexicanSofa.configuration.public_cms_path
39
- path.gsub!(%r{\A#{public_cms_path}}, "") unless path.nil? || public_cms_path == "/"
41
+ if path && public_cms_path != "/"
42
+ path = path.sub(%r{\A#{public_cms_path}}, "")
43
+ end
40
44
 
41
45
  Comfy::Cms::Site.where(hostname: real_host_from_aliases(host)).each do |site|
42
46
  if site.path.blank?
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Comfy::Cms::Snippet < ActiveRecord::Base
2
4
 
3
5
  self.table_name = "comfy_cms_snippets"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Comfy::Cms::Translation < ActiveRecord::Base
2
4
 
3
5
  self.table_name = "comfy_cms_translations"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Comfy::Cms::WithCategories
2
4
 
3
5
  extend ActiveSupport::Concern
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Comfy::Cms::WithFragments
2
4
 
3
5
  extend ActiveSupport::Concern
@@ -7,7 +7,7 @@
7
7
  = link_to t('.all'), {categories: nil}, 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
- %button.toggle-cat-edit.btn.btn-secondary.btn-sm.btn-block
10
+ %button.toggle-cat-edit.btn.btn-secondary.btn-sm.btn-block{type: "button"}
11
11
  = t(".edit")
12
12
 
13
13
  .editable
@@ -16,7 +16,7 @@
16
16
  = render "comfy/admin/cms/categories/show", category: category
17
17
 
18
18
  - url = comfy_admin_cms_site_categories_path(@site)
19
- = form_for :category, url: url, remote: true, html: {id: "new-category"} do |form|
19
+ = form_with scope: :category, url: url, html: {id: "new-category"} do |form|
20
20
  = form.hidden_field :categorized_type, value: type
21
21
  .input-group
22
22
  = form.text_field :label, placeholder: t('.add_placeholder'), class: 'form-control form-control-sm', id: nil
@@ -24,5 +24,5 @@
24
24
  %button.btn.btn-primary.btn-sm{aria: {label: "Create Category"}}
25
25
  %i.fas.fa-fw.fa-plus
26
26
 
27
- %button.toggle-cat-edit.btn.btn-light.btn-sm.btn-block
27
+ %button.toggle-cat-edit.btn.btn-light.btn-sm.btn-block{type: "button"}
28
28
  = t(".done")
@@ -4,4 +4,4 @@ $('.categories-widget .editable .categories').append(
4
4
  $('.categories-widget .read .categories').append(
5
5
  '<%= escape_javascript(render "show", category: @category, read: true) %>'
6
6
  );
7
- $('.categories-widget .editable form#new-category input').val('');
7
+ $('.categories-widget .editable form#new-category input[name="category[label]"]').val('');
@@ -1,3 +1,8 @@
1
- $('.categories .category#<%= dom_id(@category) %>').fadeOut('slow', function(){
2
- $(this).remove()
3
- })
1
+ (() => {
2
+ const categoryElements = document.querySelectorAll('.categories .category#<%= dom_id(@category) %>');
3
+ jQuery(categoryElements).fadeOut('slow', () => {
4
+ for (const element of categoryElements) {
5
+ element.remove();
6
+ }
7
+ });
8
+ })();
@@ -1,4 +1,7 @@
1
1
  %li{data: {id: file.id}}
2
+ :ruby
3
+ file_tag = cms_file_link_tag(file)
4
+ thumb_url = url_for(file.attachment.variant(Comfy::Cms::File::VARIANT_SIZE[:thumb])) if file.attachment.image?
2
5
  .row
3
6
  .col-md-5.item
4
7
  .item-controls.d-none.d-lg-block
@@ -7,12 +10,8 @@
7
10
  %i.fas.fa-bars
8
11
  .item-content
9
12
  .item-title
10
- - if file.attachment.image?
11
- - variant = file.attachment.variant(Comfy::Cms::File::VARIANT_SIZE[:thumb])
12
- - thumb = image_tag(url_for(variant), size: "200x150")
13
- = link_to file.attachment, target: "_blank", data: {toggle: "page-file-popover", content: thumb} do
14
- = file.label
15
-
13
+ = link_to file.label, file.attachment, target: "_blank",
14
+ data: {cms_file_thumb_url: thumb_url, cms_file_link_tag: file_tag}
16
15
  .item-meta
17
16
  .content-type
18
17
  = truncate(file.attachment.content_type)
@@ -23,10 +22,10 @@
23
22
  = render partial: "comfy/admin/cms/categories/categories", object: file
24
23
 
25
24
  .col-md-2.d-flex.align-items-center
26
- - file_tag = "{{cms:file_link #{file.id} }}"
27
- %input.file-path{type: "text", value: file_tag, readonly: "readonly"}
25
+ %span.file-path
26
+ = file_tag
28
27
 
29
28
  .col-md-3.d-flex.align-items-center.justify-content-md-end
30
29
  .btn-group.btn-group-sm
31
- = link_to t('.edit'), edit_comfy_admin_cms_site_file_path(@site, file), class: "btn btn-outline-secondary"
32
- = link_to t('.delete'), comfy_admin_cms_site_file_path(@site, file), method: :delete, remote: true, data: {confirm: t('.are_you_sure')}, class: "btn btn-danger"
30
+ = link_to t(".edit"), edit_comfy_admin_cms_site_file_path(@site, file), class: "btn btn-outline-secondary"
31
+ = link_to t(".delete"), comfy_admin_cms_site_file_path(@site, file), method: :delete, remote: true, data: {confirm: t(".are_you_sure")}, class: "btn btn-danger"
@@ -1,4 +1,3 @@
1
- .modal.fade.cms-files-modal{'aria-hidden' => 'true', 'data-iframe-src' => comfy_admin_cms_site_files_path(@site), role: 'dialog', tabindex: "-1"}
1
+ .modal.fade.cms-files-modal{'aria-hidden' => 'true', 'data-url' => comfy_admin_cms_site_files_path(@site, layout: false), role: 'dialog', tabindex: "-1"}
2
2
  .modal-dialog.modal-lg
3
3
  .modal-content
4
- %iframe{src: ''}
@@ -0,0 +1,4 @@
1
+ (() => {
2
+ const listItem = document.querySelector('li[data-id="<%= @file.id %>"]');
3
+ jQuery(listItem).fadeOut('slow', () => listItem.remove());
4
+ })();
@@ -1,16 +1,16 @@
1
- - content_for :head do
2
-
3
- - uploader_url = comfy_admin_cms_site_files_path(@site, source: :plupload, categories: params[:categories])
4
- %meta{name: "cms-uploader-url", content: uploader_url}
5
- %meta{name: "cms-uploader-token-name", content: request_forgery_protection_token}
6
- %meta{name: "cms-uploader-token-value", content: form_authenticity_token}
7
- %meta{name: "cms-uploader-session-name", content: Rails.application.config.session_options[:key]}
8
- %meta{name: "cms-uploader-session-value", content: request.session_options[:id]}
9
-
10
1
  - content_for :right_column do
11
2
  = render "comfy/admin/cms/categories/index", type: "Comfy::Cms::File"
12
3
 
13
- #cms-uploader
4
+ :ruby
5
+ cms_uploader_data = {
6
+ cms_uploader: {
7
+ url: comfy_admin_cms_site_files_path(@site, source: :plupload, categories: params[:categories]),
8
+ token: {name: request_forgery_protection_token, value: form_authenticity_token},
9
+ session: {name: Rails.application.config.session_options[:key], value: request.session_options[:id]}
10
+ }
11
+ }
12
+
13
+ #cms-uploader{data: cms_uploader_data}
14
14
  #cms-uploader-drag-drop-target
15
15
 
16
16
  .page-header
@@ -1,12 +1,21 @@
1
1
  .fragment-attachments
2
2
  - attachments.each do |attachment|
3
- - if attachment.image?
4
- - variant = attachment.variant(Comfy::Cms::File::VARIANT_SIZE[:thumb])
5
- - thumb = image_tag(url_for(variant), size: "200x150")
3
+ :ruby
4
+ thumb_url = url_for(attachment.variant(Comfy::Cms::File::VARIANT_SIZE[:thumb])) if attachment.image?
5
+ filename = attachment.filename.to_s
6
+ truncated_filename = truncate(filename, length: 40, omission: "...#{filename.last(10)}")
7
+
8
+ link_data = {
9
+ cms_file_thumb_url: thumb_url,
10
+ cms_file_link_tag: cms_page_file_link_tag(
11
+ fragment_id: fragment_id,
12
+ attachment: attachment,
13
+ multiple: multiple
14
+ )
15
+ }
16
+
6
17
  .fragment-attachment.btn-group.btn-group-sm.mb-1
7
- - filename = attachment.filename.to_s
8
- - truncated_filename = truncate(filename, length: 40, omission: "...#{filename.last(10)}")
9
- = link_to truncated_filename, attachment, data: {toggle: "page-file-popover", content: thumb}, class: "btn btn-light text-truncate", target: "_blank"
18
+ = link_to truncated_filename, attachment, data: link_data, class: "btn btn-light text-truncate", target: "_blank"
10
19
  = check_box_tag "#{object_name}[fragments_attributes][#{index}][file_ids_destroy][]", attachment.id, false, id: dom_id(attachment)
11
20
  %label.btn.btn-light{for: dom_id(attachment)}
12
21
  %i.fas.fa-fw.fa-times