Update galleries_controller.rb

fix the show error of the text have style
This commit is contained in:
chiu 2019-09-30 22:38:43 +08:00
parent 99c1f94515
commit 474a06455b
1 changed files with 10 additions and 9 deletions

View File

@ -20,15 +20,16 @@ class GalleriesController < ApplicationController
def index def index
albums = Album.filter_by_categories.filter_by_tags.asc(:order) albums = Album.filter_by_categories.filter_by_tags.asc(:order)
galleries = albums.collect do |a| galleries = albums.collect do |a|
alt_text = (a.description.nil? || a.description == "" ? "gallery image" : a.description) doc = Nokogiri::HTML(a.description.to_s)
{ alt_text = doc.text.empty? ? 'gallery image' : doc.text
"album-name" => a.name, {
"album-description" => a.description, "album-name" => a.name,
"alt_title" => alt_text, "album-description" => a.description,
"link_to_show" => OrbitHelper.url_to_show(a.to_param), "alt_title" => alt_text,
"thumb-src" => a.cover_path || "/assets/gallery/default.jpg" "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"},