gallery/app/controllers/galleries_controller.rb

48 lines
1.1 KiB
Ruby

class GalleriesController < ApplicationController
def index
albums = Album.filter_by_categories.collect do |a|
{
"album-name" => a.name,
"link_to_show" => OrbitHelper.url_to_show(a.to_param),
"thumb-src" => a.cover_path || "/assets/gallery/default.jpg"
}
end
{
"data" => albums,
"extras" => {"widget-title"=>"Gallery"}
}
end
def show
params = OrbitHelper.params
album = Album.find_by_param(params[:uid])
images = album.album_images.collect do |a|
{
"link_to_show" => "/" + I18n.locale.to_s + params[:url] + "/-" + a.id.to_s + "?method=theater",
"thumb-src" => a.file.thumb.url
}
end
{
"images" => images,
"data" => {"album-title"=>album.name}
}
end
def theater
params = OrbitHelper.params
image = AlbumImage.find(params[:uid])
albumid = image.album_id
album = Album.find(albumid)
images = album.album_images.all
{
"album" => album,
"images" => images,
"image" => image,
"back_to_albums" => OrbitHelper.url_to_show(album.to_param)
}
end
end