From 474a06455bcff088cbffd5d084fdebd4c7487bd8 Mon Sep 17 00:00:00 2001 From: chiu Date: Mon, 30 Sep 2019 22:38:43 +0800 Subject: [PATCH] Update galleries_controller.rb fix the show error of the text have style --- app/controllers/galleries_controller.rb | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/app/controllers/galleries_controller.rb b/app/controllers/galleries_controller.rb index 9f15dee..c6bf45f 100644 --- a/app/controllers/galleries_controller.rb +++ b/app/controllers/galleries_controller.rb @@ -20,15 +20,16 @@ class GalleriesController < ApplicationController def index albums = Album.filter_by_categories.filter_by_tags.asc(:order) galleries = albums.collect do |a| - alt_text = (a.description.nil? || a.description == "" ? "gallery image" : a.description) - { - "album-name" => a.name, - "album-description" => a.description, - "alt_title" => alt_text, - "link_to_show" => OrbitHelper.url_to_show(a.to_param), - "thumb-src" => a.cover_path || "/assets/gallery/default.jpg" - } - end + doc = Nokogiri::HTML(a.description.to_s) + alt_text = doc.text.empty? ? 'gallery image' : doc.text + { + "album-name" => a.name, + "album-description" => a.description, + "alt_title" => alt_text, + "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"},