curation 1.2 → 1.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 21a638c75deffb70db8694ecb99d94b1b711fba922ecbd0826d3a69597031df6
4
- data.tar.gz: 621519940fe6bc44302201f64211eba932d52ed366ebe0c6f11c02688b5ae0ba
3
+ metadata.gz: 2127e0e8cd5eecb8611891be3ba3ddf434dab8e1c172eb2b4f2aaffa7ffa21e4
4
+ data.tar.gz: d0b84333c2e85798b4ac9d809d5e7a49b1fab0f9d2de2a88109ca9305ffbb2e6
5
5
  SHA512:
6
- metadata.gz: bf5f63d05793d71ac052b94dcaf5f4e34943355799e042361ae704ca9423b501ab3e157ae8b6509da642e6fa680768205030a24ddc1eb4e24c31863284289575
7
- data.tar.gz: d09140b59ba119e85e9c955a40586bd1ce6410fe392a59b5e4a92e2a1ae80b4608fd458c0b84b24be8ba31267bcee9550432264e6ca4068be47b90db46228ed1
6
+ metadata.gz: b99857abd7cf08f321140261c00c613324209a2af09b668bc994a3a52704b2eef67d1986d6950a6347af5a093ef5e6174a5ddb486d7e6fe432de7402a33c01ab
7
+ data.tar.gz: 9dd921943b36746d21b55943ddb9105a6d20043a3de284d14da98bb0d5a97dce84f99649d2329f038393ae1b1c0c7d1e72f5a915f109955538c6d222e3388c9e
@@ -25,13 +25,7 @@ module Curation
25
25
  end
26
26
 
27
27
  def title
28
- if json_ld.any?
29
- json_ld.each do |ld|
30
- return ld['headline'] if ld.has_key? 'headline'
31
- end
32
- end
33
- metainspector.best_title unless metainspector.best_title.blank?
34
- metainspector.title
28
+ @title = find_title
35
29
  end
36
30
 
37
31
  def image
@@ -61,18 +55,45 @@ module Curation
61
55
 
62
56
  protected
63
57
 
58
+ def find_title
59
+ if json_ld.any?
60
+ json_ld.each do |ld|
61
+ return ld['headline'] if ld.has_key? 'headline'
62
+ end
63
+ end
64
+ [
65
+ metainspector.best_title,
66
+ metainspector.title,
67
+ nokogiri.css('[itemprop="headline"]').first.inner_text,
68
+ nokogiri.css('title').first.inner_text
69
+ ].each do |possibility|
70
+ return possibility unless possibility.blank?
71
+ end
72
+ return ''
73
+ end
74
+
64
75
  def find_image
65
76
  if json_ld.any?
66
77
  json_ld.each do |ld|
67
78
  if ld.has_key? 'image'
68
79
  image_data = ld['image']
69
80
  return image_data if image_data.is_a? String
70
- return image_data.first if image_data.is_a? Array
81
+ if image_data.is_a? Array
82
+ first = image_data.first
83
+ return first if first.is_a? String
84
+ return first['url'] if first.is_a? Hash
85
+ end
71
86
  return image_data['url'] if image_data.is_a? Hash
72
87
  end
73
88
  end
74
89
  end
75
- metainspector.images.best
90
+ [
91
+ metainspector.images.best,
92
+ nokogiri.css('[property="og:image"]').first&.attributes["content"].value
93
+ ].each do |possibility|
94
+ return possibility unless possibility.blank?
95
+ end
96
+ return ''
76
97
  end
77
98
 
78
99
  def json_ld
@@ -1,3 +1,3 @@
1
1
  module Curation
2
- VERSION = "1.2"
2
+ VERSION = "1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: curation
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.2'
4
+ version: '1.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arnaud Levy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-20 00:00:00.000000000 Z
11
+ date: 2020-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metainspector