Class: Onebox::Engine::WikimediaOnebox

Inherits:
Object
  • Object
show all
Includes:
Onebox::Engine, JSON, LayoutSupport
Defined in:
lib/onebox/engine/wikimedia_onebox.rb

Constant Summary

Constants included from Onebox::Engine

DEFAULT

Instance Attribute Summary

Attributes included from Onebox::Engine

#cache, #timeout, #uri

Class Method Summary collapse

Instance Method Summary collapse

Methods included from LayoutSupport

#layout, max_text, #to_html

Methods included from Onebox::Engine

engines, included, #initialize, #options, #options=, #placeholder_html, #to_html

Class Method Details

.priorityObject


11
12
13
14
15
16
17
# File 'lib/onebox/engine/wikimedia_onebox.rb', line 11

def self.priority
  # Wikimedia links end in an image extension.
  # E.g. https://commons.wikimedia.org/wiki/File:Stones_members_montage2.jpg
  # This engine should have priority over the generic ImageOnebox.

  1
end

Instance Method Details

#urlObject


19
20
21
# File 'lib/onebox/engine/wikimedia_onebox.rb', line 19

def url
  "https://en.wikipedia.org/w/api.php?action=query&titles=#{match[:name]}&prop=imageinfo&iilimit=50&iiprop=timestamp|user|url&iiurlwidth=500&format=json"
end