lib/onebox/engine/wikipedia_onebox.rb in onebox-1.2.9 vs lib/onebox/engine/wikipedia_onebox.rb in onebox-1.3.0
- old
+ new
@@ -3,16 +3,11 @@
class WikipediaOnebox
include Engine
include LayoutSupport
include HTML
- matches do
- http
- anything
- domain("wikipedia")
- either(".com", ".org")
- end
+ matches_regexp(/^https?:\/\/.*wikipedia\.(com|org)/)
private
def data
# get all the paras
@@ -36,11 +31,17 @@
link: link,
title: raw.css("html body h1").inner_text,
description: text
}
img = raw.css(".image img")
- if img && img.first
- result[:image] = img.first["src"]
+ if img && img.size > 0
+ img.each do |i|
+ src = i["src"]
+ if src !~ /Question_book/
+ result[:image] = src
+ break
+ end
+ end
end
result
end
end