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

View file

@ -1,8 +1,10 @@
- unless @post.errors.empty? - unless @post.errors.empty?
.alert.alert-danger .alert.alert-danger
%ul %ul
- @post.errors.each do |_,error| - @post.errors.each do |key, error|
%li= 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 -# TODO seleccionar la dirección por defecto según el idioma actual
- direction = @post.get_front_matter('dir') || 'ltr' - direction = @post.get_front_matter('dir') || 'ltr'