5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-05-03 07:57:05 +00:00

feat: mostrar detalles como desplegable

This commit is contained in:
f 2024-04-19 15:06:56 -03:00
parent bcf3925d9b
commit 382f0545d1
No known key found for this signature in database
4 changed files with 58 additions and 31 deletions

View file

@ -0,0 +1,17 @@
-#
Detail Cola de Moderación
@param :id [String] El ID opcional sirve para mantener el historial de
cuál estaba abierto y recuperarlo al cargar la página
@param :summary [String] El resumen
@param :summary_class [String] Clases para el summary
- local_assigns[:summary_class] ||= 'h3'
- local_assigns[:details_class] ||= 'py-2'
%details.details{ id: local_assigns[:id], class: local_assigns[:details_class], data: { controller: 'details', action: 'toggle->details#store' } }
%summary.d-flex.flex-row.align-items-center.justify-content-between{ class: local_assigns[:summary_class] }
%span= summary
%span.hide-when-open ▶
%span.show-when-open ▼
= yield

View file

@ -0,0 +1,34 @@
-#
Muestra una tabla con todos los atributos de un post
@param site [Site]
@param locale [Symbol]
@param dir [String]
@param post [Post]
@param title [String]
%table.table.table-condensed
%thead
%tr
%th.text-center{ colspan: 2 }= title
%tbody
- post.attributes.each do |attr|
- metadata = post[attr]
- next unless metadata.front_matter?
- cache [post, metadata, I18n.locale] do
= render("posts/attribute_ro/#{metadata.type}",
post: post, attribute: attr,
metadata: metadata,
site: site,
locale: locale,
dir: dir)
-# Mostrar todo lo que no va en el front_matter (el contenido)
- post.attributes.each do |attr|
- metadata = post[attr]
- next if metadata.front_matter?
- cache [post, metadata, I18n.locale] do
%section.content.pb-3{ id: attr, dir: dir }
= metadata.to_s.html_safe

View file

@ -1,6 +1,6 @@
%tr{ id: attribute }
%th= post_label_t(attribute, post: post)
%td{ dir: dir, lang: locale }
- p = metadata.has_one
- if p
= link_to p.title.value, site_post_path(site, p.id)
%td{ dir: dir, lang: locale, colspan: 2 }
- if (p = metadata.has_one)
= render 'layouts/details', details_class: '', summary_class: 'font-weight-bold', summary: post_label_t(attribute, post: post) do
.mt-3
= render 'posts/table', site: site, post: p, dir: dir, locale: locale, title: p.layout.humanized_name

View file

@ -1,4 +1,5 @@
- dir = @site.data.dig(params[:locale], 'dir')
.row.justify-content-center
.col-md-8
%article.content.table-responsive-md
@ -6,29 +7,4 @@
edit_site_post_path(@site, @post.id),
class: 'btn btn-secondary btn-block'
%table.table.table-condensed
%thead
%tr
%th.text-center{ colspan: 2 }= t('.front_matter')
%tbody
- @post.attributes.each do |attr|
- metadata = @post[attr]
- next unless metadata.front_matter?
- cache [metadata, I18n.locale] do
= render("posts/attribute_ro/#{metadata.type}",
post: @post, attribute: attr,
metadata: metadata,
site: @site,
tags: all_html_tags,
locale: @locale,
dir: dir)
-# Mostrar todo lo que no va en el front_matter (el contenido)
- @post.attributes.each do |attr|
- metadata = @post[attr]
- next if metadata.front_matter?
- cache [metadata, I18n.locale] do
%section.content.pb-3{ id: attr, dir: dir }
= @post.public_send(attr).to_s.html_safe
= render 'table', dir: dir, site: @site, locale: @locale, post: @post, title: t('.front_matter')