mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-16 15:51:41 +00:00
asociar el archivo subido al post
This commit is contained in:
parent
03d9913f58
commit
fdbe724f7c
1 changed files with 23 additions and 7 deletions
|
@ -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?
|
||||
|
|
Loading…
Reference in a new issue