mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-28 11:46:20 +00:00
refactor: usar constantes
This commit is contained in:
parent
df3989a187
commit
2ac91e4faf
1 changed files with 9 additions and 12 deletions
|
@ -1,5 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module MetadataTemplateConstants
|
||||
ALLOWED_ATTRIBUTES = %w[style href src alt controls data-align data-multimedia data-multimedia-inner id name].freeze
|
||||
ALLOWED_TAGS = %w[strong em del u mark p h1 h2 h3 h4 h5 h6 ul ol li img iframe audio video div figure blockquote
|
||||
figcaption a sub sup small].freeze
|
||||
end
|
||||
|
||||
# Representa la plantilla de un campo en los metadatos del artículo
|
||||
#
|
||||
# TODO: Validar el tipo de valor pasado a value= según el :type
|
||||
|
@ -8,6 +14,7 @@
|
|||
MetadataTemplate = Struct.new(:site, :document, :name, :label, :type,
|
||||
:value, :help, :required, :errors, :post,
|
||||
:layout, keyword_init: true) do
|
||||
include MetadataTemplateConstants
|
||||
include Metadata::FrontMatterConcern
|
||||
|
||||
# @return [String]
|
||||
|
@ -222,8 +229,8 @@ MetadataTemplate = Struct.new(:site, :document, :name, :label, :type,
|
|||
|
||||
sanitizer
|
||||
.sanitize(string.tr("\r", '').unicode_normalize,
|
||||
tags: allowed_tags,
|
||||
attributes: allowed_attributes)
|
||||
tags: ALLOWED_TAGS,
|
||||
attributes: ALLOWED_ATTRIBUTES)
|
||||
.strip
|
||||
.html_safe
|
||||
end
|
||||
|
@ -233,16 +240,6 @@ MetadataTemplate = Struct.new(:site, :document, :name, :label, :type,
|
|||
@sanitizer ||= Rails::Html::Sanitizer.safe_list_sanitizer.new
|
||||
end
|
||||
|
||||
def allowed_attributes
|
||||
@allowed_attributes ||= %w[style href src alt controls data-align data-multimedia data-multimedia-inner id
|
||||
name].freeze
|
||||
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 figure blockquote
|
||||
figcaption a sub sup small].freeze
|
||||
end
|
||||
|
||||
# Decifra el valor
|
||||
#
|
||||
# @todo Agregar el error de decifrado en self.errors
|
||||
|
|
Loading…
Reference in a new issue