onebox 1.5.1 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2d45ecfeb440c52d2c6d45aaec72669ad24f170b
4
- data.tar.gz: 84c5f37f871a0e5a792f179d6d4983bc9c588e52
3
+ metadata.gz: 542e1d08ae3e97ddf61f8277d8328b8836a5785a
4
+ data.tar.gz: 02d39f351722e9020bff8669d1bbc6ff820bf06e
5
5
  SHA512:
6
- metadata.gz: 9cc1a432d53eaa94625f3dcea777e8cfb3247770334ced74b91295832bffed4fdc584c33f4c786a954ced16ba1f7010d6799c5cc29232748f29c1a69e6972063
7
- data.tar.gz: 2ce5bae6fa88b77fa5f9e6a2dd1f0c6395836e51bea065dff2c62b4e79ea1329c8b4e7319a4e436a63427c4d793d8b8c1b034f52f085d9ad33f36892113c1047
6
+ metadata.gz: 639e272ae320e29103d3e2ef022cbac34e2ebbefedf5dc0e9e0955dafdb93098af1fda4dd3f2f674d486e2a6f9fc4f118d7d980fdd084d66bcc0ac71ac0284c9
7
+ data.tar.gz: b34ca56a4cba354ba0de3d614986325bb316f5e55a54a9a7b684cc55357d01e6050ee601304f6d2187e1d92a02c8726118014329e9baabf8c737579f051b2c79
@@ -47,23 +47,24 @@ module Onebox
47
47
  box_options = self.options
48
48
  result = raw.clone
49
49
 
50
- pull_status = "Pull Status:" << {:closed=>"closed",:open=>"open"}[raw["state"].to_sym] << (raw["state"] == "closed" ? (raw["merged"] ? " & accepted" : " & declined") : "") #closed , open
50
+ pull_status = "" << {:closed=>"closed",:open=>"open"}[raw["state"].to_sym] << (raw["state"] == "closed" ? (raw["merged"] ? " & merged" : " & declined") : "") #closed , open
51
51
  result['pull_status_str'] = pull_status
52
+ result['pull_status'] = raw["state"]
53
+ result['pull_status_str'] = pull_status
54
+ result['pull_status_str_open'] = raw["state"]=="open"
55
+ result['pull_status_closed_accepted'] = raw["state"]=="closed" && raw["merged"]
56
+ result['pull_status_closed_declined'] = raw["state"]=="closed" && !raw["merged"]
57
+ result['pull_status_class'] = (raw["merged"] ? "merged": raw["state"] ) # open, merged, close
58
+ result['pull_status_bgcolor'] = {:open=>"#6cc644",:merged =>"6e5494", :closed=> "#bd2c00"}[result['pull_status_class'].to_sym]
59
+ result['inline_css'] = false #set to true if you need basic styling and you don't have external css
52
60
  if box_options[:get_build_status]
53
61
  url2 = raw["statuses_url"]
54
- raw2 = api_json_request url2 #2nd api request to get build status
55
-
56
- result['pull_status'] = raw["state"]
57
- result['pull_status_str'] = pull_status
58
- result['pull_status_str_open'] = raw["state"]=="open"
59
- result['pull_status_closed_accepted'] = raw["state"]=="closed" && raw["merged"]
60
- result['pull_status_closed_declined'] = raw["state"]=="closed" && !raw["merged"]
62
+ raw2 = api_json_request url2 #2nd api request to get build status
61
63
  unless raw2.empty?
62
64
  result['build_status'] = "Build status: " + raw2[0]["state"].to_s.capitalize + " | " + raw2[0]["description"].to_s
63
65
  end
64
66
  end
65
67
 
66
-
67
68
  result['link'] = link
68
69
  result['created_at'] = Time.parse(result['created_at']).strftime("%I:%M%p - %d %b %y")
69
70
  result
@@ -65,7 +65,6 @@ module Onebox
65
65
  instagr.am
66
66
  instagram.com
67
67
  itunes.apple.com
68
- justin.tv
69
68
  khanacademy.org
70
69
  kickstarter.com
71
70
  kinomap.com
@@ -243,12 +242,44 @@ module Onebox
243
242
 
244
243
 
245
244
  if video_url
246
- html = "<iframe src=\"#{video_url}\" frameborder=\"0\" title=\"#{data[:title]}\""
245
+ # opengraph support multiple elements (videos, images ,etc).
246
+ # We attempt to find a video element with the type of video/mp4
247
+ # and generate a native <video> element for it.
247
248
 
248
- append_attribute(:width, html, video)
249
- append_attribute(:height, html, video)
249
+ if (@raw.metadata && @raw.metadata[:"video:type"])
250
+ video_type = @raw.metadata[:"video:type"]
251
+ if video_type.include? "video/mp4" #find if there is a video with type
252
+ if video_type.size > 1 #if more then one video item based on provided video_type
253
+ ind = video_type.find_index("video/mp4") #get the first video index with type video/mp4
254
+ video_url = @raw.metadata[:video][ind] #update video_url
255
+ end
256
+
257
+ attr = append_attribute(:width, attr, video)
258
+ attr = append_attribute(:height, attr, video)
259
+
260
+ # html_v1 = %Q(<video #{attr} title="#{data[:title]}" controls="" ><source src="#{video_url}"></video>)
250
261
 
251
- html << "></iframe>"
262
+ site_name_and_title = ( ("<span style='color:#fff;background:#9B9B9B;border-radius:3px;padding:3px;margin-right: 5px;'>" + CGI::escapeHTML(@raw.metadata[:site_name][0].to_s) + '</span> ') + CGI::escapeHTML((@raw.title || @raw.description).to_s) )
263
+
264
+ orig_url = @raw.url
265
+ html_v2 = %Q(
266
+ <div style='position:relative;padding-top:29px;'>
267
+ <span style='position: absolute;top:0px;z-index:2;color:#000;white-space:nowrap;text-overflow:ellipsis;word-wrap: break-word;overflow: hidden;display: inline-block;padding: 3px;border-radius: 4px;max-width: 100%;'><a href='#{orig_url}' target='_blank'>#{site_name_and_title}</a></span>
268
+ <video style='max-width:100%' #{attr} title="#{data[:title]}" controls="" ><source src="#{video_url}"></video>
269
+ </div>
270
+ )
271
+ html = html_v2
272
+
273
+ else
274
+
275
+ html = "<iframe src=\"#{video_url}\" frameborder=\"0\" title=\"#{data[:title]}\""
276
+ append_attribute(:width, html, video)
277
+ append_attribute(:height, html, video)
278
+
279
+ html << "></iframe>"
280
+ end
281
+
282
+ end
252
283
  return html
253
284
  end
254
285
  end
@@ -261,4 +292,4 @@ module Onebox
261
292
  end
262
293
  end
263
294
  end
264
- end
295
+ end
@@ -1,3 +1,3 @@
1
1
  module Onebox
2
- VERSION = "1.5.1"
2
+ VERSION = "1.5.2"
3
3
  end
@@ -8,35 +8,66 @@
8
8
  <a href="{{html_url}}" target="_blank">{{title}}</a>
9
9
  </h4>
10
10
 
11
+ <div class='github-commit-status github-content-right' {{#inline_css}}style='margin-bottom:5px;padding: 10px;background: #F5F5F5;margin-left: 100px;border-radius: 5px;'{{/inline_css}}>
11
12
 
13
+ <span class="status_tag {{pull_status_class}}" {{#inline_css}}style="background:{{pull_status_bgcolor}};color:#fff;display:inline-block;border-radius:3px;padding:1px 4px;font-weight:bold;margin-bottom:5px;"{{/inline_css}}> {{pull_status_str}} </span>
12
14
 
13
- <div class='github-commit-status' style='margin-bottom:3px;'>
14
- {{#pull_status_str_open}}
15
- <span style='background:#6cc644;color:#fff;display:inline-block;border-radius:3px;padding:2px;'>
16
- {{/pull_status_str_open}}
17
- {{#pull_status_closed_accepted}}
18
- <span style='background:#6e5494;color:#fff;display:inline-block;border-radius:3px;padding:2px;'>
19
- {{/pull_status_closed_accepted}}
20
- {{#pull_status_closed_declined}}
21
- <span style='background:#bd2c00;color:#fff;display:inline-block;border-radius:3px;padding:2px;'>
22
- {{/pull_status_closed_declined}}
23
15
 
24
- {{pull_status_str}} </span>
25
- </br>
26
16
 
27
- {{#build_status}}
28
- <span style='padding: 2px;background: #cfcfcf;'>{{build_status}}</span>
29
- {{/build_status}}
17
+
18
+ {{#build_status}}
19
+ <span class='build_status' {{#inline_css}}style='padding: 2px;font-size:12px'{{/inline_css}}>{{build_status}}</span>
20
+ {{/build_status}}
21
+
22
+ <div class="github-commit-stats">
23
+ <strong>{{commits}} commits</strong>
24
+ changed <strong>{{changed_files}} files</strong>
25
+ with <strong>{{additions}} additions</strong>
26
+ and <strong>{{deletions}} deletions</strong>.
27
+ </div>
30
28
  </div>
31
29
 
32
- <div class="date">
30
+ <div class="date github-content-right" {{#inline_css}}style='margin-left:100px;'{{/inline_css}}>
33
31
  by <a href="{{user.html_url}}" target="_blank">{{user.login}}</a>
34
32
  on <a href="{{html_url}}" target="_blank">{{created_at}}</a>
35
33
  </div>
36
34
 
37
- <div class="github-commit-stats">
38
- <strong>{{commits}} commits</strong>
39
- changed <strong>{{changed_files}} files</strong>
40
- with <strong>{{additions}} additions</strong>
41
- and <strong>{{deletions}} deletions</strong>.
42
- </div>
35
+ {{! // Sample Styling
36
+
37
+ .onebox-body .github-commit-status {
38
+ background: #F5F5F5;
39
+ border-radius: 5px;
40
+ margin:0px 0px 5px 100px;
41
+ padding: 10px;
42
+ }
43
+
44
+ .onebox-body .status_tag {
45
+ display:inline-block;
46
+ color:#fff;
47
+ padding:1px 4px;
48
+ border-radius:3px;
49
+ font-weight:bold;
50
+ margin-bottom:5px;
51
+ text-transform:capitalize;
52
+ }
53
+
54
+ .onebox-body .build_status
55
+ {
56
+ padding: 2px;
57
+ font-size:12px;
58
+ }
59
+
60
+ .onebox-body .status_tag.open {
61
+ background-color:#6cc644;
62
+ }
63
+ .onebox-body .status_tag.merged{
64
+ background-color:#6e5494;
65
+ }
66
+ .onebox-body .status_tag.closed {
67
+ background-color:#bd2c00;
68
+ }
69
+
70
+ .onebox-body .github-content-right{
71
+ margin-left:100px;
72
+ }
73
+ }}
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.5.1
4
+ version: 1.5.2
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: 2014-09-26 00:00:00.000000000 Z
13
+ date: 2014-10-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: multi_json
@@ -344,7 +344,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
344
344
  version: '0'
345
345
  requirements: []
346
346
  rubyforge_project:
347
- rubygems_version: 2.2.2
347
+ rubygems_version: 2.1.11
348
348
  signing_key:
349
349
  specification_version: 4
350
350
  summary: A gem for turning URLs into previews.