Update galleries_controller.rb

merge change with eric's
This commit is contained in:
chiu 2019-11-05 21:31:11 +08:00
parent bf0f561c2e
commit 3925c22408
1 changed files with 54 additions and 61 deletions

View File

@ -35,9 +35,7 @@ class GalleriesController < ApplicationController
"extras" => {"widget-title"=>"Gallery"}, "extras" => {"widget-title"=>"Gallery"},
"total_pages" => albums.total_pages "total_pages" => albums.total_pages
} }
end end
def show def show
params = OrbitHelper.params params = OrbitHelper.params
album = Album.find_by_param(params[:uid]) album = Album.find_by_param(params[:uid])
@ -57,13 +55,11 @@ class GalleriesController < ApplicationController
"album-description" => (flag ? "<p><span>#{album.description}</span></p>" : "")} "album-description" => (flag ? "<p><span>#{album.description}</span></p>" : "")}
} }
end end
def widget def widget
tags = OrbitHelper.widget_tags.empty? ? ["all"] : OrbitHelper.widget_tags tags = OrbitHelper.widget_tags.empty? ? ["all"] : OrbitHelper.widget_tags
albums = Album.filter_by_widget_categories.filter_by_tags(tags) albums = Album.filter_by_widget_categories.filter_by_tags(tags)
params = OrbitHelper.params params = OrbitHelper.params
counts = OrbitHelper.widget_data_count counts = OrbitHelper.widget_data_count
images = [] images = []
total_images = 0 total_images = 0
if !albums.blank? if !albums.blank?
@ -84,7 +80,6 @@ class GalleriesController < ApplicationController
end end
images = images.collect do |a| images = images.collect do |a|
alt_text = (a.description.nil? || a.description == "" ? "gallery image" : a.description) alt_text = (a.description.nil? || a.description == "" ? "gallery image" : a.description)
{ {
"link_to_show" => OrbitHelper.widget_more_url + "/" + a.album.to_param + "#" + a.id.to_s, "link_to_show" => OrbitHelper.widget_more_url + "/" + a.album.to_param + "#" + a.id.to_s,
"alt_title" => alt_text, "alt_title" => alt_text,
@ -93,7 +88,8 @@ class GalleriesController < ApplicationController
"thumb-large-src" => a.file.thumb_large.url, "thumb-large-src" => a.file.thumb_large.url,
"image_description" => a.description, "image_description" => a.description,
"mobile-src" => a.file.mobile.url, "mobile-src" => a.file.mobile.url,
"theater-src" => a.file.theater.url "theater-src" => a.file.theater.url,
"album-name" => a.album.name_translations[I18n.locale]
} }
end end
{ {
@ -101,7 +97,6 @@ class GalleriesController < ApplicationController
"extras" => {"widget-title"=>"Gallery","more_url" => OrbitHelper.widget_more_url} "extras" => {"widget-title"=>"Gallery","more_url" => OrbitHelper.widget_more_url}
} }
end end
def imgs(album_id) def imgs(album_id)
album = Album.find(album_id) album = Album.find(album_id)
tag_names = Array.new tag_names = Array.new
@ -120,7 +115,6 @@ class GalleriesController < ApplicationController
end end
return output return output
end end
def theater def theater
image = AlbumImage.find(params[:id]) image = AlbumImage.find(params[:id])
albumid = image.album_id albumid = image.album_id
@ -131,7 +125,6 @@ class GalleriesController < ApplicationController
"image" => image.id.to_s, "image" => image.id.to_s,
"images" => imgs(albumid) "images" => imgs(albumid)
} }
render :json => {"data" => data}.to_json render :json => {"data" => data}.to_json
end end
private private