urifetch 0.1.1.rc4 → 0.1.1.rc5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/urifetch/strategy/base.rb +14 -14
- data/lib/urifetch/version.rb +1 -1
- data/urifetch.gemspec +1 -1
- metadata +2 -2
@@ -50,13 +50,23 @@ module Urifetch
|
|
50
50
|
set :url, uri.to_s.sub(/\/$/,"")
|
51
51
|
|
52
52
|
doc = Nokogiri::HTML.parse(@request,false)
|
53
|
+
|
54
|
+
# Image
|
55
|
+
image = doc.css('img').first
|
56
|
+
image = image.nil? ? nil : image['src'].try(:strip)
|
57
|
+
if image
|
58
|
+
if image.match(/^https?:\/\//i).nil?
|
59
|
+
image = uri.scheme + "://" + uri.host.sub(/\/$/,"") + "/" + image.sub(/^\//,"")
|
60
|
+
end
|
61
|
+
set :image, image
|
62
|
+
end
|
53
63
|
|
54
64
|
# Open Auth data
|
55
65
|
if og = OpenGraph.parse(doc)
|
56
|
-
set :url, og.url.to_s.sub(/\/$/,""),
|
57
|
-
set :title, og.title
|
58
|
-
set :image, og.image
|
59
|
-
set :description, og.description
|
66
|
+
set :url, og.url.to_s.sub(/\/$/,""), override: true
|
67
|
+
set :title, og.title, override: true
|
68
|
+
set :image, og.image, override: true
|
69
|
+
set :description, og.description, override: true
|
60
70
|
end
|
61
71
|
|
62
72
|
# Custom CSS data
|
@@ -74,16 +84,6 @@ module Urifetch
|
|
74
84
|
set :favicon, favicon
|
75
85
|
end
|
76
86
|
|
77
|
-
# Fallback Image
|
78
|
-
image = doc.css('img').first
|
79
|
-
image = image.nil? ? nil : image['src'].try(:strip)
|
80
|
-
if image
|
81
|
-
if image.match(/^https?:\/\//i).nil?
|
82
|
-
image = uri.scheme + "://" + uri.host.sub(/\/$/,"") + "/" + image.sub(/^\//,"")
|
83
|
-
end
|
84
|
-
set(:image, image) unless get(:image)
|
85
|
-
end
|
86
|
-
|
87
87
|
end
|
88
88
|
|
89
89
|
private
|
data/lib/urifetch/version.rb
CHANGED
data/urifetch.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: urifetch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.1.
|
4
|
+
version: 0.1.1.rc5
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -249,7 +249,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
249
249
|
version: '0'
|
250
250
|
segments:
|
251
251
|
- 0
|
252
|
-
hash:
|
252
|
+
hash: -1453431270534021920
|
253
253
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
254
254
|
none: false
|
255
255
|
requirements:
|