2014-05-05 06:07:18 +00:00
|
|
|
class GalleriesController < ApplicationController
|
|
|
|
def index
|
2014-06-18 11:56:12 +00:00
|
|
|
albums = Album.filter_by_categories
|
|
|
|
galleries = albums.collect do |a|
|
2014-05-05 06:07:18 +00:00
|
|
|
{
|
|
|
|
"album-name" => a.name,
|
2014-06-09 09:56:14 +00:00
|
|
|
"album-description" => a.description,
|
2014-05-05 06:07:18 +00:00
|
|
|
"link_to_show" => OrbitHelper.url_to_show(a.to_param),
|
|
|
|
"thumb-src" => a.cover_path || "/assets/gallery/default.jpg"
|
|
|
|
}
|
|
|
|
end
|
|
|
|
{
|
2014-06-18 11:56:12 +00:00
|
|
|
"albums" => galleries,
|
2014-06-18 10:17:32 +00:00
|
|
|
"extras" => {"widget-title"=>"Gallery"},
|
|
|
|
"total_pages" => albums.total_pages
|
2014-05-05 06:07:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
|
|
|
params = OrbitHelper.params
|
|
|
|
album = Album.find_by_param(params[:uid])
|
2015-04-16 12:07:54 +00:00
|
|
|
images = album.album_images.asc(:order).collect do |a|
|
2014-05-05 06:07:18 +00:00
|
|
|
{
|
2014-06-09 09:56:14 +00:00
|
|
|
"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-05 06:07:18 +00:00
|
|
|
}
|
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
|
2015-02-06 09:04:39 +00:00
|
|
|
counts = OrbitHelper.widget_data_count
|
2014-05-26 02:08:14 +00:00
|
|
|
|
2014-05-23 06:04:26 +00:00
|
|
|
images = []
|
2014-06-17 08:39:39 +00:00
|
|
|
total_images = 0
|
2014-06-04 08:21:15 +00:00
|
|
|
if !albums.blank?
|
2014-06-17 08:39:39 +00:00
|
|
|
albums.each do |album|
|
|
|
|
total_images = total_images + album.album_images.count
|
|
|
|
end
|
2015-02-06 09:04:39 +00:00
|
|
|
total_images = counts > 9 ? 9 : counts
|
|
|
|
while images.count < counts and images.count < AlbumImage.count
|
2014-06-04 08:21:15 +00:00
|
|
|
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
|
2014-05-05 06:07:18 +00:00
|
|
|
{
|
|
|
|
"images" => images,
|
2014-05-24 11:38:25 +00:00
|
|
|
"extras" => {"widget-title"=>"Gallery","more_url" => OrbitHelper.widget_more_url}
|
2014-05-05 06:07:18 +00:00
|
|
|
}
|
2014-05-23 06:04:26 +00:00
|
|
|
end
|
2014-05-05 06:07:18 +00:00
|
|
|
|
2014-10-20 12:25:58 +00:00
|
|
|
def imgs(album_id)
|
|
|
|
album = Album.find(album_id)
|
|
|
|
tag_names = Array.new
|
2015-04-16 12:07:54 +00:00
|
|
|
images = album.album_images.asc(:order)
|
2014-10-20 12:25:58 +00:00
|
|
|
output = Array.new
|
|
|
|
images.each do |values|
|
|
|
|
output << { _id: values.id.to_s,
|
|
|
|
description: values.description,
|
|
|
|
title: values.title,
|
|
|
|
file: values.file.as_json[:file],
|
|
|
|
gallery_album_id: values.album_id,
|
|
|
|
tags: values.tags}
|
|
|
|
end
|
|
|
|
return output
|
|
|
|
end
|
|
|
|
|
2014-05-05 06:07:18 +00:00
|
|
|
def theater
|
|
|
|
params = OrbitHelper.params
|
|
|
|
image = AlbumImage.find(params[:uid])
|
|
|
|
albumid = image.album_id
|
|
|
|
album = Album.find(albumid)
|
2015-04-16 12:07:54 +00:00
|
|
|
images = album.album_images.asc(:order)
|
2014-05-05 06:07:18 +00:00
|
|
|
{
|
|
|
|
"album" => album,
|
|
|
|
"images" => images,
|
|
|
|
"image" => image,
|
2014-10-20 12:25:58 +00:00
|
|
|
"wall_images" => imgs(albumid),
|
2014-05-05 06:07:18 +00:00
|
|
|
"back_to_albums" => OrbitHelper.url_to_show(album.to_param)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|