Sha256: adfc55b5cc5e9f33cc1cad14740ab86d0da8465143bbf020ece6af2945198349
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
Contents
module Onebox module Engine class PastebinOnebox include Engine include StandardEmbed matches_regexp(/^http?:\/\/pastebin\.com/) def paste_key if uri.path =~ /\/raw\// match = uri.path.match(/\/raw\/([^\/]+)/) return match[1] if match && match[1] elsif uri.path =~ /\/download\// match = uri.path.match(/\/download\/([^\/]+)/) return match[1] if match && match[1] elsif uri.path =~ /\/embed\// match = uri.path.match(/\/embed\/([^\/]+)/) return match[1] if match && match[1] else match = uri.path.match(/\/([^\/]+)/) return match[1] if match && match[1] end nil rescue return nil end def to_html return nil unless paste_key response = Onebox::Helpers.fetch_response("http://pastebin.com/raw/#{paste_key}", 1) return nil unless response && response.code.to_i == 200 return "<iframe src='//pastebin.com/embed_iframe/#{paste_key}' style='border:none;width:100%;max-height:100px;'></iframe>" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
onebox-1.5.34 | lib/onebox/engine/pastebin_onebox.rb |
onebox-1.5.33 | lib/onebox/engine/pastebin_onebox.rb |