gallery/app/controllers/galleries_controller.rb

79 lines
2.1 KiB
Ruby
Raw Normal View History

class GalleriesController < ApplicationController
def index
albums = Album.filter_by_categories.collect do |a|
{
"album-name" => a.name,
"album-description" => a.description,
"link_to_show" => OrbitHelper.url_to_show(a.to_param),
"thumb-src" => a.cover_path || "/assets/gallery/default.jpg"
}
end
{
"albums" => 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|
{
"image-description" => a.description,
2014-05-23 06:04:26 +00:00
"link_to_show" => "/" + I18n.locale.to_s + params[:url] + "/-" + a.id.to_s + "?method=theater",
"thumb-src" => a.file.thumb.url
}
2014-05-23 06:04:26 +00:00
end
{
"images" => images,
"data" => {"album-title"=>album.name}
}
end
def widget
albums = Album.filter_by_widget_categories
params = OrbitHelper.params
2014-05-23 06:04:26 +00:00
images = []
2014-06-17 08:39:39 +00:00
total_images = 0
if !albums.blank?
2014-06-17 08:39:39 +00:00
albums.each do |album|
total_images = total_images + album.album_images.count
end
total_images = total_images > 9 ? 9 : total_images
while images.count < total_images and images.count < AlbumImage.count
albums.each do |album|
img = album.album_images.sample
if !images.include?(img) && img != nil
images << img
end
2014-05-23 06:04:26 +00:00
end
end
end
images = images.collect do |a|
{
2014-05-24 11:38:25 +00:00
"link_to_show" => OrbitHelper.widget_more_url + "/-" + a.id.to_s + "?method=theater",
2014-05-23 06:04:26 +00:00
"thumb-src" => a.file.thumb.url
}
end
{
"images" => images,
2014-05-24 11:38:25 +00:00
"extras" => {"widget-title"=>"Gallery","more_url" => OrbitHelper.widget_more_url}
}
2014-05-23 06:04:26 +00:00
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