From 3c8dc2d2cc69a46359df655671b76cc9abf87cbf Mon Sep 17 00:00:00 2001 From: f Date: Sat, 14 Nov 2020 18:02:30 -0300 Subject: [PATCH] guardar y mostrar el html guardado --- app/models/metadata_template.rb | 13 ++++++++++++- app/views/posts/attributes/_content.haml | 3 ++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/models/metadata_template.rb b/app/models/metadata_template.rb index 597a5ec3..2aedadf4 100644 --- a/app/models/metadata_template.rb +++ b/app/models/metadata_template.rb @@ -7,7 +7,6 @@ MetadataTemplate = Struct.new(:site, :document, :name, :label, :type, :value, :help, :required, :errors, :post, :layout, keyword_init: true) do - include ActionText::ContentHelper attr_reader :value_was @@ -124,6 +123,18 @@ MetadataTemplate = Struct.new(:site, :document, :name, :label, :type, tags: allowed_tags, attributes: allowed_attributes, scrubber: scrubber).strip.html_safe + en, + + def sanitizer + @sanitizer ||= Rails::Html::Sanitizer.safe_list_sanitizer.new + end + + def allowed_attributes + @allowed_attributes ||= %w[style src alt controls data-align] + end + + def allowed_tags + @allowed_tags ||= %w[strong em del u mark p h1 h2 h3 h4 h5 h6 ul ol li img iframe audio video div] end # Decifra el valor diff --git a/app/views/posts/attributes/_content.haml b/app/views/posts/attributes/_content.haml index 81bc702c..db4210c7 100644 --- a/app/views/posts/attributes/_content.haml +++ b/app/views/posts/attributes/_content.haml @@ -4,7 +4,7 @@ post: post, attribute: attribute, metadata: metadata .editor - = text_area_tag "post[#{attribute}]", metadata.value, + = text_area_tag "post[#{attribute}]", '', dir: dir, lang: locale, **field_options(attribute, metadata), class: 'd-none' @@ -70,3 +70,4 @@ %input.form-control{ type: 'url', data: { prop: 'link-href' } }/ .editor-content.form-control.h-auto{ contenteditable: 'true' } + = metadata.value