fix error
This commit is contained in:
parent
16ff105bc7
commit
a192a000c5
|
@ -36,35 +36,12 @@ class GalleriesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
page = OrbitHelper.page
|
set_image_version
|
||||||
@album_setting = AlbumSetting.first
|
@album_setting = AlbumSetting.first
|
||||||
page_no = OrbitHelper.page_number
|
page_no = OrbitHelper.page_number
|
||||||
data_count = OrbitHelper.page_data_count
|
data_count = OrbitHelper.page_data_count
|
||||||
albums = Album.filter_by_categories.filter_by_tags.asc(:order).page(page_no).per(data_count)
|
albums = Album.filter_by_categories.filter_by_tags.asc(:order).page(page_no).per(data_count)
|
||||||
album_color_map = AlbumColor.where(:album_id.in=> albums.pluck(:id)).pluck(:album_id,:color,:album_card_background_color,:album_card_text_color).map{|v| [v[0],v[1..-1]]}.to_h
|
album_color_map = AlbumColor.where(:album_id.in=> albums.pluck(:id)).pluck(:album_id,:color,:album_card_background_color,:album_card_text_color).map{|v| [v[0],v[1..-1]]}.to_h
|
||||||
@image_version = 'thumb'
|
|
||||||
ModuleApp.all.select{|tmp| tmp.key.to_s=='gallery'}.each do |modile_app|
|
|
||||||
@show_option_items = modile_app.show_option_items rescue nil
|
|
||||||
end
|
|
||||||
if !(@show_option_items.nil?)
|
|
||||||
I18n.with_locale(:en) do
|
|
||||||
page.select_option_items.each do |select_option_item|
|
|
||||||
case select_option_item.field_name
|
|
||||||
when @show_option_items.keys[1].to_s
|
|
||||||
value = YAML.load(select_option_item.value)
|
|
||||||
tmp = value[:en]
|
|
||||||
if tmp == t('gallery.small_size')
|
|
||||||
@image_version = 'thumb'
|
|
||||||
elsif tmp == t('gallery.medium_size')
|
|
||||||
@image_version = 'thumb_large'
|
|
||||||
elsif tmp == t('gallery.large_size')
|
|
||||||
@image_version = 'mobile'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
galleries = albums.collect do |a|
|
galleries = albums.collect do |a|
|
||||||
doc = Nokogiri::HTML(a.description.to_s)
|
doc = Nokogiri::HTML(a.description.to_s)
|
||||||
alt_text = doc.text.empty? ? 'gallery image' : doc.text
|
alt_text = doc.text.empty? ? 'gallery image' : doc.text
|
||||||
|
@ -103,12 +80,26 @@ class GalleriesController < ApplicationController
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
def show
|
def show
|
||||||
|
set_image_version
|
||||||
@album_setting = AlbumSetting.first
|
@album_setting = AlbumSetting.first
|
||||||
params = OrbitHelper.params
|
params = OrbitHelper.params
|
||||||
album = Album.find_by_param(params[:uid].to_s)
|
album = Album.find_by_param(params[:uid].to_s)
|
||||||
flag = show_desc?
|
flag = show_desc?
|
||||||
colors = (AlbumColor.where(:album_id=> album.id).pluck(:color,:album_card_background_color,:album_card_text_color)[0])||[] rescue []
|
colors = (AlbumColor.where(:album_id=> album.id).pluck(:color,:album_card_background_color,:album_card_text_color)[0])||[] rescue []
|
||||||
images = album.album_images.asc(:order).collect do |a|
|
images = album.album_images.asc(:order).collect do |a|
|
||||||
|
src = a.file.url
|
||||||
|
thumb_large_src = a.file.thumb_large.url
|
||||||
|
mobile_src = a.file.mobile.url
|
||||||
|
theater_src = a.file.theater.url
|
||||||
|
case @image_version
|
||||||
|
when 'thumb'
|
||||||
|
thumb_src = a.file.thumb.url
|
||||||
|
when 'thumb_large'
|
||||||
|
thumb_src = thumb_large_src
|
||||||
|
when 'mobile'
|
||||||
|
thumb_src = mobile_src
|
||||||
|
end
|
||||||
|
|
||||||
alt_text = (a.description.blank? ? "gallery image" : Nokogiri::HTML(a.description.to_s).text())
|
alt_text = (a.description.blank? ? "gallery image" : Nokogiri::HTML(a.description.to_s).text())
|
||||||
{
|
{
|
||||||
"image-description" => (flag ? a.description : ''),
|
"image-description" => (flag ? a.description : ''),
|
||||||
|
@ -116,10 +107,10 @@ class GalleriesController < ApplicationController
|
||||||
"alt_title" => alt_text,
|
"alt_title" => alt_text,
|
||||||
"link_to_show" => "#" + a.id.to_s,
|
"link_to_show" => "#" + a.id.to_s,
|
||||||
"src" => a.file.url,
|
"src" => a.file.url,
|
||||||
"thumb-src" => a.file.thumb.url,
|
"thumb-src" => thumb_src,
|
||||||
"thumb-large-src" => a.file.thumb_large.url,
|
"thumb-large-src" => thumb_large_src,
|
||||||
"mobile-src" => a.file.mobile.url,
|
"mobile-src" => mobile_src,
|
||||||
"theater-src" => a.file.theater.url,
|
"theater-src" => theater_src,
|
||||||
|
|
||||||
"album_color" => iterate_data(colors[1],colors[0],@album_setting.album_card_background_color,'transparent'),
|
"album_color" => iterate_data(colors[1],colors[0],@album_setting.album_card_background_color,'transparent'),
|
||||||
"album_card_text_color" => iterate_data(colors[2],@album_setting.album_card_text_color)
|
"album_card_text_color" => iterate_data(colors[2],@album_setting.album_card_text_color)
|
||||||
|
@ -272,4 +263,30 @@ class GalleriesController < ApplicationController
|
||||||
end
|
end
|
||||||
flag
|
flag
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_image_version
|
||||||
|
page = OrbitHelper.page
|
||||||
|
@image_version = 'thumb'
|
||||||
|
ModuleApp.all.select{|tmp| tmp.key.to_s=='gallery'}.each do |modile_app|
|
||||||
|
@show_option_items = modile_app.show_option_items rescue nil
|
||||||
|
end
|
||||||
|
if !(@show_option_items.nil?)
|
||||||
|
I18n.with_locale(:en) do
|
||||||
|
page.select_option_items.each do |select_option_item|
|
||||||
|
case select_option_item.field_name
|
||||||
|
when @show_option_items.keys[1].to_s
|
||||||
|
value = YAML.load(select_option_item.value)
|
||||||
|
tmp = value[:en]
|
||||||
|
if tmp == t('gallery.small_size')
|
||||||
|
@image_version = 'thumb'
|
||||||
|
elsif tmp == t('gallery.medium_size')
|
||||||
|
@image_version = 'thumb_large'
|
||||||
|
elsif tmp == t('gallery.large_size')
|
||||||
|
@image_version = 'mobile'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue