5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2025-02-22 14:01:51 +00:00

Merge branch 'issue-3871' into production.panel.sutty.nl

This commit is contained in:
f 2025-01-27 15:37:10 -03:00
commit 2113b31e11
No known key found for this signature in database
5 changed files with 37 additions and 9 deletions

View file

@ -7,12 +7,25 @@ class MetadataPermalink < MetadataString
false
end
# Devuelve la URL actual del sitio
#
# @return [String, nil]
def default_value
if post.written?
super.presence || document.url
else
super.presence
end
end
private
# Al hacer limpieza, validamos la ruta. Eliminamos / multiplicadas,
# puntos suspensivos, la primera / para que siempre sea relativa y
# agregamos una / al final si la ruta no tiene extensión.
def sanitize(value)
return value.strip if value.blank?
value = value.strip.unicode_normalize.gsub('..', '/').gsub('./', '').squeeze('/')
value = value[1..-1] if value.start_with? '/'
value += '/' if File.extname(value).blank?

View file

@ -413,6 +413,18 @@ class Post
included
end
# Devuelve la URL absoluta
#
# @return [String, nil]
def absolute_url
return unless written?
@absolute_url ||=
URI.parse(site.url).tap do |uri|
uri.path = document.url
end.to_s
end
private
# Levanta un error si al construir el artículo no pasamos un atributo.

View file

@ -435,7 +435,9 @@ class Site < ApplicationRecord
# Si estamos usando nuestro propio plugin de i18n, los posts están
# en "colecciones"
locales.map(&:to_s).each do |i|
@configuration['collections'][i] = {}
@configuration['collections'][i] = {
'permalink' => configuration.send(:style_to_permalink, configuration['permalink'])
}
end
@configuration

View file

@ -1,3 +1,3 @@
%tr{ id: attribute }
%th= post_label_t(attribute, post: post)
%td{ dir: dir, lang: locale }= metadata.value
%td{ dir: dir, lang: locale }= link_to post.absolute_url, post.absolute_url, target: '_blank', rel: 'noopener'

View file

@ -1,7 +1,8 @@
.form-group
= label_tag "#{base}_#{attribute}", post_label_t(attribute, post: post)
= text_field base, attribute, value: metadata.value,
dir: dir, lang: locale,
**field_options(attribute, metadata)
= render 'posts/attribute_feedback',
post: post, attribute: attribute, metadata: metadata
- if post.written?
.form-group
= label_tag "#{base}_#{attribute}", post_label_t(attribute, post: post)
= text_field base, attribute, value: metadata.value,
dir: dir, lang: locale,
**field_options(attribute, metadata)
= render 'posts/attribute_feedback',
post: post, attribute: attribute, metadata: metadata