5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-24 11:26:23 +00:00

Merge branch 'issue-14169' of https://0xacab.org/sutty/sutty into 17.3.alpine.panel.sutty.nl

This commit is contained in:
Sutty 2023-09-13 20:52:43 +00:00
commit b4ba1382c3
6 changed files with 29 additions and 2 deletions

View file

@ -0,0 +1,14 @@
# frozen_string_literal: true
# Fecha y hora de creación
class MetadataCreatedAt < MetadataTemplate
# Por defecto la hora actual
def default_value
Time.now
end
# Nunca cambia
def value=(new_value)
value
end
end

View file

@ -12,7 +12,7 @@ class Post
DEFAULT_ATTRIBUTES = %i[site document layout].freeze
# Otros atributos que no vienen en los metadatos
PRIVATE_ATTRIBUTES = %i[path slug attributes errors].freeze
PUBLIC_ATTRIBUTES = %i[lang date uuid].freeze
PUBLIC_ATTRIBUTES = %i[lang date uuid created_at].freeze
ATTR_SUFFIXES = %w[? =].freeze
attr_reader :attributes, :errors, :layout, :site, :document
@ -221,6 +221,11 @@ class Post
post: self, required: true)
end
# La fecha de creación inmodificable del post
def created_at
@metadata[:created_at] ||= MetadataCreatedAt.new(document: document, site: site, layout: layout, name: :created_at, type: :timestamp, post: self, required: true)
end
# Detecta si es un atributo válido o no, a partir de la tabla de la
# plantilla
def attribute?(mid)
@ -271,7 +276,6 @@ class Post
# Y que no se procese liquid
yaml['liquid'] = false
yaml['usuaries'] = usuaries.map(&:id).uniq
yaml['created_at'] ||= modified_at.dup
yaml['last_modified_at'] = modified_at
"#{yaml.to_yaml}---\n\n#{body}"

View file

@ -0,0 +1,4 @@
%tr{ id: attribute }
%th= post_label_t(attribute, post: post)
%td{ dir: dir, lang: locale }
%time{ datetime: metadata.value.xmlschema }= l metadata.value

View file

@ -0,0 +1 @@
-# nada

View file

@ -530,6 +530,8 @@ en:
feedback: 'This field cannot be empty!'
uuid:
label: 'Unique identifier'
created_at:
label: 'Created at'
geo:
uri: 'Open in app'
osm: 'Open in web map'

View file

@ -538,6 +538,8 @@ es:
feedback: '¡Este campo no puede estar vacío!'
uuid:
label: 'Identificador único'
created_at:
label: 'Fecha de creación'
geo:
uri: 'Abrir en aplicación'
osm: 'Abrir en mapa web'