From 9095713769b74319528fd6f811e6442de7d334f3 Mon Sep 17 00:00:00 2001 From: chris Date: Tue, 13 Nov 2012 15:21:59 +0800 Subject: [PATCH] Fix bugs in Json when missing files --- .../panel/gallery/back_end/albums_controller.rb | 7 +++---- .../panel/gprs/back_end/locations_controller.rb | 4 ++-- .../app/views/panel/gprs/back_end/locations/index.html.erb | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/albums_controller.rb b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/albums_controller.rb index bf32b693..ee19a269 100644 --- a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/albums_controller.rb +++ b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/albums_controller.rb @@ -132,17 +132,16 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController all_image << { image_title: image.title, image_description: image.description, - image_file: { url: "http://#{request.host_with_port+image.file.url}", - thumb: "http://#{request.host_with_port+image.file.thumb.to_s}"}, + image_file: { url: "http://#{request.host_with_port}#{image.file.url}", + thumb: "http://#{request.host_with_port}#{image.file.thumb.to_s}"}, image_tag_names: tags} end album.tag_ids.each do |tag| tag_names << GalleryTag.find(tag)[I18n.locale] end - output << { - album_cover_file: "http://#{request.host_with_port+album.cover_path}", + album_cover_file: "http://#{request.host_with_port}#{album.cover_path}", album_name: album.name, album_tag_names: tag_names, images: all_image diff --git a/vendor/built_in_modules/gprs/app/controllers/panel/gprs/back_end/locations_controller.rb b/vendor/built_in_modules/gprs/app/controllers/panel/gprs/back_end/locations_controller.rb index 884e5d13..8609cce1 100644 --- a/vendor/built_in_modules/gprs/app/controllers/panel/gprs/back_end/locations_controller.rb +++ b/vendor/built_in_modules/gprs/app/controllers/panel/gprs/back_end/locations_controller.rb @@ -59,8 +59,8 @@ class Panel::Gprs::BackEnd::LocationsController < OrbitBackendController @data = Array.new locations.each do |location| - picurl = "http://#{request.host_with_port + location.file.url}", - thumburl = "http://#{request.host_with_port + location.file.thumb.url}" + picurl = location.file.blank? ? '' : "http://#{request.host_with_port + location.file.url}" + thumburl = location.file.blank? ? '' : "http://#{request.host_with_port + location.file.thumb.url}" @data << { name: location.name, pic_url: picurl, thumb_url: thumburl, diff --git a/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/index.html.erb b/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/index.html.erb index 6731688d..eb8b0485 100644 --- a/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/index.html.erb +++ b/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/index.html.erb @@ -13,7 +13,7 @@ <% @locations.each do |location| %> - <%= image_tag(location.file, alt: location.file, size: "50x50" )%> + <%= image_tag(location.file, alt: location.file, size: "50x50" ) if !location.file.blank? %> <%= location.name%> <%= location.longitude%> <%= location.latitude%>