Fix bug.
This commit is contained in:
parent
473b3bf02e
commit
39fa7aed06
|
@ -52,8 +52,14 @@ class WebResourcesController < ApplicationController
|
|||
elsif link.link_open == "local"
|
||||
target = "_self"
|
||||
end
|
||||
doc = Nokogiri::HTML(link.title.to_s)
|
||||
text = doc.css("body")[0].text rescue ""
|
||||
if text.blank? && doc.css("img").count != 0
|
||||
text = doc.css("img").map{|img| img.attr("alt") rescue ""}.select{|t| t.present?}.first
|
||||
end
|
||||
{
|
||||
"title" => link.title,
|
||||
"title_text" => text,
|
||||
"context" => link.context,
|
||||
"statuses" => statuses,
|
||||
"link_to_show" => link.url,
|
||||
|
|
Loading…
Reference in New Issue