onebox 1.9.15 → 1.9.16

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: b2d622a19807117f6d8c14ecd71e6ec4c74800c210ce976005455c8764c8c8f2
4
- data.tar.gz: b9bf2c897a097312bf7ae9fc951abf8ad0c64742aad4ed59953b9e36fcb4b9f9
3
+ metadata.gz: 1d132e970ee3bf4b66a61cdac190169b51fb1208148494eafcfbbdf483467f44
4
+ data.tar.gz: 439181659be99f1d3150b9377dc2dbf49a73a2606255554c5b1d4f4f542d7b47
5
5
  SHA512:
6
- metadata.gz: 9cef39c90059bd9dc86e940d2a315ad5dbc0624c9deceb1df5129571aef0029985396526a4a758cb6891ac0618c930d5267e3f46524ccf1424037ae0fdf448a7
7
- data.tar.gz: 2afd1bb5f8568cd35eea12c9a82f168ff937d35aa3f38aff2cecd1b4acd9f1a5b1914da6db4a9835ec32fcaf8b5bd3012ee0b6201a4692b6dcd23ddd6729ed12
6
+ metadata.gz: ae2e84808088cc38680fc62862d565f9ae409e0f1889d32f472fd070cf4e1cae6a6407576652fc11d22d4d6a3f082989286f404a4c61f2c84b7a08839fd0ff93
7
+ data.tar.gz: 0b955b5a6ce936396740423744cde0e0611a6d4258d974f4f56382efc8a02692250a72e04b356ce0f4fd808eb7d85137147d1a91c774d17a19e794e4edcf2c86
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- onebox (1.9.15)
4
+ onebox (1.9.16)
5
5
  htmlentities (~> 4.3)
6
6
  moneta (~> 1.0)
7
7
  multi_json (~> 1.11)
@@ -151,4 +151,4 @@ DEPENDENCIES
151
151
  twitter (~> 4.8)
152
152
 
153
153
  BUNDLED WITH
154
- 2.0.1
154
+ 2.0.2
data/README.md CHANGED
@@ -184,7 +184,7 @@ Adding Support for a new URL
184
184
  Whitelisted Generic Onebox caveats
185
185
  ----------------------------------
186
186
 
187
- The Whitelisted Generic Onebox has some caveats for it's use, beyond simply whitelisting the domain.
187
+ The Whitelisted Generic Onebox has some caveats for its use, beyond simply whitelisting the domain.
188
188
 
189
189
  1. The domain must be whitelisted
190
190
  2. The URL you're oneboxing cannot be a root url (e.g. `http://example.com` won't work, but `http://example.com/page` will)
@@ -7,7 +7,7 @@ module Onebox
7
7
  include LayoutSupport
8
8
  include JSON
9
9
 
10
- matches_regexp Regexp.new("^https?://(?:www\.)?(?:(?:\w)+\.)?(github)\.com(?:/)?(?:.)*/commits?/")
10
+ matches_regexp Regexp.new("^https?://(?:www\.)?(?:(?:\w)+\.)?(github)\.com(?:/)?(?:.)*/commit/")
11
11
  always_https
12
12
 
13
13
  def url
@@ -19,9 +19,9 @@ module Onebox
19
19
  def match
20
20
  return @match if @match
21
21
 
22
- @match = @url.match(%{github\.com/(?<owner>[^/]+)/(?<repository>[^/]+)/commits?/(?<sha>[^/]+)})
22
+ @match = @url.match(%{github\.com/(?<owner>[^/]+)/(?<repository>[^/]+)/commit/(?<sha>[^/]+)})
23
23
 
24
- @match = @url.match(%{github\.com/(?<owner>[^/]+)/(?<repository>[^/]+)/pull/(?<pr>[^/]+)/commits?/(?<sha>[^/]+)}) if @match.nil?
24
+ @match = @url.match(%{github\.com/(?<owner>[^/]+)/(?<repository>[^/]+)/pull/(?<pr>[^/]+)/commit/(?<sha>[^/]+)}) if @match.nil?
25
25
 
26
26
  @match
27
27
  end
@@ -42,7 +42,10 @@ module Onebox
42
42
  end
43
43
 
44
44
  ulink = URI(link)
45
- result['commit_date'] = Time.parse(result['commit']['author']['date']).strftime("%I:%M%p - %d %b %y %Z")
45
+ committed_at = Time.parse(result['commit']['author']['date'])
46
+ result['committed_at'] = committed_at.strftime("%I:%M%p - %d %b %y %Z")
47
+ result['committed_at_date'] = committed_at.strftime("%F")
48
+ result['committed_at_time'] = committed_at.strftime("%T")
46
49
  result['domain'] = "#{ulink.host}/#{ulink.path.split('/')[1]}/#{ulink.path.split('/')[2]}"
47
50
  result
48
51
  end
@@ -31,6 +31,9 @@ module Onebox
31
31
  short_content = content_words[0..max_words].join(" ")
32
32
  short_content += "..." if content_words.length > max_words
33
33
 
34
+ created_at = Time.parse(@raw['created_at'])
35
+ closed_at = Time.parse(@raw['closed_at']) if @raw['closed_at']
36
+
34
37
  ulink = URI(link)
35
38
  {
36
39
  link: @url,
@@ -38,8 +41,12 @@ module Onebox
38
41
  content: short_content.gsub("<br>", "\n"),
39
42
  labels: @raw["labels"],
40
43
  user: @raw['user'],
41
- created_at: @raw['created_at'].split("T")[0], #get only date for now
42
- closed_at: (@raw['closed_at'].nil? ? "" : @raw['closed_at'].split("T")[0]),
44
+ created_at: created_at.strftime("%I:%M%p - %d %b %y %Z"),
45
+ created_at_date: created_at.strftime("%F"),
46
+ created_at_time: created_at.strftime("%T"),
47
+ closed_at: closed_at&.strftime("%I:%M%p - %d %b %y %Z"),
48
+ closed_at_date: closed_at&.strftime("%F"),
49
+ closed_at_time: closed_at&.strftime("%T"),
43
50
  closed_by: @raw['closed_by'],
44
51
  avatar: "https://avatars1.githubusercontent.com/u/#{@raw['user']['id']}?v=2&s=96",
45
52
  domain: "#{ulink.host}/#{ulink.path.split('/')[1]}/#{ulink.path.split('/')[2]}",
@@ -23,7 +23,12 @@ module Onebox
23
23
  def data
24
24
  result = raw.clone
25
25
  result['link'] = link
26
- result['created_at'] = Time.parse(result['created_at']).strftime("%I:%M%p - %d %b %y %Z")
26
+
27
+ created_at = Time.parse(result['created_at'])
28
+ result['created_at'] = created_at.strftime("%I:%M%p - %d %b %y %Z")
29
+ result['created_at_date'] = created_at.strftime("%F")
30
+ result['created_at_time'] = created_at.strftime("%T")
31
+
27
32
  ulink = URI(link)
28
33
  result['domain'] = "#{ulink.host}/#{ulink.path.split('/')[1]}/#{ulink.path.split('/')[2]}"
29
34
  result
@@ -17,7 +17,8 @@ class Sanitize
17
17
  'video' => %w[controls height loop width autoplay muted poster],
18
18
  'path' => %w[d],
19
19
  'svg' => ['aria-hidden', 'width', 'height', 'viewbox'],
20
- 'div' => [:data], # any data-* attributes
20
+ 'div' => [:data], # any data-* attributes,
21
+ 'span' => [:data], # any data-* attributes
21
22
  },
22
23
 
23
24
  add_attributes: {
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Onebox
4
- VERSION = "1.9.15"
4
+ VERSION = "1.9.16"
5
5
  end
@@ -1,25 +1,41 @@
1
- <svg width="60" height="60" class="github-icon" viewBox="0 0 14 16" version="1.1" aria-hidden="true"><path fill-rule="evenodd" d="M10.86 7c-.45-1.72-2-3-3.86-3-1.86 0-3.41 1.28-3.86 3H0v2h3.14c.45 1.72 2 3 3.86 3 1.86 0 3.41-1.28 3.86-3H14V7h-3.14zM7 10.2c-1.22 0-2.2-.98-2.2-2.2 0-1.22.98-2.2 2.2-2.2 1.22 0 2.2.98 2.2 2.2 0 1.22-.98 2.2-2.2 2.2z"></path></svg>
1
+ <div class="github-row">
2
+ <div class="github-icon-container" title="Commit">
3
+ <svg width="60" height="60" class="github-icon" viewBox="0 0 14 16" version="1.1" aria-hidden="true"><path fill-rule="evenodd" d="M10.86 7c-.45-1.72-2-3-3.86-3-1.86 0-3.41 1.28-3.86 3H0v2h3.14c.45 1.72 2 3 3.86 3 1.86 0 3.41-1.28 3.86-3H14V7h-3.14zM7 10.2c-1.22 0-2.2-.98-2.2-2.2 0-1.22.98-2.2 2.2-2.2 1.22 0 2.2.98 2.2 2.2 0 1.22-.98 2.2-2.2 2.2z"></path></svg>
4
+ </div>
2
5
 
3
- <h4>
4
- {{#author.avatar_url}}
5
- <a href="{{author.html_url}}" target="_blank">
6
- <img alt="{{author.login}}" src="{{author.avatar_url}}" class="onebox-avatar-inline" width="20" height="20">
7
- </a>
8
- {{/author.avatar_url}}
9
- <a href="{{html_url}}" target="_blank">{{title}}</a>
10
- </h4>
6
+ <div class="github-info-container">
7
+ <h4>
8
+ <a href="{{html_url}}" target="_blank">{{title}}</a>
9
+ </h4>
11
10
 
12
- {{#message}}
13
- <pre class="message" style="white-space: normal;">{{message}}</pre>
14
- {{/message}}
11
+ <div class="github-info">
12
+ <div class="date">
13
+ committed <span class="discourse-local-date" data-format='ll' data-date="{{committed_at_date}}" data-time="{{committed_at_time}}" data-timezone="UTC">{{committed_at}}</span>
14
+ </div>
15
15
 
16
- <div class="date">
17
- commit by <a href="{{author.html_url}}" target="_blank">{{author.login}}</a>
18
- on <a href="{{html_url}}" target="_blank">{{commit_date}}</a>
19
- </div>
16
+ <div class="user">
17
+ <a href="{{author.html_url}}" target="_blank">
18
+ <img alt="{{author.login}}" src="{{author.avatar_url}}" class="onebox-avatar-inline" width="20" height="20">
19
+ {{author.login}}
20
+ </a>
21
+
22
+ </div>
20
23
 
21
- <div class="github-commit-stats">
22
- changed <strong>{{files.length}} files</strong>
23
- with <strong>{{stats.additions}} additions</strong>
24
- and <strong>{{stats.deletions}} deletions</strong>.
24
+ <div class="lines" title="changed {{files.length}} files with {{stats.additions}} additions and {{stats.deletions}} deletions">
25
+ <a href="{{html_url}}/files" target="_blank">
26
+ <span class="added">+{{stats.additions}}</span>
27
+ <span class="removed">-{{stats.deletions}}</span>
28
+ </a>
29
+ </div>
30
+ </div>
31
+
32
+ </div>
25
33
  </div>
34
+
35
+
36
+ {{#message}}
37
+ <div class="github-row">
38
+ <pre class="github-content" style="white-space: normal;">{{message}}</pre>
39
+ </div>
40
+ {{/message}}
41
+
@@ -1,29 +1,40 @@
1
- <svg width="60" height="60" class="github-icon" viewBox="0 0 14 16" version="1.1" aria-hidden="true"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg>
1
+ <div class="github-row">
2
+ <div class="github-icon-container" title="Issue">
3
+ <svg width="60" height="60" class="github-icon" viewBox="0 0 14 16" version="1.1" aria-hidden="true"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg>
4
+ </div>
2
5
 
3
- <h4>
4
- <a href="{{user.html_url}}">
5
- <img src="{{avatar}}" class="onebox-avatar-inline" height="20" width="20">
6
- </a>
7
- <a href="{{link}}" target="_blank">{{title}}</a>
8
- </h4>
6
+ <div class="github-info-container">
7
+ <h4>
8
+ <a href="{{link}}" target="_blank">{{title}}</a>
9
+ </h4>
9
10
 
10
- <div class="date" style="margin-top:10px;">
11
- <div class="user" style="margin-top:10px;">
12
- issue opened by <a href="{{user.html_url}}" target="_blank">{{user.login}}</a>
13
- on <a href="{{link}}" target="_blank">{{created_at}}</a>
14
- </div>
15
- <div class="user">
16
- {{#closed_by}}
17
- closed by <a href="{{html_url}}" target="_blank">{{login}}</a>
18
- on <a href="{{link}}" target="_blank">{{closed_at}}</a>
19
- {{/closed_by}}
20
- </div>
21
- </div>
11
+ <div class="github-info">
12
+ <div class="date">
13
+ opened <span class="discourse-local-date" data-format='ll' data-date="{{created_at_date}}" data-time="{{created_at_time}}" data-timezone="UTC">{{created_at}}</span>
14
+ </div>
15
+
16
+ {{#closed_at}}
17
+ <div class="date">
18
+ closed <span class="discourse-local-date" data-format='ll' data-date="{{closed_at_date}}" data-time="{{closed_at_time}}" data-timezone="UTC">{{closed_at}}</span>
19
+ </div>
20
+ {{/closed_at}}
22
21
 
23
- <p class='content' style="white-space: pre-wrap;">{{content}}</p>
22
+ <div class="user">
23
+ <a href="{{user.html_url}}" target="_blank">
24
+ <img alt="{{user.login}}" src="{{user.avatar_url}}" class="onebox-avatar-inline" width="20" height="20">
25
+ {{user.login}}
26
+ </a>
27
+ </div>
28
+ </div>
29
+ </div>
30
+ </div>
24
31
 
25
- <div class='labels'>
26
- {{#labels}}
27
- <span style="display:inline-block;margin-top:2px;background-color: #B8B8B8;padding: 2px;border-radius: 4px;color: #fff;margin-left: 3px;">{{name}}</span>
28
- {{/labels}}
32
+ <div class="github-row">
33
+ <p class='github-content'>{{content}}</p>
29
34
  </div>
35
+
36
+ {{#labels}}
37
+ <div class='labels'>
38
+ <span style="display:inline-block;margin-top:2px;background-color: #B8B8B8;padding: 2px;border-radius: 4px;color: #fff;margin-left: 3px;">{{name}}</span>
39
+ </div>
40
+ {{/labels}}
@@ -1,22 +1,36 @@
1
- <svg width="60" height="60" class="github-icon" viewBox="0 0 12 16" version="1.1" aria-hidden="true"><path fill-rule="evenodd" d="M11 11.28V5c-.03-.78-.34-1.47-.94-2.06C9.46 2.35 8.78 2.03 8 2H7V0L4 3l3 3V4h1c.27.02.48.11.69.31.21.2.3.42.31.69v6.28A1.993 1.993 0 0 0 10 15a1.993 1.993 0 0 0 1-3.72zm-1 2.92c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zM4 3c0-1.11-.89-2-2-2a1.993 1.993 0 0 0-1 3.72v6.56A1.993 1.993 0 0 0 2 15a1.993 1.993 0 0 0 1-3.72V4.72c.59-.34 1-.98 1-1.72zm-.8 10c0 .66-.55 1.2-1.2 1.2-.65 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"></path></svg>
1
+ <div class="github-row">
2
+ <div class="github-icon-container" title="Pull Request">
3
+ <svg width="60" height="60" class="github-icon" viewBox="0 0 12 16" version="1.1" aria-hidden="true"><path fill-rule="evenodd" d="M11 11.28V5c-.03-.78-.34-1.47-.94-2.06C9.46 2.35 8.78 2.03 8 2H7V0L4 3l3 3V4h1c.27.02.48.11.69.31.21.2.3.42.31.69v6.28A1.993 1.993 0 0 0 10 15a1.993 1.993 0 0 0 1-3.72zm-1 2.92c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zM4 3c0-1.11-.89-2-2-2a1.993 1.993 0 0 0-1 3.72v6.56A1.993 1.993 0 0 0 2 15a1.993 1.993 0 0 0 1-3.72V4.72c.59-.34 1-.98 1-1.72zm-.8 10c0 .66-.55 1.2-1.2 1.2-.65 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"></path></svg>
4
+ </div>
2
5
 
3
- <h4>
4
- {{#user.avatar_url}}
5
- <a href="{{user.html_url}}" target="_blank">
6
- <img alt="{{user.login}}" src="{{user.avatar_url}}" class="onebox-avatar-inline" width="20" height="20">
7
- </a>
8
- {{/user.avatar_url}}
9
- <a href="{{html_url}}" target="_blank">{{title}}</a>
10
- </h4>
6
+ <div class="github-info-container">
7
+ <h4>
8
+ <a href="{{html_url}}" target="_blank">{{title}}</a>
9
+ </h4>
11
10
 
12
- <div class="date">
13
- pull request by <a href="{{user.html_url}}" target="_blank">{{user.login}}</a>
14
- on <a href="{{html_url}}" target="_blank">{{created_at}}</a>
15
- </div>
11
+ <div class="branches">
12
+ <code>{{base.label}}</code> ← <code>{{head.label}}</code>
13
+ </div>
16
14
 
17
- <div class="github-commit-stats">
18
- <strong>{{commits}} commits</strong>
19
- changed <strong>{{changed_files}} files</strong>
20
- with <strong>{{additions}} additions</strong>
21
- and <strong>{{deletions}} deletions</strong>.
22
- </div>
15
+ <div class="github-info">
16
+ <div class="date">
17
+ opened <span class="discourse-local-date" data-format='ll' data-date="{{created_at_date}}" data-time="{{created_at_time}}" data-timezone="UTC">{{created_at}}</span>
18
+ </div>
19
+
20
+ <div class="user">
21
+ <a href="{{user.html_url}}" target="_blank">
22
+ <img alt="{{user.login}}" src="{{user.avatar_url}}" class="onebox-avatar-inline" width="20" height="20">
23
+ {{user.login}}
24
+ </a>
25
+ </div>
26
+
27
+ <div class="lines" title="{{commits}} commits changed {{changed_files}} files with {{additions}} additions and {{deletions}} deletions">
28
+ <a href="{{html_url}}/files" target="_blank">
29
+ <span class="added">+{{additions}}</span>
30
+ <span class="removed">-{{deletions}}</span>
31
+ </a>
32
+ </div>
33
+ </div>
34
+
35
+ </div>
36
+ </div>
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.9.15
4
+ version: 1.9.16
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-10-08 00:00:00.000000000 Z
13
+ date: 2019-10-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: multi_json