onebox 1.8.81 → 1.8.82
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 -154
- 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 +1 -1
- data/lib/onebox/mixins/twitch_onebox.rb +0 -0
- data/lib/onebox/oembed.rb +15 -15
- data/lib/onebox/open_graph.rb +90 -90
- 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 +1 -1
- 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 +3 -4
data/lib/onebox/layout.rb
CHANGED
File without changes
|
File without changes
|
data/lib/onebox/matcher.rb
CHANGED
File without changes
|
@@ -115,7 +115,7 @@ module Onebox
|
|
115
115
|
a_lines.each do |l|
|
116
116
|
l = l.chomp("\n") # remove new line
|
117
117
|
m = l.match(/^[ ]*/) # find leading spaces 0 or more
|
118
|
-
unless m.nil? || l.size == m[0].size ||
|
118
|
+
unless m.nil? || l.size == m[0].size || l.size == 0 # no match | only spaces in line | empty line
|
119
119
|
m_str_length = m[0].size
|
120
120
|
if m_str_length <= 1 # minimum space is 1 or nothing we can break we found our minimum
|
121
121
|
min_space = m_str_length
|
File without changes
|
data/lib/onebox/oembed.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
module Onebox
|
2
|
-
class Oembed < OpenGraph
|
3
|
-
|
4
|
-
def initialize(response)
|
5
|
-
@data = Onebox::Helpers.symbolize_keys(::MultiJson.load(response))
|
6
|
-
|
7
|
-
# never use oembed from WordPress 4.4 (it's broken)
|
8
|
-
data.delete(:html) if data[:html] && data[:html]["wp-embedded-content"]
|
9
|
-
end
|
10
|
-
|
11
|
-
def html
|
12
|
-
get(:html, nil, false)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
1
|
+
module Onebox
|
2
|
+
class Oembed < OpenGraph
|
3
|
+
|
4
|
+
def initialize(response)
|
5
|
+
@data = Onebox::Helpers.symbolize_keys(::MultiJson.load(response))
|
6
|
+
|
7
|
+
# never use oembed from WordPress 4.4 (it's broken)
|
8
|
+
data.delete(:html) if data[:html] && data[:html]["wp-embedded-content"]
|
9
|
+
end
|
10
|
+
|
11
|
+
def html
|
12
|
+
get(:html, nil, false)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/onebox/open_graph.rb
CHANGED
@@ -1,90 +1,90 @@
|
|
1
|
-
module Onebox
|
2
|
-
class OpenGraph
|
3
|
-
|
4
|
-
attr_reader :data
|
5
|
-
|
6
|
-
def initialize(doc)
|
7
|
-
@data = extract(doc)
|
8
|
-
end
|
9
|
-
|
10
|
-
def title
|
11
|
-
get(:title, 80)
|
12
|
-
end
|
13
|
-
|
14
|
-
def title_attr
|
15
|
-
!title.nil? ? "title='#{title}'" : ""
|
16
|
-
end
|
17
|
-
|
18
|
-
def get_secure_image
|
19
|
-
secure_link = URI(get(:image))
|
20
|
-
secure_link.scheme = 'https'
|
21
|
-
secure_link.to_s
|
22
|
-
end
|
23
|
-
|
24
|
-
def method_missing(attr, *args, &block)
|
25
|
-
value = get(attr, *args)
|
26
|
-
|
27
|
-
return nil if Onebox::Helpers::blank?(value)
|
28
|
-
|
29
|
-
method_name = attr.to_s
|
30
|
-
if method_name.end_with?(*integer_suffixes)
|
31
|
-
value.to_i
|
32
|
-
elsif method_name.end_with?(*url_suffixes)
|
33
|
-
::Onebox::Helpers.normalize_url_for_output(value)
|
34
|
-
else
|
35
|
-
value
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def get(attr, length = nil, sanitize = true)
|
40
|
-
return nil if Onebox::Helpers::blank?(data)
|
41
|
-
|
42
|
-
value = data[attr]
|
43
|
-
|
44
|
-
return nil if Onebox::Helpers::blank?(value)
|
45
|
-
|
46
|
-
value = html_entities.decode(value)
|
47
|
-
value = Sanitize.fragment(value) if sanitize
|
48
|
-
value.strip!
|
49
|
-
value = Onebox::Helpers.truncate(value, length) unless length.nil?
|
50
|
-
|
51
|
-
value
|
52
|
-
end
|
53
|
-
|
54
|
-
private
|
55
|
-
|
56
|
-
def integer_suffixes
|
57
|
-
['width', 'height']
|
58
|
-
end
|
59
|
-
|
60
|
-
def url_suffixes
|
61
|
-
['url', 'image', 'video']
|
62
|
-
end
|
63
|
-
|
64
|
-
def html_entities
|
65
|
-
@html_entities ||= HTMLEntities.new
|
66
|
-
end
|
67
|
-
|
68
|
-
def extract(doc)
|
69
|
-
return {} if Onebox::Helpers::blank?(doc)
|
70
|
-
|
71
|
-
data = {}
|
72
|
-
|
73
|
-
doc.css('meta').each do |m|
|
74
|
-
if (m["property"] && m["property"][/^(?:og|article|product):(.+)$/i]) || (m["name"] && m["name"][/^(?:og|article|product):(.+)$/i])
|
75
|
-
value = (m["content"] || m["value"]).to_s
|
76
|
-
data[$1.tr('-:', '_').to_sym] ||= value unless Onebox::Helpers::blank?(value)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
# Attempt to retrieve the title from the meta tag
|
81
|
-
title_element = doc.at_css('title')
|
82
|
-
if title_element && title_element.text
|
83
|
-
data[:title] ||= title_element.text unless Onebox::Helpers.blank?(title_element.text)
|
84
|
-
end
|
85
|
-
|
86
|
-
data
|
87
|
-
end
|
88
|
-
|
89
|
-
end
|
90
|
-
end
|
1
|
+
module Onebox
|
2
|
+
class OpenGraph
|
3
|
+
|
4
|
+
attr_reader :data
|
5
|
+
|
6
|
+
def initialize(doc)
|
7
|
+
@data = extract(doc)
|
8
|
+
end
|
9
|
+
|
10
|
+
def title
|
11
|
+
get(:title, 80)
|
12
|
+
end
|
13
|
+
|
14
|
+
def title_attr
|
15
|
+
!title.nil? ? "title='#{title}'" : ""
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_secure_image
|
19
|
+
secure_link = URI(get(:image))
|
20
|
+
secure_link.scheme = 'https'
|
21
|
+
secure_link.to_s
|
22
|
+
end
|
23
|
+
|
24
|
+
def method_missing(attr, *args, &block)
|
25
|
+
value = get(attr, *args)
|
26
|
+
|
27
|
+
return nil if Onebox::Helpers::blank?(value)
|
28
|
+
|
29
|
+
method_name = attr.to_s
|
30
|
+
if method_name.end_with?(*integer_suffixes)
|
31
|
+
value.to_i
|
32
|
+
elsif method_name.end_with?(*url_suffixes)
|
33
|
+
::Onebox::Helpers.normalize_url_for_output(value)
|
34
|
+
else
|
35
|
+
value
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def get(attr, length = nil, sanitize = true)
|
40
|
+
return nil if Onebox::Helpers::blank?(data)
|
41
|
+
|
42
|
+
value = data[attr]
|
43
|
+
|
44
|
+
return nil if Onebox::Helpers::blank?(value)
|
45
|
+
|
46
|
+
value = html_entities.decode(value)
|
47
|
+
value = Sanitize.fragment(value) if sanitize
|
48
|
+
value.strip!
|
49
|
+
value = Onebox::Helpers.truncate(value, length) unless length.nil?
|
50
|
+
|
51
|
+
value
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def integer_suffixes
|
57
|
+
['width', 'height']
|
58
|
+
end
|
59
|
+
|
60
|
+
def url_suffixes
|
61
|
+
['url', 'image', 'video']
|
62
|
+
end
|
63
|
+
|
64
|
+
def html_entities
|
65
|
+
@html_entities ||= HTMLEntities.new
|
66
|
+
end
|
67
|
+
|
68
|
+
def extract(doc)
|
69
|
+
return {} if Onebox::Helpers::blank?(doc)
|
70
|
+
|
71
|
+
data = {}
|
72
|
+
|
73
|
+
doc.css('meta').each do |m|
|
74
|
+
if (m["property"] && m["property"][/^(?:og|article|product):(.+)$/i]) || (m["name"] && m["name"][/^(?:og|article|product):(.+)$/i])
|
75
|
+
value = (m["content"] || m["value"]).to_s
|
76
|
+
data[$1.tr('-:', '_').to_sym] ||= value unless Onebox::Helpers::blank?(value)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# Attempt to retrieve the title from the meta tag
|
81
|
+
title_element = doc.at_css('title')
|
82
|
+
if title_element && title_element.text
|
83
|
+
data[:title] ||= title_element.text unless Onebox::Helpers.blank?(title_element.text)
|
84
|
+
end
|
85
|
+
|
86
|
+
data
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
end
|
data/lib/onebox/preview.rb
CHANGED
File without changes
|
File without changes
|
data/lib/onebox/status_check.rb
CHANGED
File without changes
|
File without changes
|
data/lib/onebox/version.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Onebox
|
4
|
-
VERSION = "1.8.
|
5
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Onebox
|
4
|
+
VERSION = "1.8.82"
|
5
|
+
end
|
data/lib/onebox/view.rb
CHANGED
File without changes
|
data/lib/onebox/web.rb
CHANGED
File without changes
|
data/lib/onebox/web_helpers.rb
CHANGED
File without changes
|
data/onebox.gemspec
CHANGED
File without changes
|
data/templates/_layout.mustache
CHANGED
File without changes
|
data/templates/amazon.mustache
CHANGED
File without changes
|
data/templates/douban.mustache
CHANGED
File without changes
|
@@ -27,7 +27,7 @@ pre.onebox code li.selected{
|
|
27
27
|
}
|
28
28
|
</style>
|
29
29
|
}}
|
30
|
-
<pre class='onebox' ><code class='{{lang}}'><ol
|
30
|
+
<pre class='onebox' ><code class='{{lang}}'><ol class='start lines' start="{{cr_results.from}}" style='counter-reset: li-counter {{cr_results.from_minus_one}} ;'>
|
31
31
|
{{#lines}}<li{{#selected}} class="selected"{{/selected}}>{{data}}</li>{{/lines}}
|
32
32
|
</ol></code></pre>
|
33
33
|
{{/has_lines}}
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/templates/pastebin.mustache
CHANGED
File without changes
|
data/templates/pdf.mustache
CHANGED
File without changes
|
data/templates/pubmed.mustache
CHANGED
File without changes
|
File without changes
|
File without changes
|
data/templates/wechatmp.mustache
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/templates/xkcd.mustache
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onebox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.82
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joanna Zeta
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2019-03-
|
13
|
+
date: 2019-03-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: multi_json
|
@@ -418,8 +418,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
418
418
|
- !ruby/object:Gem::Version
|
419
419
|
version: '0'
|
420
420
|
requirements: []
|
421
|
-
|
422
|
-
rubygems_version: 2.7.8
|
421
|
+
rubygems_version: 3.0.0
|
423
422
|
signing_key:
|
424
423
|
specification_version: 4
|
425
424
|
summary: A gem for generating embeddable HTML previews from URLs.
|