onebox 1.8.80 → 1.8.81
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -0
- data/.rspec +0 -0
- data/.rubocop.yml +0 -0
- data/.ruby-gemset +0 -0
- data/.travis.yml +0 -0
- data/CHANGELOG.md +26 -26
- data/Gemfile +0 -0
- data/Gemfile.lock +154 -152
- data/Guardfile +0 -0
- data/LICENSE.txt +0 -0
- data/README.md +223 -223
- data/Rakefile +0 -0
- data/lib/onebox.rb +0 -0
- data/lib/onebox/engine.rb +188 -188
- data/lib/onebox/engine/amazon_onebox.rb +167 -167
- data/lib/onebox/engine/asciinema_onebox.rb +0 -0
- data/lib/onebox/engine/audio_onebox.rb +0 -0
- data/lib/onebox/engine/audioboom_onebox.rb +24 -24
- data/lib/onebox/engine/bandcamp_onebox.rb +32 -32
- data/lib/onebox/engine/cloudapp_onebox.rb +51 -51
- data/lib/onebox/engine/coub_onebox.rb +21 -21
- data/lib/onebox/engine/douban_onebox.rb +0 -0
- data/lib/onebox/engine/five_hundred_px_onebox.rb +17 -17
- data/lib/onebox/engine/flickr_onebox.rb +0 -0
- data/lib/onebox/engine/flickr_shortened_onebox.rb +0 -0
- data/lib/onebox/engine/gfycat_onebox.rb +0 -0
- data/lib/onebox/engine/giphy_onebox.rb +22 -22
- data/lib/onebox/engine/github_blob_onebox.rb +0 -0
- data/lib/onebox/engine/github_commit_onebox.rb +0 -0
- data/lib/onebox/engine/github_gist_onebox.rb +0 -0
- data/lib/onebox/engine/github_issue_onebox.rb +0 -0
- data/lib/onebox/engine/github_pullrequest_onebox.rb +0 -0
- data/lib/onebox/engine/gitlab_blob_onebox.rb +0 -0
- data/lib/onebox/engine/google_calendar_onebox.rb +0 -0
- data/lib/onebox/engine/google_docs_onebox.rb +0 -0
- data/lib/onebox/engine/google_maps_onebox.rb +0 -0
- data/lib/onebox/engine/google_photos_onebox.rb +57 -57
- data/lib/onebox/engine/google_play_app_onebox.rb +0 -0
- data/lib/onebox/engine/html.rb +0 -0
- data/lib/onebox/engine/image_onebox.rb +0 -0
- data/lib/onebox/engine/imgur_onebox.rb +65 -65
- data/lib/onebox/engine/instagram_onebox.rb +32 -32
- data/lib/onebox/engine/json.rb +0 -0
- data/lib/onebox/engine/kaltura_onebox.rb +31 -31
- data/lib/onebox/engine/mixcloud_onebox.rb +20 -20
- data/lib/onebox/engine/opengraph_image.rb +12 -12
- data/lib/onebox/engine/pastebin_onebox.rb +0 -0
- data/lib/onebox/engine/pdf_onebox.rb +0 -0
- data/lib/onebox/engine/pubmed_onebox.rb +0 -0
- data/lib/onebox/engine/replit_onebox.rb +24 -24
- data/lib/onebox/engine/sketchfab_onebox.rb +31 -31
- data/lib/onebox/engine/slides_onebox.rb +0 -0
- data/lib/onebox/engine/soundcloud_onebox.rb +31 -31
- data/lib/onebox/engine/stack_exchange_onebox.rb +0 -0
- data/lib/onebox/engine/standard_embed.rb +145 -145
- data/lib/onebox/engine/steam_store_onebox.rb +37 -37
- data/lib/onebox/engine/trello_onebox.rb +0 -0
- data/lib/onebox/engine/twitch_clips_onebox.rb +0 -0
- data/lib/onebox/engine/twitch_stream_onebox.rb +0 -0
- data/lib/onebox/engine/twitch_video_onebox.rb +0 -0
- data/lib/onebox/engine/twitter_status_onebox.rb +0 -0
- data/lib/onebox/engine/typeform_onebox.rb +41 -41
- data/lib/onebox/engine/video_onebox.rb +0 -0
- data/lib/onebox/engine/vimeo_onebox.rb +20 -20
- data/lib/onebox/engine/wechat_mp_onebox.rb +0 -0
- data/lib/onebox/engine/whitelisted_generic_onebox.rb +366 -366
- data/lib/onebox/engine/wikimedia_onebox.rb +0 -0
- data/lib/onebox/engine/wikipedia_onebox.rb +0 -0
- data/lib/onebox/engine/wistia_onebox.rb +27 -27
- data/lib/onebox/engine/xkcd_onebox.rb +0 -0
- data/lib/onebox/engine/youku_onebox.rb +0 -0
- data/lib/onebox/engine/youtube_onebox.rb +163 -163
- data/lib/onebox/file_type_finder.rb +0 -0
- data/lib/onebox/helpers.rb +188 -188
- data/lib/onebox/layout.rb +0 -0
- data/lib/onebox/layout_support.rb +0 -0
- data/lib/onebox/matcher.rb +0 -0
- data/lib/onebox/mixins/git_blob_onebox.rb +0 -0
- data/lib/onebox/mixins/twitch_onebox.rb +0 -0
- data/lib/onebox/oembed.rb +15 -12
- data/lib/onebox/open_graph.rb +90 -88
- data/lib/onebox/preview.rb +0 -0
- data/lib/onebox/sanitize_config.rb +0 -0
- data/lib/onebox/status_check.rb +0 -0
- data/lib/onebox/template_support.rb +0 -0
- data/lib/onebox/version.rb +5 -5
- data/lib/onebox/view.rb +0 -0
- data/lib/onebox/web.rb +0 -0
- data/lib/onebox/web_helpers.rb +0 -0
- data/onebox.gemspec +0 -0
- data/templates/_layout.mustache +0 -0
- data/templates/amazon.mustache +0 -0
- data/templates/douban.mustache +0 -0
- data/templates/githubblob.mustache +0 -0
- data/templates/githubcommit.mustache +0 -0
- data/templates/githubgist.mustache +0 -0
- data/templates/githubissue.mustache +0 -0
- data/templates/githubpullrequest.mustache +0 -0
- data/templates/gitlabblob.mustache +0 -0
- data/templates/googledocs.mustache +0 -0
- data/templates/googleplayapp.mustache +0 -0
- data/templates/instagram.mustache +0 -0
- data/templates/pastebin.mustache +0 -0
- data/templates/pdf.mustache +0 -0
- data/templates/pubmed.mustache +0 -0
- data/templates/stackexchange.mustache +0 -0
- data/templates/twitterstatus.mustache +0 -0
- data/templates/wechatmp.mustache +0 -0
- data/templates/whitelistedgeneric.mustache +0 -0
- data/templates/wikimedia.mustache +0 -0
- data/templates/wikipedia.mustache +0 -0
- data/templates/xkcd.mustache +0 -0
- metadata +4 -3
File without changes
|
@@ -1,31 +1,31 @@
|
|
1
|
-
module Onebox
|
2
|
-
module Engine
|
3
|
-
class SoundCloudOnebox
|
4
|
-
include Engine
|
5
|
-
include StandardEmbed
|
6
|
-
|
7
|
-
matches_regexp(/^https?:\/\/soundcloud\.com/)
|
8
|
-
always_https
|
9
|
-
|
10
|
-
def to_html
|
11
|
-
oembed = get_oembed
|
12
|
-
oembed.html.gsub('visual=true', 'visual=false')
|
13
|
-
end
|
14
|
-
|
15
|
-
def placeholder_html
|
16
|
-
oembed = get_oembed
|
17
|
-
return if Onebox::Helpers.blank?(oembed.thumbnail_url)
|
18
|
-
"<img src='#{oembed.thumbnail_url}' #{oembed.title_attr}>"
|
19
|
-
end
|
20
|
-
|
21
|
-
protected
|
22
|
-
|
23
|
-
def get_oembed_url
|
24
|
-
oembed_url = "https://soundcloud.com/oembed.json?url=#{url}"
|
25
|
-
oembed_url << "&maxheight=166" unless url["/sets/"]
|
26
|
-
oembed_url
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
1
|
+
module Onebox
|
2
|
+
module Engine
|
3
|
+
class SoundCloudOnebox
|
4
|
+
include Engine
|
5
|
+
include StandardEmbed
|
6
|
+
|
7
|
+
matches_regexp(/^https?:\/\/soundcloud\.com/)
|
8
|
+
always_https
|
9
|
+
|
10
|
+
def to_html
|
11
|
+
oembed = get_oembed
|
12
|
+
oembed.html.gsub('visual=true', 'visual=false')
|
13
|
+
end
|
14
|
+
|
15
|
+
def placeholder_html
|
16
|
+
oembed = get_oembed
|
17
|
+
return if Onebox::Helpers.blank?(oembed.thumbnail_url)
|
18
|
+
"<img src='#{oembed.thumbnail_url}' #{oembed.title_attr}>"
|
19
|
+
end
|
20
|
+
|
21
|
+
protected
|
22
|
+
|
23
|
+
def get_oembed_url
|
24
|
+
oembed_url = "https://soundcloud.com/oembed.json?url=#{url}"
|
25
|
+
oembed_url << "&maxheight=166" unless url["/sets/"]
|
26
|
+
oembed_url
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
File without changes
|
@@ -1,145 +1,145 @@
|
|
1
|
-
require "cgi"
|
2
|
-
require "onebox/open_graph"
|
3
|
-
|
4
|
-
module Onebox
|
5
|
-
module Engine
|
6
|
-
module StandardEmbed
|
7
|
-
|
8
|
-
def self.oembed_providers
|
9
|
-
@@oembed_providers ||= {}
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.add_oembed_provider(regexp, endpoint)
|
13
|
-
oembed_providers[regexp] = endpoint
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.opengraph_providers
|
17
|
-
@@opengraph_providers ||= []
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.add_opengraph_provider(regexp)
|
21
|
-
opengraph_providers << regexp
|
22
|
-
end
|
23
|
-
|
24
|
-
# Some oembed providers (like meetup.com) don't provide links to themselves
|
25
|
-
add_oembed_provider(/www\.meetup\.com\//, 'http://api.meetup.com/oembed')
|
26
|
-
add_oembed_provider(/www\.mixcloud\.com\//, 'https://www.mixcloud.com/oembed/')
|
27
|
-
# In order to support Private Videos
|
28
|
-
add_oembed_provider(/vimeo\.com\//, 'https://vimeo.com/api/oembed.json')
|
29
|
-
# NYT requires login so use oembed only
|
30
|
-
add_oembed_provider(/nytimes\.com\//, 'https://www.nytimes.com/svc/oembed/json/')
|
31
|
-
|
32
|
-
def always_https?
|
33
|
-
WhitelistedGenericOnebox.host_matches(uri, WhitelistedGenericOnebox.https_hosts) || super
|
34
|
-
end
|
35
|
-
|
36
|
-
def raw
|
37
|
-
return @raw if @raw
|
38
|
-
|
39
|
-
og = get_opengraph
|
40
|
-
twitter = get_twitter
|
41
|
-
oembed = get_oembed
|
42
|
-
|
43
|
-
@raw = {}
|
44
|
-
|
45
|
-
og.data.each do |k, v|
|
46
|
-
next if k == "title_attr"
|
47
|
-
v = og.send(k)
|
48
|
-
@raw[k] ||= v unless v.nil?
|
49
|
-
end
|
50
|
-
|
51
|
-
twitter.each { |k, v| @raw[k] ||= v unless Onebox::Helpers::blank?(v) }
|
52
|
-
|
53
|
-
oembed.data.each do |k, v|
|
54
|
-
v = oembed.send(k)
|
55
|
-
@raw[k] ||= v unless v.nil?
|
56
|
-
end
|
57
|
-
|
58
|
-
favicon = get_favicon
|
59
|
-
@raw["favicon".to_sym] = favicon unless Onebox::Helpers::blank?(favicon)
|
60
|
-
|
61
|
-
@raw
|
62
|
-
end
|
63
|
-
|
64
|
-
protected
|
65
|
-
|
66
|
-
def html_doc
|
67
|
-
return @html_doc if @html_doc
|
68
|
-
|
69
|
-
headers = nil
|
70
|
-
headers = { 'Cookie' => options[:cookie] } if options[:cookie]
|
71
|
-
|
72
|
-
@html_doc = Onebox::Helpers.fetch_html_doc(url, headers)
|
73
|
-
end
|
74
|
-
|
75
|
-
def get_oembed
|
76
|
-
@oembed ||= Onebox::Oembed.new(get_json_response)
|
77
|
-
end
|
78
|
-
|
79
|
-
def get_opengraph
|
80
|
-
@opengraph ||= ::Onebox::OpenGraph.new(html_doc)
|
81
|
-
end
|
82
|
-
|
83
|
-
def get_twitter
|
84
|
-
return {} unless html_doc
|
85
|
-
|
86
|
-
twitter = {}
|
87
|
-
|
88
|
-
html_doc.css('meta').each do |m|
|
89
|
-
if (m["property"] && m["property"][/^twitter:(.+)$/i]) || (m["name"] && m["name"][/^twitter:(.+)$/i])
|
90
|
-
value = (m["content"] || m["value"]).to_s
|
91
|
-
twitter[$1.tr('-:' , '_').to_sym] ||= value unless Onebox::Helpers::blank?(value)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
twitter
|
96
|
-
end
|
97
|
-
|
98
|
-
def get_favicon
|
99
|
-
return nil unless html_doc
|
100
|
-
|
101
|
-
favicon = html_doc.css('link[rel="shortcut icon"], link[rel="icon shortcut"], link[rel="shortcut"], link[rel="icon"]').first
|
102
|
-
favicon = favicon.nil? ? nil : (favicon['href'].nil? ? nil : favicon['href'].strip)
|
103
|
-
|
104
|
-
Onebox::Helpers::get_absolute_image_url(favicon, url)
|
105
|
-
end
|
106
|
-
|
107
|
-
def get_json_response
|
108
|
-
oembed_url = get_oembed_url
|
109
|
-
|
110
|
-
return "{}" if Onebox::Helpers.blank?(oembed_url)
|
111
|
-
|
112
|
-
Onebox::Helpers.fetch_response(oembed_url) rescue "{}"
|
113
|
-
rescue Errno::ECONNREFUSED, Net::HTTPError, Net::HTTPFatalError, MultiJson::LoadError
|
114
|
-
"{}"
|
115
|
-
end
|
116
|
-
|
117
|
-
protected
|
118
|
-
|
119
|
-
def get_oembed_url
|
120
|
-
oembed_url = nil
|
121
|
-
|
122
|
-
StandardEmbed.oembed_providers.each do |regexp, endpoint|
|
123
|
-
if url =~ regexp
|
124
|
-
oembed_url = "#{endpoint}?url=#{url}"
|
125
|
-
break
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
if html_doc
|
130
|
-
if Onebox::Helpers.blank?(oembed_url)
|
131
|
-
application_json = html_doc.at("//link[@type='application/json+oembed']/@href")
|
132
|
-
oembed_url = application_json.value if application_json
|
133
|
-
end
|
134
|
-
|
135
|
-
if Onebox::Helpers.blank?(oembed_url)
|
136
|
-
text_json = html_doc.at("//link[@type='text/json+oembed']/@href")
|
137
|
-
oembed_url ||= text_json.value if text_json
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
oembed_url
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
1
|
+
require "cgi"
|
2
|
+
require "onebox/open_graph"
|
3
|
+
|
4
|
+
module Onebox
|
5
|
+
module Engine
|
6
|
+
module StandardEmbed
|
7
|
+
|
8
|
+
def self.oembed_providers
|
9
|
+
@@oembed_providers ||= {}
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.add_oembed_provider(regexp, endpoint)
|
13
|
+
oembed_providers[regexp] = endpoint
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.opengraph_providers
|
17
|
+
@@opengraph_providers ||= []
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.add_opengraph_provider(regexp)
|
21
|
+
opengraph_providers << regexp
|
22
|
+
end
|
23
|
+
|
24
|
+
# Some oembed providers (like meetup.com) don't provide links to themselves
|
25
|
+
add_oembed_provider(/www\.meetup\.com\//, 'http://api.meetup.com/oembed')
|
26
|
+
add_oembed_provider(/www\.mixcloud\.com\//, 'https://www.mixcloud.com/oembed/')
|
27
|
+
# In order to support Private Videos
|
28
|
+
add_oembed_provider(/vimeo\.com\//, 'https://vimeo.com/api/oembed.json')
|
29
|
+
# NYT requires login so use oembed only
|
30
|
+
add_oembed_provider(/nytimes\.com\//, 'https://www.nytimes.com/svc/oembed/json/')
|
31
|
+
|
32
|
+
def always_https?
|
33
|
+
WhitelistedGenericOnebox.host_matches(uri, WhitelistedGenericOnebox.https_hosts) || super
|
34
|
+
end
|
35
|
+
|
36
|
+
def raw
|
37
|
+
return @raw if @raw
|
38
|
+
|
39
|
+
og = get_opengraph
|
40
|
+
twitter = get_twitter
|
41
|
+
oembed = get_oembed
|
42
|
+
|
43
|
+
@raw = {}
|
44
|
+
|
45
|
+
og.data.each do |k, v|
|
46
|
+
next if k == "title_attr"
|
47
|
+
v = og.send(k)
|
48
|
+
@raw[k] ||= v unless v.nil?
|
49
|
+
end
|
50
|
+
|
51
|
+
twitter.each { |k, v| @raw[k] ||= v unless Onebox::Helpers::blank?(v) }
|
52
|
+
|
53
|
+
oembed.data.each do |k, v|
|
54
|
+
v = oembed.send(k)
|
55
|
+
@raw[k] ||= v unless v.nil?
|
56
|
+
end
|
57
|
+
|
58
|
+
favicon = get_favicon
|
59
|
+
@raw["favicon".to_sym] = favicon unless Onebox::Helpers::blank?(favicon)
|
60
|
+
|
61
|
+
@raw
|
62
|
+
end
|
63
|
+
|
64
|
+
protected
|
65
|
+
|
66
|
+
def html_doc
|
67
|
+
return @html_doc if @html_doc
|
68
|
+
|
69
|
+
headers = nil
|
70
|
+
headers = { 'Cookie' => options[:cookie] } if options[:cookie]
|
71
|
+
|
72
|
+
@html_doc = Onebox::Helpers.fetch_html_doc(url, headers)
|
73
|
+
end
|
74
|
+
|
75
|
+
def get_oembed
|
76
|
+
@oembed ||= Onebox::Oembed.new(get_json_response)
|
77
|
+
end
|
78
|
+
|
79
|
+
def get_opengraph
|
80
|
+
@opengraph ||= ::Onebox::OpenGraph.new(html_doc)
|
81
|
+
end
|
82
|
+
|
83
|
+
def get_twitter
|
84
|
+
return {} unless html_doc
|
85
|
+
|
86
|
+
twitter = {}
|
87
|
+
|
88
|
+
html_doc.css('meta').each do |m|
|
89
|
+
if (m["property"] && m["property"][/^twitter:(.+)$/i]) || (m["name"] && m["name"][/^twitter:(.+)$/i])
|
90
|
+
value = (m["content"] || m["value"]).to_s
|
91
|
+
twitter[$1.tr('-:' , '_').to_sym] ||= value unless Onebox::Helpers::blank?(value)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
twitter
|
96
|
+
end
|
97
|
+
|
98
|
+
def get_favicon
|
99
|
+
return nil unless html_doc
|
100
|
+
|
101
|
+
favicon = html_doc.css('link[rel="shortcut icon"], link[rel="icon shortcut"], link[rel="shortcut"], link[rel="icon"]').first
|
102
|
+
favicon = favicon.nil? ? nil : (favicon['href'].nil? ? nil : favicon['href'].strip)
|
103
|
+
|
104
|
+
Onebox::Helpers::get_absolute_image_url(favicon, url)
|
105
|
+
end
|
106
|
+
|
107
|
+
def get_json_response
|
108
|
+
oembed_url = get_oembed_url
|
109
|
+
|
110
|
+
return "{}" if Onebox::Helpers.blank?(oembed_url)
|
111
|
+
|
112
|
+
Onebox::Helpers.fetch_response(oembed_url) rescue "{}"
|
113
|
+
rescue Errno::ECONNREFUSED, Net::HTTPError, Net::HTTPFatalError, MultiJson::LoadError
|
114
|
+
"{}"
|
115
|
+
end
|
116
|
+
|
117
|
+
protected
|
118
|
+
|
119
|
+
def get_oembed_url
|
120
|
+
oembed_url = nil
|
121
|
+
|
122
|
+
StandardEmbed.oembed_providers.each do |regexp, endpoint|
|
123
|
+
if url =~ regexp
|
124
|
+
oembed_url = "#{endpoint}?url=#{url}"
|
125
|
+
break
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
if html_doc
|
130
|
+
if Onebox::Helpers.blank?(oembed_url)
|
131
|
+
application_json = html_doc.at("//link[@type='application/json+oembed']/@href")
|
132
|
+
oembed_url = application_json.value if application_json
|
133
|
+
end
|
134
|
+
|
135
|
+
if Onebox::Helpers.blank?(oembed_url)
|
136
|
+
text_json = html_doc.at("//link[@type='text/json+oembed']/@href")
|
137
|
+
oembed_url ||= text_json.value if text_json
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
oembed_url
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
@@ -1,37 +1,37 @@
|
|
1
|
-
module Onebox
|
2
|
-
module Engine
|
3
|
-
class SteamStoreOnebox
|
4
|
-
include Engine
|
5
|
-
include StandardEmbed
|
6
|
-
|
7
|
-
always_https
|
8
|
-
matches_regexp(/^https?:\/\/store\.steampowered\.com\/app\/\d+/)
|
9
|
-
|
10
|
-
def placeholder_html
|
11
|
-
og = get_opengraph
|
12
|
-
<<-HTML
|
13
|
-
<div style='width:100%; height:190px; background-color:#262626; color:#9e9e9e; margin:15px 0;'>
|
14
|
-
<div style='padding:10px'>
|
15
|
-
<h3 style='color:#fff; margin:10px 0 10px 5px;'>#{og.title}</h3>
|
16
|
-
<img src='#{og.image}' style='float:left; max-width:184px; margin:5px 15px 0 5px'/>
|
17
|
-
<p>#{og.description}</p>
|
18
|
-
</div>
|
19
|
-
</div>
|
20
|
-
HTML
|
21
|
-
end
|
22
|
-
|
23
|
-
def to_html
|
24
|
-
iframe_url = @url[/https?:\/\/store\.steampowered\.com\/app\/\d+/].gsub("/app/", "/widget/")
|
25
|
-
escaped_src = ::Onebox::Helpers.normalize_url_for_output(iframe_url)
|
26
|
-
|
27
|
-
<<-HTML
|
28
|
-
<iframe src='#{escaped_src}'
|
29
|
-
frameborder='0'
|
30
|
-
width='100%'
|
31
|
-
height='190'>
|
32
|
-
</iframe>
|
33
|
-
HTML
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
1
|
+
module Onebox
|
2
|
+
module Engine
|
3
|
+
class SteamStoreOnebox
|
4
|
+
include Engine
|
5
|
+
include StandardEmbed
|
6
|
+
|
7
|
+
always_https
|
8
|
+
matches_regexp(/^https?:\/\/store\.steampowered\.com\/app\/\d+/)
|
9
|
+
|
10
|
+
def placeholder_html
|
11
|
+
og = get_opengraph
|
12
|
+
<<-HTML
|
13
|
+
<div style='width:100%; height:190px; background-color:#262626; color:#9e9e9e; margin:15px 0;'>
|
14
|
+
<div style='padding:10px'>
|
15
|
+
<h3 style='color:#fff; margin:10px 0 10px 5px;'>#{og.title}</h3>
|
16
|
+
<img src='#{og.image}' style='float:left; max-width:184px; margin:5px 15px 0 5px'/>
|
17
|
+
<p>#{og.description}</p>
|
18
|
+
</div>
|
19
|
+
</div>
|
20
|
+
HTML
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_html
|
24
|
+
iframe_url = @url[/https?:\/\/store\.steampowered\.com\/app\/\d+/].gsub("/app/", "/widget/")
|
25
|
+
escaped_src = ::Onebox::Helpers.normalize_url_for_output(iframe_url)
|
26
|
+
|
27
|
+
<<-HTML
|
28
|
+
<iframe src='#{escaped_src}'
|
29
|
+
frameborder='0'
|
30
|
+
width='100%'
|
31
|
+
height='190'>
|
32
|
+
</iframe>
|
33
|
+
HTML
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,41 +1,41 @@
|
|
1
|
-
module Onebox
|
2
|
-
module Engine
|
3
|
-
class TypeformOnebox
|
4
|
-
include Engine
|
5
|
-
|
6
|
-
matches_regexp(/^https?:\/\/[a-z0-9]+\.typeform\.com\/to\/[a-zA-Z0-9]+/)
|
7
|
-
always_https
|
8
|
-
|
9
|
-
def to_html
|
10
|
-
typeform_src = build_typeform_src
|
11
|
-
|
12
|
-
<<~HTML
|
13
|
-
<iframe src="#{typeform_src}"
|
14
|
-
width="100%"
|
15
|
-
height="600px"
|
16
|
-
scrolling="no"
|
17
|
-
frameborder="0">
|
18
|
-
</iframe>
|
19
|
-
HTML
|
20
|
-
end
|
21
|
-
alias placeholder_html to_html
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def build_typeform_src
|
26
|
-
escaped_src = ::Onebox::Helpers.normalize_url_for_output(@url)
|
27
|
-
query_params = CGI::parse(URI::parse(escaped_src).query || '')
|
28
|
-
|
29
|
-
return escaped_src if query_params.has_key?('typeform-embed')
|
30
|
-
|
31
|
-
if query_params.empty?
|
32
|
-
escaped_src << '?' unless escaped_src.end_with?('?')
|
33
|
-
else
|
34
|
-
escaped_src << '&'
|
35
|
-
end
|
36
|
-
|
37
|
-
escaped_src << 'typeform-embed=embed-widget'
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
1
|
+
module Onebox
|
2
|
+
module Engine
|
3
|
+
class TypeformOnebox
|
4
|
+
include Engine
|
5
|
+
|
6
|
+
matches_regexp(/^https?:\/\/[a-z0-9]+\.typeform\.com\/to\/[a-zA-Z0-9]+/)
|
7
|
+
always_https
|
8
|
+
|
9
|
+
def to_html
|
10
|
+
typeform_src = build_typeform_src
|
11
|
+
|
12
|
+
<<~HTML
|
13
|
+
<iframe src="#{typeform_src}"
|
14
|
+
width="100%"
|
15
|
+
height="600px"
|
16
|
+
scrolling="no"
|
17
|
+
frameborder="0">
|
18
|
+
</iframe>
|
19
|
+
HTML
|
20
|
+
end
|
21
|
+
alias placeholder_html to_html
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def build_typeform_src
|
26
|
+
escaped_src = ::Onebox::Helpers.normalize_url_for_output(@url)
|
27
|
+
query_params = CGI::parse(URI::parse(escaped_src).query || '')
|
28
|
+
|
29
|
+
return escaped_src if query_params.has_key?('typeform-embed')
|
30
|
+
|
31
|
+
if query_params.empty?
|
32
|
+
escaped_src << '?' unless escaped_src.end_with?('?')
|
33
|
+
else
|
34
|
+
escaped_src << '&'
|
35
|
+
end
|
36
|
+
|
37
|
+
escaped_src << 'typeform-embed=embed-widget'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|