correct pic file format

This commit is contained in:
Rueshyna 2013-01-03 18:16:00 +08:00
parent 8e33313b13
commit 8815533075
2 changed files with 98 additions and 104 deletions

View File

@ -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}

View File

@ -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