From 88155330751fbe034daf8651cf293198ea881855 Mon Sep 17 00:00:00 2001 From: Rueshyna Date: Thu, 3 Jan 2013 18:16:00 +0800 Subject: [PATCH] correct pic file format --- .../gallery/back_end/albums_controller.rb | 2 +- .../gallery/front_end/albums_controller.rb | 200 +++++++++--------- 2 files changed, 98 insertions(+), 104 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 fa7b5e3b..56f6f189 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 @@ -177,7 +177,7 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController theater_link: panel_gallery_back_end_album_image_path(values), description: values.description, title: values.title, - file: values.file, + file: values.file.as_json[:file], gallery_album_id: values.gallery_album_id, tag_ids: values.tag_ids, tag_names: tags} diff --git a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/front_end/albums_controller.rb b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/front_end/albums_controller.rb index 51ba47cb..07f85999 100644 --- a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/front_end/albums_controller.rb +++ b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/front_end/albums_controller.rb @@ -1,110 +1,104 @@ class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController - - def index - - end + def index + end - def show - @album = GalleryAlbum.find(params[:id]) - @tags = Array.new - @album.tag_ids.each do |tag| - @tags << GalleryTag.find(tag)[I18n.locale] - end + def show + @album = GalleryAlbum.find(params[:id]) + @tags = Array.new + @album.tag_ids.each do |tag| + @tags << GalleryTag.find(tag)[I18n.locale] + end + end - end + def get_albums + @categoryids = params["cid"] + @tags = params["tid"] + @albums = Array.new + if @categoryids == "all" + if @tags + if @tags.kind_of?(Array) + @tags.each do |tag| + @albums << GalleryAlbum.where(tag_ids: tag) + end + else + @albums << GalleryAlbum.where(tag_ids: @tags) + end + else + @albums << GalleryAlbum.all + end + else + @categoryids.each do |id| + category = GalleryCategory.find(id) + if @tags + if @tags.kind_of?(Array) + @tags.each do |tag| + @albums << category.gallery_albums.where(tag_ids: tag) + end + else + @albums << category.gallery_albums.where(tag_ids: @tags) + end + else + @albums << category.gallery_albums.all + end + end + end + @output = Array.new + @albums.each do |album| + @albs = Array.new + album.each do |values| + tags = Array.new + values.tag_ids.each do |tag| + tags << GalleryTag.find(tag)[I18n.locale] + end + category = GalleryCategory.find(values.gallery_category_id).name + @albs << {"_id"=>values.id,"show_path"=>panel_gallery_front_end_album_path(values),"cover"=>values.cover,"cover_path"=>values.cover_path,"description"=>values.description,"category_name"=>category,"gallery_category_id" => values.gallery_category_id,"name"=>values.name,"tag_ids"=>values.tag_ids,"tag_names"=>tags} + end + @output << @albs + end + render :json=>@output.to_json + end - def get_albums - @categoryids = params["cid"] - @tags = params["tid"] - @albums = Array.new - if @categoryids == "all" - if @tags - if @tags.kind_of?(Array) - @tags.each do |tag| - @albums << GalleryAlbum.where(tag_ids: tag) - end - else - @albums << GalleryAlbum.where(tag_ids: @tags) - end - else - @albums << GalleryAlbum.all - end - else - @categoryids.each do |id| - category = GalleryCategory.find(id) - if @tags - if @tags.kind_of?(Array) - @tags.each do |tag| - @albums << category.gallery_albums.where(tag_ids: tag) - end - else - @albums << category.gallery_albums.where(tag_ids: @tags) - end - else - @albums << category.gallery_albums.all - end - end - end - @output = Array.new - @albums.each do |album| - @albs = Array.new - album.each do |values| - tags = Array.new - values.tag_ids.each do |tag| - tags << GalleryTag.find(tag)[I18n.locale] - end - category = GalleryCategory.find(values.gallery_category_id).name - @albs << {"_id"=>values.id,"show_path"=>panel_gallery_front_end_album_path(values),"cover"=>values.cover,"cover_path"=>values.cover_path,"description"=>values.description,"category_name"=>category,"gallery_category_id" => values.gallery_category_id,"name"=>values.name,"tag_ids"=>values.tag_ids,"tag_names"=>tags} - end - @output << @albs - end - render :json=>@output.to_json - end - - - - def imgs - @album = GalleryAlbum.find(params[:id]) - @images = @album.gallery_images.all - @output = Array.new - @images.each do |values| - tags = Array.new - values.tag_ids.each do |tag| - tags << GalleryTag.find(tag)[I18n.locale] - end - @output << {"_id"=>values.id,"theater_link"=>theater_panel_gallery_front_end_album_path(values),"description"=>values.description,"title"=>values.title,"file"=>values.file,"gallery_album_id"=>values.gallery_album_id,"tag_ids"=>values.tag_ids,"tag_names"=>tags} - end - render :json=>{"images" => @output}.to_json - end - - def images_tags - album = GalleryAlbum.find(params[:album_id]) - tags = Array.new - images = album.gallery_images.all - images.each do |image| - tags << {"id"=>image.id, "tags" => image.tag_ids} - end - render :json=>tags.to_json - end - - def theater - @image = GalleryImage.find(params[:id]) - @albumid = @image.gallery_album_id - @album = GalleryAlbum.find(@albumid) - @images = @album.gallery_images.all - tags = @album.tag_ids - @tagnames = Array.new - tags.each do |tag| - @tagnames << GalleryTag.find(tag)[I18n.locale] - end - @back_link = panel_gallery_front_end_album_path(@albumid) - end + def imgs + @album = GalleryAlbum.find(params[:id]) + @images = @album.gallery_images.all + @output = Array.new + @images.each do |values| + tags = Array.new + values.tag_ids.each do |tag| + tags << GalleryTag.find(tag)[I18n.locale] + end + @output << {:_id => values.id, + :theater_link => theater_panel_gallery_front_end_album_path(values), + :description => values.description, + :title => values.title, + :file => values.file.as_json[:file], + :gallery_album_id => values.gallery_album_id, + :tag_ids => values.tag_ids, + :tag_names => tags} + end + render :json=>{:images => @output}.to_json + end + def images_tags + album = GalleryAlbum.find(params[:album_id]) + tags = Array.new + images = album.gallery_images.all + images.each do |image| + tags << {"id"=>image.id, "tags" => image.tag_ids} + end + render :json=>tags.to_json + end + def theater + @image = GalleryImage.find(params[:id]) + @albumid = @image.gallery_album_id + @album = GalleryAlbum.find(@albumid) + @images = @album.gallery_images.all + tags = @album.tag_ids + @tagnames = Array.new + tags.each do |tag| + @tagnames << GalleryTag.find(tag)[I18n.locale] + end + @back_link = panel_gallery_front_end_album_path(@albumid) + end end - - - - - -