onebox 1.3.8 → 1.3.9

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: 3386135fe238f1228c6b420da7c007f37b240144
4
- data.tar.gz: 234fa7e682c6d57c4091711165eb3d050eea3e8d
3
+ metadata.gz: a7e63f64363e58311aad66504fd91ba7940eb2b3
4
+ data.tar.gz: 18d611e2867fd927ffb4835d30845886ae938411
5
5
  SHA512:
6
- metadata.gz: 4998b0699bdc9b3d95b32b6fe25a15cc4ff44cb64c3e8140fbd6c5bb9d711a65be7716b40dfc80f77f2c7d380d3a4bd0fb21ea52d90a388499f6bf978d999704
7
- data.tar.gz: 46e1dadcbd1f02a55d8f5a1af4ae26870c476aa57f4d06bca57e690ce2de5115043303987d9334ffccfc5f408e8bb9ba69c21a9496226156e63c370bac060489
6
+ metadata.gz: 5140e35dcaefd82ae6a685ae9683095fbb5f4b674c03a4fa4d9c654c9cbe16dd68e9eab4848f0c293d6968c0f5626c20dad83fe6208071d96cde6cf946723186
7
+ data.tar.gz: 3755590cec94084263a1a542d094d4fe60e980c3a4b78058edaf0c2d6fdd1cca5ce64b93acb181e0f948624f8188bd19a4a7c1eeb6b8faa777eeea4ff357ab35
data/README.md CHANGED
@@ -3,8 +3,8 @@ onebox
3
3
 
4
4
  - [![Gem Version](https://badge.fury.io/rb/onebox.png)](https://rubygems.org/gems/onebox)
5
5
  - [![Code Climate](https://codeclimate.com/github/dysania/onebox.png)](https://codeclimate.com/github/dysania/onebox)
6
- - [![Build Status](https://travis-ci.org/dysania/onebox.png)](https://travis-ci.org/dysania/onebox)
7
- - [![Dependency Status](https://gemnasium.com/dysania/onebox.png)](https://gemnasium.com/dysania/onebox)
6
+ - [![Build Status](https://travis-ci.org/discourse/onebox.png)](https://travis-ci.org/discourse/onebox)
7
+ - [![Dependency Status](https://gemnasium.com/discourse/onebox.png)](https://gemnasium.com/discourse/onebox)
8
8
 
9
9
 
10
10
  Onebox is a library for turning media URLs into simple HTML previews of the resource.
data/lib/onebox.rb CHANGED
@@ -2,8 +2,6 @@ require "open-uri"
2
2
  require "multi_json"
3
3
  require "nokogiri"
4
4
  require "mustache"
5
- require "hexpress"
6
- require "hexpress/web"
7
5
  require "ostruct"
8
6
  require "moneta"
9
7
  require "cgi"
data/lib/onebox/engine.rb CHANGED
@@ -81,10 +81,6 @@ module Onebox
81
81
  100
82
82
  end
83
83
 
84
- def matches(&block)
85
- matches_regexp(Hexpress.new(&block).to_r)
86
- end
87
-
88
84
  def matches_regexp(r)
89
85
  class_variable_set :@@matcher, r
90
86
  end
@@ -5,14 +5,7 @@ module Onebox
5
5
  include LayoutSupport
6
6
  include JSON
7
7
 
8
- matches do
9
- http
10
- maybe("www.")
11
- domain("github")
12
- tld("com")
13
- anything
14
- with("/commit/")
15
- end
8
+ matches_regexp Regexp.new("^http(?:s)?://(?:www\.)?(?:(?:\w)+\.)?(github)\.com(?:/)?(?:.)*/commit/")
16
9
 
17
10
  def url
18
11
  "https://api.github.com/repos/#{match[:owner]}/#{match[:repository]}/commits/#{match[:sha]}"
@@ -5,12 +5,7 @@ module Onebox
5
5
  class GithubGistOnebox
6
6
  include Engine
7
7
 
8
- matches do
9
- http
10
- with("gist.")
11
- domain("github")
12
- tld("com")
13
- end
8
+ matches_regexp Regexp.new("^http(?:s)?://gist\\.(?:(?:\\w)+\\.)?(github)\\.com(?:/)?")
14
9
 
15
10
  def url
16
11
  "https://api.github.com/gists/#{match[:sha]}"
@@ -5,14 +5,7 @@ module Onebox
5
5
  include LayoutSupport
6
6
  include JSON
7
7
 
8
- matches do
9
- http
10
- maybe("www.")
11
- domain("github")
12
- tld("com")
13
- anything
14
- with("/pull/")
15
- end
8
+ matches_regexp Regexp.new("^http(?:s)?://(?:www\\.)?(?:(?:\\w)+\\.)?(github)\\.com(?:/)?(?:.)*/pull/")
16
9
 
17
10
  def url
18
11
  "https://api.github.com/repos/#{match[:owner]}/#{match[:repository]}/pulls/#{match[:number]}"
@@ -5,13 +5,7 @@ module Onebox
5
5
  include LayoutSupport
6
6
  include HTML
7
7
 
8
- matches do
9
- http
10
- with("play.")
11
- domain("google")
12
- tld("com")
13
- with("/store/apps/")
14
- end
8
+ matches_regexp Regexp.new("^http(?:s)?://play\\.(?:(?:\\w)+\\.)?(google)\\.com(?:/)?/store/apps/")
15
9
 
16
10
  private
17
11
 
@@ -6,6 +6,11 @@ module Onebox
6
6
  matches_regexp /^(https?:)?\/\/.+\.(png|jpg|jpeg|gif|bmp|tif|tiff)(\?.*)?$/i
7
7
 
8
8
  def to_html
9
+ # Fix Dropbox image links
10
+ if /^https:\/\/www.dropbox.com\/s\//.match @url
11
+ @url.gsub!("https://www.dropbox.com","https://dl.dropboxusercontent.com")
12
+ end
13
+
9
14
  "<a href='#{@url}' target='_blank'><img src='#{@url}'></a>"
10
15
  end
11
16
  end
@@ -4,12 +4,7 @@ module Onebox
4
4
  include Engine
5
5
  include LayoutSupport
6
6
 
7
- matches do
8
- http
9
- domain("www.ncbi.nlm.nih")
10
- tld("gov")
11
- has("/pubmed/")
12
- end
7
+ matches_regexp Regexp.new("^http(?:s)?://(?:(?:\\w)+\\.)?(www.ncbi.nlm.nih)\\.gov(?:/)?/pubmed/")
13
8
 
14
9
  private
15
10
 
@@ -5,14 +5,7 @@ module Onebox
5
5
  include LayoutSupport
6
6
  include HTML
7
7
 
8
- matches do
9
- http
10
- maybe("www.")
11
- domain("twitter")
12
- tld("com")
13
- anything
14
- has("/status/")
15
- end
8
+ matches_regexp Regexp.new("^http(?:s)?://(?:www\\.)?(?:(?:\\w)+\\.)?(twitter)\\.com(?:/)?(?:.)*/status/")
16
9
 
17
10
  private
18
11
 
@@ -1,3 +1,3 @@
1
1
  module Onebox
2
- VERSION = "1.3.8"
2
+ VERSION = "1.3.9"
3
3
  end
data/onebox.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["holla@jzeta.com", "vyki.englert@gmail.com", "robin.ward@gmail.com"]
11
11
  spec.description = %q{A gem for turning URLs into previews.}
12
12
  spec.summary = spec.description
13
- spec.homepage = "https://github.com/dysania/onebox"
13
+ spec.homepage = "https://github.com/discourse/onebox"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
@@ -21,7 +21,6 @@ Gem::Specification.new do |spec|
21
21
  spec.add_runtime_dependency "multi_json", "~> 1.7"
22
22
  spec.add_runtime_dependency "mustache", "~> 0.99"
23
23
  spec.add_runtime_dependency "nokogiri", "~> 1.6.1"
24
- spec.add_runtime_dependency "hexpress", "~> 1.2"
25
24
  spec.add_runtime_dependency "moneta", "~> 0.7"
26
25
 
27
26
  spec.add_development_dependency "bundler", "~> 1.3"
@@ -66,21 +66,6 @@ describe Onebox::Engine do
66
66
  end
67
67
  end
68
68
 
69
- describe ".matches" do
70
- class OneboxEngineMatches
71
- include Onebox::Engine
72
-
73
- matches do
74
- find "foo.com"
75
- end
76
- end
77
-
78
- it "sets @@matcher to a regular expression" do
79
- regex = OneboxEngineMatches.class_variable_get(:@@matcher)
80
- expect(regex).to be_a(Regexp)
81
- end
82
- end
83
-
84
69
  end
85
70
 
86
71
  describe ".onebox_name" do
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.3.8
4
+ version: 1.3.9
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-06-11 00:00:00.000000000 Z
13
+ date: 2014-06-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: multi_json
@@ -54,20 +54,6 @@ dependencies:
54
54
  - - "~>"
55
55
  - !ruby/object:Gem::Version
56
56
  version: 1.6.1
57
- - !ruby/object:Gem::Dependency
58
- name: hexpress
59
- requirement: !ruby/object:Gem::Requirement
60
- requirements:
61
- - - "~>"
62
- - !ruby/object:Gem::Version
63
- version: '1.2'
64
- type: :runtime
65
- prerelease: false
66
- version_requirements: !ruby/object:Gem::Requirement
67
- requirements:
68
- - - "~>"
69
- - !ruby/object:Gem::Version
70
- version: '1.2'
71
57
  - !ruby/object:Gem::Dependency
72
58
  name: moneta
73
59
  requirement: !ruby/object:Gem::Requirement
@@ -335,7 +321,7 @@ files:
335
321
  - templates/twitterstatus.mustache
336
322
  - templates/whitelistedgeneric.mustache
337
323
  - templates/wikipedia.mustache
338
- homepage: https://github.com/dysania/onebox
324
+ homepage: https://github.com/discourse/onebox
339
325
  licenses:
340
326
  - MIT
341
327
  metadata: {}