5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-26 07:16:21 +00:00

campo de permalink

closes #145
closes #79
This commit is contained in:
f 2020-11-11 14:41:12 -03:00
parent f4a632a947
commit 1878749910
3 changed files with 32 additions and 0 deletions

View file

@ -0,0 +1,22 @@
# frozen_string_literal: true
# Este metadato permite generar rutas manuales.
class MetadataPermalink < MetadataString
# Los permalinks nunca pueden ser privados
def private?
false
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)
value = value.strip.gsub('..', '/').gsub('./', '').squeeze('/')
value = value[1..-1] if value.start_with? '/'
value += '/' if File.extname(value).blank?
value
end
end

View file

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

View file

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