onebox 1.5.6 → 1.5.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
  SHA1:
3
- metadata.gz: ff1798c506e288427056ead18fd48f2988050be3
4
- data.tar.gz: ba7f2a9b90eca120f7e02823dd82478efd82b23d
3
+ metadata.gz: 7f68792a4551ae1d514bc6bdbd07607ead5ebb5a
4
+ data.tar.gz: e464aae6ea273ce32edcc3321c5b589e61162468
5
5
  SHA512:
6
- metadata.gz: 5cefe833b7afd031180985fec397fa7f42704c5c2a8e456260d756805bb4741db9b3a8496556d1a841009b9eda5445c243487f9b30acbe7cff89e2beba06d69b
7
- data.tar.gz: d22d9b5ed23f70cde5d8e3bdf8e272c9c5aafb6d4dc989e3db604f8d9b1ed9f010803aa01a00600cd885724056201e8b9f5b517065467960a5e72918dc26ca20
6
+ metadata.gz: 81677af638f4db63c2fac2b5489fee88f3fd50924908b2294a3eca02e1013d85281a22712e84d16588a8ef41f45328f19fa5425b7f55c4ec9f4f4cd22bf3677a
7
+ data.tar.gz: 514e05a5956aa021d98cc713c2f84df2a3bc6c916c82d93f167194c9c7f8d933d0d5e3bbd336a6baef1c0d5e8653a899b0107d8af5086adc607f8df98ea91040
@@ -141,3 +141,4 @@ require_relative "engine/youku_onebox"
141
141
  require_relative "engine/douban_onebox"
142
142
  require_relative "engine/whitelisted_generic_onebox"
143
143
  require_relative "engine/pubmed_onebox"
144
+ require_relative "engine/google_calendar_onebox"
@@ -8,7 +8,7 @@ module Onebox
8
8
  matches_regexp Regexp.new("^http(?:s)?:\/\/(?:www\.)?(?:(?:\w)+\.)?github\.com\/(?<org>.+)\/(?<repo>.+)\/issues\/([[:digit:]]+)")
9
9
 
10
10
  def url
11
- m = match
11
+ m = match
12
12
  "https://api.github.com/repos/#{m["org"]}/#{m["repo"]}/issues/#{m["item_id"]}"
13
13
  end
14
14
 
@@ -19,11 +19,11 @@ module Onebox
19
19
  end
20
20
 
21
21
  def data
22
-
22
+
23
23
  @raw ||= ::MultiJson.load(open(url,"Accept"=>"application/vnd.github.v3.text+json",:read_timeout=>timeout )) #custom Accept header so we can get body as text.
24
24
  body_text= @raw["body_text"]
25
-
26
-
25
+
26
+
27
27
  content_words = body_text.gsub("\n\n","\n").gsub("\n","<br>").split(" ") #one pass of removing double newline, then we change \n to <br> and later on we revert it back to \n this is a workaround to avoid losing newlines after we join it back.
28
28
  max_words = 20
29
29
  short_content = content_words[0..max_words].join(" ")
@@ -35,8 +35,6 @@ module Onebox
35
35
  content:short_content.gsub("<br>","\n"),
36
36
  labels: @raw["labels"],
37
37
  user: @raw['user'],
38
- status: @raw['state'],
39
- status_color: status_color[@raw['state']] || "#cfcfcf",
40
38
  created_at: @raw['created_at'].split("T")[0], #get only date for now
41
39
  closed_at: (@raw['closed_at'].nil? ? "" : @raw['closed_at'].split("T")[0] ) ,
42
40
  closed_by: @raw['closed_by'],
@@ -0,0 +1,15 @@
1
+ module Onebox
2
+ module Engine
3
+ class GoogleCalendarOnebox
4
+ include Engine
5
+
6
+ matches_regexp /^(https?:)?\/\/(www\.google\.[\w.]{2,}|goo\.gl)\/calendar\/.+$/
7
+
8
+ def to_html
9
+ url = @url.split('&').first
10
+ "<iframe src='#{url}&rm=minimal' style='border: 0' width='800' height='600' frameborder='0' scrolling='no' ></iframe>"
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -16,6 +16,7 @@ module Onebox
16
16
  def self.default_whitelist
17
17
  %w(23hq.com
18
18
  500px.com
19
+ 8tracks.com
19
20
  about.com
20
21
  answers.com
21
22
  ask.com
@@ -32,7 +33,6 @@ module Onebox
32
33
  cnn.com
33
34
  collegehumor.com
34
35
  coursera.org
35
- codepen.io
36
36
  cracked.com
37
37
  dailymail.co.uk
38
38
  dailymotion.com
@@ -243,25 +243,25 @@ module Onebox
243
243
 
244
244
 
245
245
  if video_url
246
- # opengraph support multiple elements (videos, images ,etc).
246
+ # opengraph support multiple elements (videos, images ,etc).
247
247
  # We attempt to find a video element with the type of video/mp4
248
248
  # and generate a native <video> element for it.
249
249
 
250
250
  if (@raw.metadata && @raw.metadata[:"video:type"])
251
251
  video_type = @raw.metadata[:"video:type"]
252
- if video_type.include? "video/mp4" #find if there is a video with type
253
- if video_type.size > 1 #if more then one video item based on provided video_type
254
- ind = video_type.find_index("video/mp4") #get the first video index with type video/mp4
255
- video_url = @raw.metadata[:video][ind] #update video_url
256
- end
257
-
258
- attr = append_attribute(:width, attr, video)
252
+ if video_type.include? "video/mp4" # find if there is a video with type
253
+ if video_type.size > 1 # if more then one video item based on provided video_type
254
+ ind = video_type.find_index("video/mp4") # get the first video index with type video/mp4
255
+ video_url = @raw.metadata[:video][ind] # update video_url
256
+ end
257
+
258
+ attr = append_attribute(:width, attr, video)
259
259
  attr = append_attribute(:height, attr, video)
260
-
260
+
261
261
  # html_v1 = %Q(<video #{attr} title="#{data[:title]}" controls="" ><source src="#{video_url}"></video>)
262
262
 
263
263
  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) )
264
-
264
+
265
265
  orig_url = @raw.url
266
266
  html_v2 = %Q(
267
267
  <div style='position:relative;padding-top:29px;'>
@@ -271,7 +271,7 @@ module Onebox
271
271
  )
272
272
  html = html_v2
273
273
 
274
- else
274
+ else
275
275
 
276
276
  html = "<iframe src=\"#{video_url}\" frameborder=\"0\" title=\"#{data[:title]}\""
277
277
  append_attribute(:width, html, video)
@@ -293,4 +293,4 @@ module Onebox
293
293
  end
294
294
  end
295
295
  end
296
- end
296
+ end
@@ -1,3 +1,3 @@
1
1
  module Onebox
2
- VERSION = "1.5.6"
2
+ VERSION = "1.5.7"
3
3
  end
@@ -5,16 +5,13 @@
5
5
  <h4><a href="{{link}}" target="_blank">{{title}}</a></h4>
6
6
 
7
7
  <div class="date" style="margin-top:10px;">
8
- <div class="status">
9
- <span style="background-color: {{status_color}};padding: 2px;border-radius: 4px;color: #fff;">{{status}}</span>
10
- </div>
11
8
  <div class="user" style="margin-top:10px;">
12
- opened by <a href="{{user.html_url}}" target="_blank">{{user.login}}</a>
9
+ opened by <a href="{{user.html_url}}" target="_blank">{{user.login}}</a>
13
10
  on <a href="{{link}}" target="_blank">{{created_at}}</a>
14
11
  </div>
15
12
  <div class="user">
16
13
  {{#closed_by}}
17
- closed by <a href="{{html_url}}" target="_blank">{{login}}</a>
14
+ closed by <a href="{{html_url}}" target="_blank">{{login}}</a>
18
15
  on <a href="{{link}}" target="_blank">{{closed_at}}</a>
19
16
  {{/closed_by}}
20
17
  </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.5.6
4
+ version: 1.5.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: 2014-12-29 00:00:00.000000000 Z
13
+ date: 2015-01-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: multi_json
@@ -252,6 +252,7 @@ files:
252
252
  - lib/onebox/engine/github_gist_onebox.rb
253
253
  - lib/onebox/engine/github_issue_onebox.rb
254
254
  - lib/onebox/engine/github_pullrequest_onebox.rb
255
+ - lib/onebox/engine/google_calendar_onebox.rb
255
256
  - lib/onebox/engine/google_play_app_onebox.rb
256
257
  - lib/onebox/engine/html.rb
257
258
  - lib/onebox/engine/image_onebox.rb