link_thumbnailer 1.0.7 → 1.0.8

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/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 1.0.8
2
+
3
+ - Thanks to [juriglx](https://github.com/juriglx), support for canonical urls
4
+ - Bug fixes
5
+
1
6
  # 1.0.7
2
7
 
3
8
  - Fix: Issue with preview controller
data/README.md CHANGED
@@ -143,7 +143,7 @@ In `config/initializers/link_thumbnailer.rb`
143
143
 
144
144
  # Enable or disable SSL verification
145
145
  # config.verify_ssl = true
146
-
146
+
147
147
  # HTTP open_timeout: The amount of time in seconds to wait for a connection to be opened.
148
148
  # config.http_timeout = 5
149
149
  end
@@ -175,3 +175,4 @@ Coming soon:
175
175
  ## Contributors
176
176
 
177
177
  - [phlegx](https://github.com/phlegx)
178
+ - [juriglx](https://github.com/juriglx)
@@ -38,7 +38,7 @@ module LinkThumbnailer
38
38
  end
39
39
 
40
40
  def description
41
- if element = xpath('//meta[@name="description" and @content]').first
41
+ if element = xpath("//meta[translate(@name,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz') = 'description' and @content]").first
42
42
  return element.attributes['content'].value.strip
43
43
  end
44
44
 
@@ -51,6 +51,13 @@ module LinkThumbnailer
51
51
  nil
52
52
  end
53
53
 
54
+ def canonical_url
55
+ if element = xpath("//link[translate(@rel, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz') = 'canonical' and @href]").first
56
+ return element.attributes['href'].value.strip
57
+ end
58
+ nil
59
+ end
60
+
54
61
  attr_accessor :source_url
55
62
 
56
63
  end
@@ -1,3 +1,3 @@
1
1
  module LinkThumbnailer
2
- VERSION = "1.0.7"
2
+ VERSION = "1.0.8"
3
3
  end
@@ -82,6 +82,7 @@ module LinkThumbnailer
82
82
  self.object[:title] = doc.title
83
83
  self.object[:description] = doc.description
84
84
  self.object[:images] = self.img_parser.parse(doc.img_abs_urls.dup)
85
+ self.object[:url] = doc.canonical_url || self.object[:url]
85
86
  return self.object if self.object.valid?
86
87
  nil
87
88
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: link_thumbnailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-04 00:00:00.000000000 Z
12
+ date: 2013-05-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -191,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
191
  version: '0'
192
192
  requirements: []
193
193
  rubyforge_project:
194
- rubygems_version: 1.8.24
194
+ rubygems_version: 1.8.25
195
195
  signing_key:
196
196
  specification_version: 3
197
197
  summary: Ruby gem ranking images from a given URL returning an object containing images