5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-16 18:36:22 +00:00

asociar el archivo subido al post

This commit is contained in:
f 2022-03-04 19:21:26 -03:00
parent 03d9913f58
commit fdbe724f7c

View file

@ -43,13 +43,7 @@ class MetadataFile < MetadataTemplate
# repetida.
def save
value['description'] = sanitize value['description']
if path?
hardlink
value['path'] = relative_destination_path
else
value['path'] = nil
end
value['path'] = static_file ? relative_destination_path_with_filename.to_s : nil
true
end
@ -110,6 +104,28 @@ class MetadataFile < MetadataTemplate
private
# Obtener la ruta al archivo relativa al sitio
#
# @return [Pathname]
def destination_path
Pathname.new(static_file_path)
end
# Agrega el nombre de archivo a la ruta para tener retrocompatibilidad
#
# @return [Pathname]
def destination_path_with_filename
destination_path.realpath
end
def relative_destination_path_with_filename
destination_path_with_filename.relative_path_from(site.path)
end
def static_file_path
static_file.blob.service.path_for(static_file.key)
end
# No hay archivo pero se lo describió
def no_file_for_description?
!path? && description?