Class: Onebox::Engine::AllowlistedGenericOnebox
Constant Summary
DEFAULT
Instance Attribute Summary
#errors, #options, #timeout, #uri, #url
Class Method Summary
collapse
Instance Method Summary
collapse
#layout, max_text
add_oembed_provider, add_opengraph_provider, #always_https?, oembed_providers, opengraph_providers, #raw
all_iframe_origins, engines, included, #initialize, origins_to_regexes
Class Method Details
.===(other) ⇒ Object
179
180
181
182
183
|
# File 'lib/onebox/engine/allowlisted_generic_onebox.rb', line 179
def self.===(other)
other.kind_of?(URI) ?
host_matches(other, allowed_domains) || probable_wordpress(other) || probable_discourse(other) :
super
end
|
.allowed_domains ⇒ Object
20
21
22
|
# File 'lib/onebox/engine/allowlisted_generic_onebox.rb', line 20
def self.allowed_domains
@allowed_domains ||= default_allowed_domains.dup
end
|
.allowed_domains=(list) ⇒ Object
16
17
18
|
# File 'lib/onebox/engine/allowlisted_generic_onebox.rb', line 16
def self.allowed_domains=(list)
@allowed_domains = list
end
|
175
176
177
|
# File 'lib/onebox/engine/allowlisted_generic_onebox.rb', line 175
def self.
['brand', 'price', 'usd', 'cad', 'reading time', 'likes']
end
|
.default_allowed_domains ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
# File 'lib/onebox/engine/allowlisted_generic_onebox.rb', line 24
def self.default_allowed_domains
%w(
23hq.com
500px.com
8tracks.com
abc.net.au
answers.com
arstechnica.com
ask.com
battle.net
bbc.co.uk
bbs.boingboing.net
bestbuy.ca
bestbuy.com
bloomberg.com
businessinsider.com
change.org
cnet.com
cnn.com
codepen.io
collegehumor.com
consider.it
coursera.org
cracked.com
dailymail.co.uk
dailymotion.com
deadline.com
dell.com
deviantart.com
digg.com
dotsub.com
ebay.ca
ebay.co.uk
ebay.com
ehow.com
espn.go.com
etsy.com
facebook.com
findery.com
folksy.com
forbes.com
foxnews.com
funnyordie.com
gifs.com
groupon.com
howtogeek.com
huffingtonpost.ca
huffingtonpost.com
hulu.com
ign.com
ikea.com
imdb.com
indiatimes.com
itunes.apple.com
khanacademy.org
kickstarter.com
kinomap.com
lessonplanet.com
linkedin.com
liveleak.com
livestream.com
mashable.com
medium.com
meetup.com
mixcloud.com
mlb.com
myspace.com
nba.com
npr.org
nytimes.com
photobucket.com
pinterest.com
reference.com
rottentomatoes.com
samsung.com
scribd.com
slideshare.net
sourceforge.net
speakerdeck.com
spotify.com
streamable.com
techcrunch.com
ted.com
thefreedictionary.com
theglobeandmail.com
thenextweb.com
theonion.com
thestar.com
thesun.co.uk
thinkgeek.com
tmz.com
torontosun.com
tumblr.com
twitpic.com
usatoday.com
viddler.com
vine.co
walmart.com
washingtonpost.com
wi.st
wikia.com
wikihow.com
wired.com
wistia.com
wonderhowto.com
wsj.com
zappos.com
zillow.com
)
end
|
.default_html_providers ⇒ Object
Often using the ‘html` attribute is not what we want, like for some blogs that include the entire page HTML. However for some providers like Flickr it allows us to return gifv and galleries.
138
139
140
|
# File 'lib/onebox/engine/allowlisted_generic_onebox.rb', line 138
def self.default_html_providers
['Flickr', 'Meetup']
end
|
.host_matches(uri, list) ⇒ Object
163
164
165
|
# File 'lib/onebox/engine/allowlisted_generic_onebox.rb', line 163
def self.host_matches(uri, list)
!!list.find { |h| %r((^|\.)#{Regexp.escape(h)}$).match(uri.host) }
end
|
.html_providers ⇒ Object
142
143
144
|
# File 'lib/onebox/engine/allowlisted_generic_onebox.rb', line 142
def self.html_providers
@html_providers ||= default_html_providers.dup
end
|
.html_providers=(new_provs) ⇒ Object
146
147
148
|
# File 'lib/onebox/engine/allowlisted_generic_onebox.rb', line 146
def self.html_providers=(new_provs)
@html_providers = new_provs
end
|
.https_hosts ⇒ Object
159
160
161
|
# File 'lib/onebox/engine/allowlisted_generic_onebox.rb', line 159
def self.https_hosts
%w(slideshare.net dailymotion.com livestream.com imgur.com flickr.com)
end
|
.priority ⇒ Object
12
13
14
|
# File 'lib/onebox/engine/allowlisted_generic_onebox.rb', line 12
def self.priority
200
end
|
.probable_discourse(uri) ⇒ Object
167
168
169
|
# File 'lib/onebox/engine/allowlisted_generic_onebox.rb', line 167
def self.probable_discourse(uri)
!!(uri.path =~ /\/t\/[^\/]+\/\d+(\/\d+)?(\?.*)?$/)
end
|
.probable_wordpress(uri) ⇒ Object
171
172
173
|
# File 'lib/onebox/engine/allowlisted_generic_onebox.rb', line 171
def self.probable_wordpress(uri)
!!(uri.path =~ /\d{4}\/\d{2}\//)
end
|
.rewrites ⇒ Object
A re-written URL converts http:// -> https://
151
152
153
|
# File 'lib/onebox/engine/allowlisted_generic_onebox.rb', line 151
def self.rewrites
@rewrites ||= https_hosts.dup
end
|
.rewrites=(new_list) ⇒ Object
155
156
157
|
# File 'lib/onebox/engine/allowlisted_generic_onebox.rb', line 155
def self.rewrites=(new_list)
@rewrites = new_list
end
|
Instance Method Details
#placeholder_html ⇒ Object
#to_html ⇒ Object
185
186
187
|
# File 'lib/onebox/engine/allowlisted_generic_onebox.rb', line 185
def to_html
rewrite_https(generic_html)
end
|