5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-07-01 20:46:07 +00:00

mostrar un error si no se pudo procesar la imagen

This commit is contained in:
f 2018-10-31 18:55:50 -03:00
parent c40538a9f7
commit daba9e3058
No known key found for this signature in database
GPG key ID: F3FDAB97B5F9F7E7
2 changed files with 8 additions and 7 deletions

View file

@ -234,7 +234,7 @@ class Post
i.store! v.tempfile
v = i.url
end
rescue CarrierWave::IntegrityError => e
rescue CarrierWave::ProcessingError, CarrierWave::IntegrityError => e
v = e.message
end
end
@ -267,10 +267,9 @@ class Post
# XXX este es un principio de validación de plantillas, aunque no es
# recursivo
template_fields.each do |tf|
# TODO descubrir de mejor forma que el archivo no es del formato
# correcto
if tf.image? && [get_front_matter(tf.key)].flatten.compact.map { |i| i.split('/').to_a.count <= 1 }.any?
add_error validate: get_front_matter(tf.key)
errors = [get_front_matter(tf.key)].flatten.compact
if tf.image? && errors.map { |i| File.exist?(File.join(site.path, i)) }.none?
add_error Hash[tf.key.to_sym, errors]
end
end
end

View file

@ -1,8 +1,10 @@
- unless @post.errors.empty?
.alert.alert-danger
%ul
- @post.errors.each do |_,error|
%li= error
- @post.errors.each do |key, error|
%li
%strong= @post.template_fields.find { |tf| tf.key == key.to_s }.try(:label) || key
= [error].flatten.join("\n")
-# TODO seleccionar la dirección por defecto según el idioma actual
- direction = @post.get_front_matter('dir') || 'ltr'