lib/onebox/engine/wikipedia_onebox.rb in onebox-1.2.3 vs lib/onebox/engine/wikipedia_onebox.rb in onebox-1.2.4
- old
+ new
@@ -20,10 +20,11 @@
text = ""
unless paras.empty?
cnt = 0
while text.length < Onebox::LayoutSupport.max_text && cnt <= 3
+ break if cnt >= paras.size
text << " " unless cnt == 0
paragraph = paras[cnt].inner_text[0..Onebox::LayoutSupport.max_text]
paragraph.gsub!(/\[\d+\]/mi, "")
text << paragraph
cnt += 1
@@ -34,10 +35,10 @@
result = {
link: link,
title: raw.css("html body h1").inner_text,
description: text
}
- img = raw.css(".infobox .image img")
+ img = raw.css(".image img")
if img && img.first
result[:image] = img.first["src"]
end
result