Compare commits
6 Commits
master
...
thumb_widt
Author | SHA1 | Date |
---|---|---|
Harry Bomrah | 0ce35c692d | |
JiangRu | 958e801fc7 | |
Harry Bomrah | 5f848cbffa | |
manson | 54b33b5fc3 | |
manson | a0768d5076 | |
manson | 5f5acf9b6d |
|
@ -1,20 +1,52 @@
|
||||||
class GalleriesController < ApplicationController
|
class GalleriesController < ApplicationController
|
||||||
def index
|
def index
|
||||||
albums = Album.filter_by_categories
|
params = OrbitHelper.params
|
||||||
galleries = albums.collect do |a|
|
page = Page.where(:page_id => params[:page_id]).first
|
||||||
{
|
if page.layout.starts_with?("random")
|
||||||
"album-name" => a.name,
|
data = get_random_data
|
||||||
"album-description" => a.description,
|
else
|
||||||
"link_to_show" => OrbitHelper.url_to_show(a.to_param),
|
data = get_data
|
||||||
"thumb-src" => a.cover_path || "/assets/gallery/default.jpg"
|
end
|
||||||
}
|
|
||||||
|
data
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_random_data
|
||||||
|
categories = OrbitHelper.page_categories
|
||||||
|
if categories.include?("all")
|
||||||
|
albums = Album.all.sample(OrbitHelper.page_data_count)
|
||||||
|
else
|
||||||
|
albums = Album.where(:category_id.in => categories).filter_by_tags.sample(OrbitHelper.page_data_count)
|
||||||
|
end
|
||||||
|
galleries = albums.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" => galleries,
|
||||||
|
"extras" => {"widget-title"=>"Gallery"},
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_data
|
||||||
|
albums = Album.filter_by_categories.filter_by_tags
|
||||||
|
galleries = albums.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
|
end
|
||||||
{
|
{
|
||||||
"albums" => galleries,
|
"albums" => galleries,
|
||||||
"extras" => {"widget-title"=>"Gallery"},
|
"extras" => {"widget-title"=>"Gallery"},
|
||||||
"total_pages" => albums.total_pages
|
"total_pages" => albums.total_pages
|
||||||
}
|
}
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
|
|
@ -50,7 +50,7 @@ class GalleryUploader < CarrierWave::Uploader::Base
|
||||||
# end
|
# end
|
||||||
|
|
||||||
version :thumb do
|
version :thumb do
|
||||||
process :resize_to_fill => [200, 200]
|
process :resize_to_limit => [200, nil]
|
||||||
end
|
end
|
||||||
|
|
||||||
version :theater do
|
version :theater do
|
||||||
|
|
Loading…
Reference in New Issue