onebox 2.1.6 → 2.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b6fd88926ec341ed84409e7c77dbfcce244dbf2a0c74e0a19736e81b2b693e84
4
- data.tar.gz: 18f53e5fb7b1fa4eab35ea27f87e97600e82af0eaf4fd5eed0809744bf7e53c7
3
+ metadata.gz: d9a1e5a4239bdcf5a170e23cb70ae17f581cd25de8c6b72eb911d953119fb8cb
4
+ data.tar.gz: 80057c1f0667b807e1e5be53ff283dabeabe64aa3c3f53d1c63658346e7d12ab
5
5
  SHA512:
6
- metadata.gz: 5a5c344336f529d53b51ac47b5b0efee1b6fb29b0b2541948d650fa1d81e11f97edfa3d1a2f8abb7915b8cf9c86e41c74b64cb40b26924e380f68d52e0015c33
7
- data.tar.gz: 9cefe31755197bbfb71ba3e741329c7bdba10fd9bb19892b237cb78b22769e0e19824119b94cb3cdd24f7bec10f4aeb91cbad3a7d40eefd84c2cbe64866908b0
6
+ metadata.gz: 94a0e7ecc496f75f5f59f40701247fba1bff1068a21c91773e43285c3bf83eadd945ecdd910a8becb454870f5c790baed7626e5cd7d2fe7a6951e7da5fb3e701
7
+ data.tar.gz: 1ad163ff7cfad65008902d27244bd74a9d84e2e49d8600c9ed6f48e74f0fff4d8e77250b36cb4c03e68fdf6f29ab67a8e3e1238b7645156f3f93269f94548329
@@ -152,6 +152,7 @@ require_relative "engine/amazon_onebox"
152
152
  require_relative "engine/github_issue_onebox"
153
153
  require_relative "engine/github_blob_onebox"
154
154
  require_relative "engine/github_commit_onebox"
155
+ require_relative "engine/github_folder_onebox"
155
156
  require_relative "engine/github_gist_onebox"
156
157
  require_relative "engine/github_pullrequest_onebox"
157
158
  require_relative "engine/google_calendar_onebox"
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Onebox
4
+ module Engine
5
+ class GithubFolderOnebox
6
+ include Engine
7
+ include StandardEmbed
8
+ include LayoutSupport
9
+
10
+ matches_regexp Regexp.new(/^https?:\/\/(?:www\.)?(?:(?:\w)+\.)?(github)\.com[\:\d]*(\/\w*){2}\/tree/)
11
+ always_https
12
+
13
+ private
14
+
15
+ def data
16
+ og = get_opengraph
17
+
18
+ max_length = 250
19
+
20
+ display_path = extract_path(og.url, max_length)
21
+ display_description = clean_description(og.description, og.title, max_length)
22
+
23
+ {
24
+ link: og.url,
25
+ path_link: url,
26
+ image: og.image,
27
+ title: og.title,
28
+ path: display_path,
29
+ description: display_description,
30
+ favicon: get_favicon
31
+ }
32
+ end
33
+
34
+ def extract_path(root, max_length)
35
+ path = url.split('#')[0].split('?')[0]
36
+ path = path["#{root}/tree/".length..-1]
37
+ path.length > max_length ? path[-max_length..-1] : path
38
+ end
39
+
40
+ def clean_description(description, title, max_length)
41
+ return unless description
42
+
43
+ desc_end = " - #{title}"
44
+ if description[-desc_end.length..-1] == desc_end
45
+ description = description[0...-desc_end.length]
46
+ end
47
+
48
+ Onebox::Helpers.truncate(description, max_length)
49
+ end
50
+ end
51
+ end
52
+ end
@@ -16,6 +16,8 @@ module Onebox
16
16
 
17
17
  def data
18
18
  oembed = get_oembed
19
+ raise "No oEmbed data found. Ensure 'facebook_app_access_token' is valid" if oembed.data.empty?
20
+
19
21
  permalink = clean_url.gsub("/#{oembed.author_name}/", "/")
20
22
 
21
23
  { link: permalink,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Onebox
4
- VERSION = "2.1.6"
4
+ VERSION = "2.1.7"
5
5
  end
@@ -0,0 +1,11 @@
1
+ {{#image}}<img src="{{image}}" class="thumbnail"/>{{/image}}
2
+
3
+ <h3><a href='{{link}}' target="_blank" rel="noopener">{{title}}</a></h3>
4
+
5
+ {{#path}}
6
+ <p><a href='{{path_link}}' target="_blank" rel="noopener">{{path}}</a></p>
7
+ {{/path}}
8
+
9
+ {{#description}}
10
+ <p><span class="label1">{{description}}</span></p>
11
+ {{/description}}
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: 2.1.6
4
+ version: 2.1.7
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: 2020-11-16 00:00:00.000000000 Z
13
+ date: 2020-11-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: addressable
@@ -316,6 +316,7 @@ files:
316
316
  - lib/onebox/engine/giphy_onebox.rb
317
317
  - lib/onebox/engine/github_blob_onebox.rb
318
318
  - lib/onebox/engine/github_commit_onebox.rb
319
+ - lib/onebox/engine/github_folder_onebox.rb
319
320
  - lib/onebox/engine/github_gist_onebox.rb
320
321
  - lib/onebox/engine/github_issue_onebox.rb
321
322
  - lib/onebox/engine/github_pullrequest_onebox.rb
@@ -383,6 +384,7 @@ files:
383
384
  - templates/amazon.mustache
384
385
  - templates/githubblob.mustache
385
386
  - templates/githubcommit.mustache
387
+ - templates/githubfolder.mustache
386
388
  - templates/githubgist.mustache
387
389
  - templates/githubissue.mustache
388
390
  - templates/githubpullrequest.mustache