Module: Onebox

Defined in:
lib/onebox.rb,
lib/onebox/web.rb,
lib/onebox/view.rb,
lib/onebox/engine.rb,
lib/onebox/layout.rb,
lib/onebox/helpers.rb,
lib/onebox/matcher.rb,
lib/onebox/preview.rb,
lib/onebox/version.rb,
lib/onebox/engine/html.rb,
lib/onebox/engine/json.rb,
lib/onebox/web_helpers.rb,
lib/onebox/status_check.rb,
lib/onebox/layout_support.rb,
lib/onebox/file_type_finder.rb,
lib/onebox/template_support.rb,
lib/onebox/engine/pdf_onebox.rb,
lib/onebox/engine/coub_onebox.rb,
lib/onebox/engine/xkcd_onebox.rb,
lib/onebox/engine/audio_onebox.rb,
lib/onebox/engine/giphy_onebox.rb,
lib/onebox/engine/image_onebox.rb,
lib/onebox/engine/imgur_onebox.rb,
lib/onebox/engine/video_onebox.rb,
lib/onebox/engine/vimeo_onebox.rb,
lib/onebox/engine/youku_onebox.rb,
lib/onebox/engine/amazon_onebox.rb,
lib/onebox/engine/douban_onebox.rb,
lib/onebox/engine/flickr_onebox.rb,
lib/onebox/engine/gfycat_onebox.rb,
lib/onebox/engine/pubmed_onebox.rb,
lib/onebox/engine/replit_onebox.rb,
lib/onebox/engine/slides_onebox.rb,
lib/onebox/mixins/twitch_onebox.rb,
lib/onebox/engine/standard_embed.rb,
lib/onebox/engine/youtube_onebox.rb,
lib/onebox/engine/bandcamp_onebox.rb,
lib/onebox/engine/mixcloud_onebox.rb,
lib/onebox/engine/opengraph_image.rb,
lib/onebox/engine/pastebin_onebox.rb,
lib/onebox/engine/typeform_onebox.rb,
lib/onebox/engine/asciinema_onebox.rb,
lib/onebox/engine/audioboom_onebox.rb,
lib/onebox/engine/sketchfab_onebox.rb,
lib/onebox/engine/wikimedia_onebox.rb,
lib/onebox/engine/wikipedia_onebox.rb,
lib/onebox/engine/soundcloud_onebox.rb,
lib/onebox/engine/github_blob_onebox.rb,
lib/onebox/engine/github_gist_onebox.rb,
lib/onebox/engine/google_docs_onebox.rb,
lib/onebox/engine/google_maps_onebox.rb,
lib/onebox/engine/steam_store_onebox.rb,
lib/onebox/engine/github_issue_onebox.rb,
lib/onebox/engine/github_commit_onebox.rb,
lib/onebox/engine/stack_exchange_onebox.rb,
lib/onebox/engine/twitter_status_onebox.rb,
lib/onebox/engine/five_hundred_px_onebox.rb,
lib/onebox/engine/google_calendar_onebox.rb,
lib/onebox/engine/google_play_app_onebox.rb,
lib/onebox/engine/flickr_shortened_onebox.rb,
lib/onebox/engine/github_pullrequest_onebox.rb,
lib/onebox/engine/whitelisted_generic_onebox.rb

Defined Under Namespace

Modules: Engine, FileTypeFinder, Helpers, LayoutSupport, Mixins, TemplateSupport, WebHelpers Classes: Layout, Matcher, Preview, StatusCheck, View, Web

Constant Summary collapse

DEFAULTS =
{
  cache: Moneta.new(:Memory, expires: true, serializer: :json),
  connect_timeout: 5,
  timeout: 10,
  max_download_kb: (10 * 1024), # 10MB
  load_paths: [File.join(Gem::Specification.find_by_name("onebox").gem_dir, "templates")],
  allowed_ports: [80, 443],
  allowed_schemes: ["http", "https"],
  sanitize_config: Sanitize::Config::ONEBOX,
  redirect_limit: 5
}
VERSION =
"1.8.13"
@@options =
DEFAULTS

Class Method Summary collapse

Class Method Details

.check(url, options = Onebox.options) ⇒ Object


34
35
36
# File 'lib/onebox.rb', line 34

def self.check(url, options = Onebox.options)
  StatusCheck.new(url, options)
end

.has_matcher?(url) ⇒ Boolean


42
43
44
# File 'lib/onebox.rb', line 42

def self.has_matcher?(url)
  !!Matcher.new(url).oneboxed
end

.optionsObject


38
39
40
# File 'lib/onebox.rb', line 38

def self.options
  OpenStruct.new(@@options)
end

.options=(options) ⇒ Object


46
47
48
# File 'lib/onebox.rb', line 46

def self.options=(options)
  @@options = DEFAULTS.merge(options)
end

.preview(url, options = Onebox.options) ⇒ Object


30
31
32
# File 'lib/onebox.rb', line 30

def self.preview(url, options = Onebox.options)
  Preview.new(url, options)
end