From 26d186721d6df1f76a602caf176fd444e54f0a91 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 6 May 2021 12:33:28 -0300 Subject: [PATCH] algunos metadatos son indexables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit solo los de texto que no se refieran a otros artículos por ahora --- app/models/metadata_array.rb | 8 ++++++++ app/models/metadata_content.rb | 8 ++++++++ app/models/metadata_document_date.rb | 4 ++++ app/models/metadata_related_posts.rb | 4 ++++ app/models/metadata_string.rb | 4 ++++ app/models/metadata_template.rb | 6 ++++++ 6 files changed, 34 insertions(+) diff --git a/app/models/metadata_array.rb b/app/models/metadata_array.rb index 5c0b16f7..5f43b790 100644 --- a/app/models/metadata_array.rb +++ b/app/models/metadata_array.rb @@ -13,6 +13,14 @@ class MetadataArray < MetadataTemplate false end + def indexable? + true + end + + def to_s + value.join(', ') + end + private # TODO: Sanitizar otros valores diff --git a/app/models/metadata_content.rb b/app/models/metadata_content.rb index 525f38ab..546e08c8 100644 --- a/app/models/metadata_content.rb +++ b/app/models/metadata_content.rb @@ -19,6 +19,14 @@ class MetadataContent < MetadataTemplate document.content end + def indexable? + true + end + + def to_s + sanitizer.sanitize value, tags: [], attributes: [] + end + private # Detectar si el contenido estaba en Markdown y pasarlo a HTML diff --git a/app/models/metadata_document_date.rb b/app/models/metadata_document_date.rb index 39e68735..a52cd051 100644 --- a/app/models/metadata_document_date.rb +++ b/app/models/metadata_document_date.rb @@ -11,6 +11,10 @@ class MetadataDocumentDate < MetadataTemplate document.date end + def indexable? + true + end + # El valor puede ser un Date, Time o una String en el formato # "yyyy-mm-dd" def value diff --git a/app/models/metadata_related_posts.rb b/app/models/metadata_related_posts.rb index 9a73dea9..bcc18d86 100644 --- a/app/models/metadata_related_posts.rb +++ b/app/models/metadata_related_posts.rb @@ -18,6 +18,10 @@ class MetadataRelatedPosts < MetadataArray false end + def indexable? + false + end + private # Obtiene todos los posts y opcionalmente los filtra diff --git a/app/models/metadata_string.rb b/app/models/metadata_string.rb index ed50bc88..724c2ef3 100644 --- a/app/models/metadata_string.rb +++ b/app/models/metadata_string.rb @@ -7,6 +7,10 @@ class MetadataString < MetadataTemplate super || '' end + def indexable? + true + end + private # No se permite HTML en las strings diff --git a/app/models/metadata_template.rb b/app/models/metadata_template.rb index 58000596..2fa8a61e 100644 --- a/app/models/metadata_template.rb +++ b/app/models/metadata_template.rb @@ -7,6 +7,12 @@ MetadataTemplate = Struct.new(:site, :document, :name, :label, :type, :value, :help, :required, :errors, :post, :layout, keyword_init: true) do + + # Determina si el campo es indexable + def indexable? + false + end + def inspect "#<#{self.class} site=#{site.name.inspect} post=#{post.id.inspect} value=#{value.inspect}>" end