linkser 0.0.9 → 0.0.10
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.
- data/lib/linkser/objects/html.rb +4 -4
- data/lib/linkser/version.rb +1 -1
- metadata +4 -4
data/lib/linkser/objects/html.rb
CHANGED
@@ -24,7 +24,7 @@ module Linkser
|
|
24
24
|
if ogp and ogp.image
|
25
25
|
begin
|
26
26
|
img_spec = ImageSpec.new(ogp.image)
|
27
|
-
if valid_img?
|
27
|
+
if valid_img?(img_spec.width.to_f, img_spec.height.to_f) and can_hotlink_img?(ogp.image)
|
28
28
|
images << Linkser::Resource.new({:type => "image", :url => ogp.image, :width => img_spec.width, :height => img_spec.height})
|
29
29
|
end
|
30
30
|
rescue
|
@@ -42,7 +42,7 @@ module Linkser
|
|
42
42
|
if [".jpg", ".jpeg", ".png"].include? img_ext
|
43
43
|
begin
|
44
44
|
img_spec = ImageSpec.new(img_src)
|
45
|
-
if valid_img?
|
45
|
+
if valid_img?(img_spec.width.to_f, img_spec.height.to_f) and can_hotlink_img?(img_src)
|
46
46
|
images << Linkser::Resource.new({:type => "image", :url => img_src, :width => img_spec.width, :height => img_spec.height})
|
47
47
|
end
|
48
48
|
rescue
|
@@ -100,11 +100,11 @@ module Linkser
|
|
100
100
|
end
|
101
101
|
|
102
102
|
def can_hotlink_img? url, limit=10
|
103
|
+
return false if limit < 0
|
103
104
|
uri = URI.parse(url)
|
104
105
|
http = Net::HTTP.new uri.host, uri.port
|
105
106
|
http.start do |agent|
|
106
|
-
agent.
|
107
|
-
response = agent.head uri.request_uri
|
107
|
+
response = agent.head uri.request_uri, { 'Referrer' => 'http://www.linkser.com/' }
|
108
108
|
case response
|
109
109
|
when Net::HTTPSuccess then
|
110
110
|
return true
|
data/lib/linkser/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: linkser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 10
|
10
|
+
version: 0.0.10
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Eduardo Casanova
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2012-01-02 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rake
|