orbit-gallery/app/controllers/panel/gallery/front_end/albums_controller.rb

49 lines
1.4 KiB
Ruby

class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController
def index
@albums = Album.where(:category_id.in => params[:category_id])
end
def show
@album = Album.find(params[:id])
@images = @album.album_images
end
def imgs
@album = Album.find(params[:id])
@images = @album.album_images.all
@output = Array.new
@images.each do |values|
tags = Tag.find(values.tagged_ids).map{|t| t.name}
@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.album_id,
:tag_ids => values.tag_ids,
:tag_names => tags}
end
render :json=>{:images => @output}.to_json
end
def images_tags
album = Album.find(params[:album_id])
tags = Array.new
images = album.album_images.all
images.each do |image|
tags << {"id"=>image.id, "tags" => image.tag_ids}
end
render :json=>tags.to_json
end
def theater
@image = AlbumImage.find(params[:image_id])
@albumid = @image.album_id
@album = Album.find(@albumid)
@images = @album.album_images.all
tags = @album.tagged_ids
@tagnames = Tag.find(tags).map{|t| t.name}
@back_link = panel_gallery_front_end_album_path(@albumid)
end
end