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), theater_link: panel_gallery_back_end_album_image_path(values),
description: values.description, description: values.description,
title: values.title, title: values.title,
file: values.file, file: values.file.as_json[:file],
gallery_album_id: values.gallery_album_id, gallery_album_id: values.gallery_album_id,
tag_ids: values.tag_ids, tag_ids: values.tag_ids,
tag_names: tags} tag_names: tags}

View File

@ -1,110 +1,104 @@
class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController
def index
end
def index 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 show def imgs
@album = GalleryAlbum.find(params[:id]) @album = GalleryAlbum.find(params[:id])
@tags = Array.new @images = @album.gallery_images.all
@album.tag_ids.each do |tag| @output = Array.new
@tags << GalleryTag.find(tag)[I18n.locale] @images.each do |values|
end tags = Array.new
values.tag_ids.each do |tag|
end tags << GalleryTag.find(tag)[I18n.locale]
end
def get_albums @output << {:_id => values.id,
@categoryids = params["cid"] :theater_link => theater_panel_gallery_front_end_album_path(values),
@tags = params["tid"] :description => values.description,
@albums = Array.new :title => values.title,
if @categoryids == "all" :file => values.file.as_json[:file],
if @tags :gallery_album_id => values.gallery_album_id,
if @tags.kind_of?(Array) :tag_ids => values.tag_ids,
@tags.each do |tag| :tag_names => tags}
@albums << GalleryAlbum.where(tag_ids: tag) end
end render :json=>{:images => @output}.to_json
else end
@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 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 end