From 0af59fa625ad65810145d2e9565c2b101fd1d75c Mon Sep 17 00:00:00 2001 From: f Date: Tue, 26 May 2020 19:26:19 -0300 Subject: [PATCH] archivos faltantes :$ --- .gitignore | 1 + app/models/metadata_locales.rb | 27 +++++++++++++++++++++++ app/models/metadata_markdown.rb | 3 +++ app/models/metadata_markdown_content.rb | 9 ++++++++ app/views/posts/attributes/_markdown.haml | 8 +++++++ 5 files changed, 48 insertions(+) create mode 100644 app/models/metadata_locales.rb create mode 100644 app/models/metadata_markdown.rb create mode 100644 app/models/metadata_markdown_content.rb create mode 100644 app/views/posts/attributes/_markdown.haml diff --git a/.gitignore b/.gitignore index 8d7772c3..15d27058 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,7 @@ /_sites/* /_deploy/* /data/* +/_storage/* .env diff --git a/app/models/metadata_locales.rb b/app/models/metadata_locales.rb new file mode 100644 index 00000000..5843b04a --- /dev/null +++ b/app/models/metadata_locales.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +# Los valores de este metadato son artículos en otros idiomas +class MetadataLocales < MetadataTemplate + def default_value + [] + end + + # Todos los valores posibles para cada idioma disponible + # + # TODO: Optimizar? + # + # @return { lang: { title: uuid } } + def values + @values ||= site.locales.map do |locale| + { + locale.to_sym => site.posts(lang: locale).map do |post| + { post.title.value => post.uuid.value } + end.inject(:merge) + } + end.inject(:merge) + end + + def to_param + { name => [] } + end +end diff --git a/app/models/metadata_markdown.rb b/app/models/metadata_markdown.rb new file mode 100644 index 00000000..bad2b5a7 --- /dev/null +++ b/app/models/metadata_markdown.rb @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +class MetadataMarkdown < MetadataText; end diff --git a/app/models/metadata_markdown_content.rb b/app/models/metadata_markdown_content.rb new file mode 100644 index 00000000..4d298fee --- /dev/null +++ b/app/models/metadata_markdown_content.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class MetadataMarkdownContent < MetadataContent + # Renderizar a HTML + def to_s + CommonMarker.render_doc(value, %i[FOOTNOTES SMART], + %i[table strikethrough autolink]).to_html + end +end diff --git a/app/views/posts/attributes/_markdown.haml b/app/views/posts/attributes/_markdown.haml new file mode 100644 index 00000000..8c47fdd4 --- /dev/null +++ b/app/views/posts/attributes/_markdown.haml @@ -0,0 +1,8 @@ +.form-group.markdown-content + = label_tag "post_#{attribute}", post_label_t(attribute, post: post) + = text_area_tag "post[#{attribute}]", metadata.value, + dir: dir, lang: locale, + **field_options(attribute, metadata, class: 'content') + .editor.mt-1 + = render 'posts/attribute_feedback', + post: post, attribute: attribute, metadata: metadata