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.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/.travis.yml +5 -2
- data/Gemfile +5 -0
- data/Rakefile +2 -0
- data/app/assets/javascripts/comfy/admin/cms/application.js +40 -0
- data/app/assets/javascripts/comfy/admin/cms/base.js +46 -0
- data/app/assets/javascripts/comfy/admin/cms/categories.js +17 -0
- data/app/assets/javascripts/comfy/admin/cms/codemirror.js +31 -0
- data/app/assets/javascripts/comfy/admin/cms/custom.js +1 -0
- data/app/assets/javascripts/comfy/admin/cms/diff.js +10 -0
- data/app/assets/javascripts/comfy/admin/cms/file_link.js +67 -0
- data/app/assets/javascripts/comfy/admin/cms/file_upload.js +194 -0
- data/app/assets/javascripts/comfy/admin/cms/files_modal.js +40 -0
- data/app/assets/javascripts/comfy/admin/cms/page_fragments.js +22 -0
- data/app/assets/javascripts/comfy/admin/cms/slugify.js +34 -0
- data/app/assets/javascripts/comfy/admin/cms/sortable_list.js +40 -0
- data/app/assets/javascripts/comfy/admin/cms/timepicker.js +30 -0
- data/app/assets/javascripts/comfy/admin/cms/wysiwyg.js +65 -0
- data/app/assets/javascripts/comfy/vendor/redactor.js +12 -6
- data/app/assets/stylesheets/comfy/admin/cms/base.sass +32 -35
- data/app/controllers/application_controller.rb +2 -0
- data/app/controllers/comfy/admin/base_controller.rb +3 -1
- data/app/controllers/comfy/admin/cms/base_controller.rb +9 -1
- data/app/controllers/comfy/admin/cms/categories_controller.rb +2 -0
- data/app/controllers/comfy/admin/cms/files_controller.rb +3 -1
- data/app/controllers/comfy/admin/cms/layouts_controller.rb +2 -0
- data/app/controllers/comfy/admin/cms/pages_controller.rb +4 -1
- data/app/controllers/comfy/admin/cms/revisions/base_controller.rb +2 -0
- data/app/controllers/comfy/admin/cms/revisions/layout_controller.rb +2 -0
- data/app/controllers/comfy/admin/cms/revisions/page_controller.rb +2 -0
- data/app/controllers/comfy/admin/cms/revisions/snippet_controller.rb +2 -0
- data/app/controllers/comfy/admin/cms/revisions/translation_controller.rb +2 -0
- data/app/controllers/comfy/admin/cms/sites_controller.rb +2 -0
- data/app/controllers/comfy/admin/cms/snippets_controller.rb +2 -0
- data/app/controllers/comfy/admin/cms/translations_controller.rb +8 -0
- data/app/controllers/comfy/cms/assets_controller.rb +2 -0
- data/app/controllers/comfy/cms/base_controller.rb +4 -2
- data/app/controllers/comfy/cms/content_controller.rb +3 -1
- data/app/controllers/concerns/comfy/paginate.rb +2 -0
- data/app/controllers/concerns/comfy/reorder_action.rb +2 -0
- data/app/helpers/comfy/admin/cms_helper.rb +19 -0
- data/app/helpers/comfy/cms_helper.rb +4 -2
- data/app/models/comfy/cms/categorization.rb +2 -0
- data/app/models/comfy/cms/category.rb +2 -0
- data/app/models/comfy/cms/file.rb +2 -0
- data/app/models/comfy/cms/fragment.rb +3 -1
- data/app/models/comfy/cms/layout.rb +3 -1
- data/app/models/comfy/cms/page.rb +3 -1
- data/app/models/comfy/cms/revision.rb +2 -0
- data/app/models/comfy/cms/site.rb +5 -1
- data/app/models/comfy/cms/snippet.rb +2 -0
- data/app/models/comfy/cms/translation.rb +2 -0
- data/app/models/concerns/comfy/cms/with_categories.rb +2 -0
- data/app/models/concerns/comfy/cms/with_fragments.rb +2 -0
- data/app/views/comfy/admin/cms/categories/_index.html.haml +3 -3
- data/app/views/comfy/admin/cms/categories/create.js.erb +1 -1
- data/app/views/comfy/admin/cms/categories/destroy.js.erb +8 -3
- data/app/views/comfy/admin/cms/files/_file.html.haml +9 -10
- data/app/views/comfy/admin/cms/files/_modal.html.haml +1 -2
- data/app/views/comfy/admin/cms/files/destroy.js.erb +4 -0
- data/app/views/comfy/admin/cms/files/index.html.haml +10 -10
- data/app/views/comfy/admin/cms/fragments/_form_fragment_attachments.html.haml +15 -6
- data/app/views/comfy/admin/cms/fragments/_form_fragments.html.haml +17 -21
- data/app/views/comfy/admin/cms/pages/_form.html.haml +3 -2
- data/app/views/comfy/admin/cms/pages/toggle_branch.js.erb +3 -1
- data/app/views/comfy/admin/cms/translations/_form.html.haml +3 -2
- data/app/views/layouts/comfy/admin/cms.html.haml +0 -1
- data/app/views/layouts/comfy/admin/cms/_body.html.haml +1 -0
- data/app/views/layouts/comfy/admin/cms/_left.html.haml +1 -1
- data/comfortable_mexican_sofa.gemspec +3 -2
- data/config.ru +2 -0
- data/config/application.rb +2 -0
- data/config/boot.rb +2 -0
- data/config/cms_routes.rb +2 -0
- data/config/environment.rb +2 -0
- data/config/environments/development.rb +2 -0
- data/config/environments/test.rb +2 -0
- data/config/initializers/comfortable_mexican_sofa.rb +2 -0
- data/lib/comfortable_mexican_sofa.rb +2 -0
- data/lib/comfortable_mexican_sofa/access_control/admin_authentication.rb +2 -0
- data/lib/comfortable_mexican_sofa/access_control/admin_authorization.rb +2 -0
- data/lib/comfortable_mexican_sofa/access_control/public_authentication.rb +2 -0
- data/lib/comfortable_mexican_sofa/access_control/public_authorization.rb +2 -0
- data/lib/comfortable_mexican_sofa/configuration.rb +3 -0
- data/lib/comfortable_mexican_sofa/content.rb +3 -0
- data/lib/comfortable_mexican_sofa/content/block.rb +2 -0
- data/lib/comfortable_mexican_sofa/content/params_parser.rb +59 -41
- data/lib/comfortable_mexican_sofa/content/renderer.rb +18 -4
- data/lib/comfortable_mexican_sofa/content/tag.rb +20 -5
- data/lib/comfortable_mexican_sofa/content/tags/asset.rb +2 -0
- data/lib/comfortable_mexican_sofa/content/tags/checkbox.rb +10 -3
- data/lib/comfortable_mexican_sofa/content/tags/date.rb +3 -1
- data/lib/comfortable_mexican_sofa/content/tags/datetime.rb +3 -1
- data/lib/comfortable_mexican_sofa/content/tags/file.rb +21 -27
- data/lib/comfortable_mexican_sofa/content/tags/file_link.rb +23 -24
- data/lib/comfortable_mexican_sofa/content/tags/files.rb +11 -9
- data/lib/comfortable_mexican_sofa/content/tags/fragment.rb +11 -1
- data/lib/comfortable_mexican_sofa/content/tags/helper.rb +3 -1
- data/lib/comfortable_mexican_sofa/content/tags/markdown.rb +3 -1
- data/lib/comfortable_mexican_sofa/content/tags/mixins/file_content.rb +38 -0
- data/lib/comfortable_mexican_sofa/content/tags/number.rb +3 -1
- data/lib/comfortable_mexican_sofa/content/tags/page_file_link.rb +82 -0
- data/lib/comfortable_mexican_sofa/content/tags/partial.rb +3 -1
- data/lib/comfortable_mexican_sofa/content/tags/snippet.rb +2 -0
- data/lib/comfortable_mexican_sofa/content/tags/template.rb +3 -1
- data/lib/comfortable_mexican_sofa/content/tags/text.rb +3 -1
- data/lib/comfortable_mexican_sofa/content/tags/textarea.rb +3 -1
- data/lib/comfortable_mexican_sofa/content/tags/wysiwyg.rb +3 -1
- data/lib/comfortable_mexican_sofa/engine.rb +2 -1
- data/lib/comfortable_mexican_sofa/error.rb +2 -0
- data/lib/comfortable_mexican_sofa/extensions/acts_as_tree.rb +2 -0
- data/lib/comfortable_mexican_sofa/extensions/has_revisions.rb +2 -0
- data/lib/comfortable_mexican_sofa/form_builder.rb +24 -17
- data/lib/comfortable_mexican_sofa/render_methods.rb +2 -0
- data/lib/comfortable_mexican_sofa/routes/cms.rb +2 -0
- data/lib/comfortable_mexican_sofa/routes/cms_admin.rb +2 -0
- data/lib/comfortable_mexican_sofa/routing.rb +2 -0
- data/lib/comfortable_mexican_sofa/seeds.rb +3 -1
- data/lib/comfortable_mexican_sofa/seeds/file/exporter.rb +2 -0
- data/lib/comfortable_mexican_sofa/seeds/file/importer.rb +2 -0
- data/lib/comfortable_mexican_sofa/seeds/layout/exporter.rb +2 -0
- data/lib/comfortable_mexican_sofa/seeds/layout/importer.rb +2 -0
- data/lib/comfortable_mexican_sofa/seeds/page/exporter.rb +2 -0
- data/lib/comfortable_mexican_sofa/seeds/page/importer.rb +2 -0
- data/lib/comfortable_mexican_sofa/seeds/snippet/exporter.rb +2 -0
- data/lib/comfortable_mexican_sofa/seeds/snippet/importer.rb +2 -0
- data/lib/comfortable_mexican_sofa/version.rb +3 -1
- data/lib/comfortable_mexican_sofa/view_hooks.rb +2 -0
- data/lib/generators/comfy/cms/assets_generator.rb +2 -0
- data/lib/generators/comfy/cms/cms_generator.rb +6 -4
- data/lib/generators/comfy/cms/controllers_generator.rb +2 -0
- data/lib/generators/comfy/cms/models_generator.rb +2 -0
- data/lib/generators/comfy/cms/views_generator.rb +2 -0
- data/lib/generators/comfy/scaffold/scaffold_generator.rb +6 -2
- data/lib/tasks/cms_seeds.rake +2 -0
- metadata +20 -26
- data/app/assets/javascripts/comfy/admin/cms/application.js.coffee +0 -30
- data/app/assets/javascripts/comfy/admin/cms/base.js.coffee +0 -224
- data/app/assets/javascripts/comfy/admin/cms/custom.js.coffee +0 -1
- data/app/assets/javascripts/comfy/admin/cms/files.js.coffee +0 -29
- data/app/assets/javascripts/comfy/admin/cms/uploader.js.coffee +0 -140
- data/app/views/comfy/admin/cms/files/create.js.erb +0 -1
- data/app/views/comfy/admin/cms/files/destroy.js.coffee +0 -2
- data/app/views/comfy/admin/cms/pages/form_fragments.js.erb +0 -1
- 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::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::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]
|
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]
|
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
|
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
|
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
|
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
|
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::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
|
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
|
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
|
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::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
|
-
|
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?
|
@@ -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
|
-
=
|
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
|
-
|
2
|
-
|
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
|
-
|
11
|
-
|
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
|
-
-
|
27
|
-
|
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(
|
32
|
-
= link_to t(
|
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-
|
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: ''}
|
@@ -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
|
-
|
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
|
-
|
4
|
-
|
5
|
-
|
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
|
-
-
|
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
|