Compare commits

...

6 Commits

Author SHA1 Message Date
Harry Bomrah 0ce35c692d added random albums 2016-10-13 16:27:34 +05:30
JiangRu 958e801fc7 fix albums sort by rand 2016-07-20 15:24:39 +08:00
Harry Bomrah 5f848cbffa Merge branch 'master' of gitlab.tp.rulingcom.com:saurabh/gallery into thumb_width_200 2015-03-30 17:00:00 +08:00
manson 54b33b5fc3 fix thumb resize_to_limit 2015-02-13 15:10:37 +08:00
manson a0768d5076 fix thumb image 2015-02-13 14:57:12 +08:00
manson 5f5acf9b6d change show method image thumb size 2015-02-13 14:48:55 +08:00
2 changed files with 42 additions and 10 deletions

View File

@ -1,20 +1,52 @@
class GalleriesController < ApplicationController
def index
albums = Album.filter_by_categories
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"
}
params = OrbitHelper.params
page = Page.where(:page_id => params[:page_id]).first
if page.layout.starts_with?("random")
data = get_random_data
else
data = get_data
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
{
"albums" => galleries,
"extras" => {"widget-title"=>"Gallery"},
"total_pages" => albums.total_pages
}
end
def show

View File

@ -50,7 +50,7 @@ class GalleryUploader < CarrierWave::Uploader::Base
# end
version :thumb do
process :resize_to_fill => [200, 200]
process :resize_to_limit => [200, nil]
end
version :theater do