curation 1.2 → 1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/curation.rb +30 -9
- data/lib/curation/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2127e0e8cd5eecb8611891be3ba3ddf434dab8e1c172eb2b4f2aaffa7ffa21e4
|
4
|
+
data.tar.gz: d0b84333c2e85798b4ac9d809d5e7a49b1fab0f9d2de2a88109ca9305ffbb2e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b99857abd7cf08f321140261c00c613324209a2af09b668bc994a3a52704b2eef67d1986d6950a6347af5a093ef5e6174a5ddb486d7e6fe432de7402a33c01ab
|
7
|
+
data.tar.gz: 9dd921943b36746d21b55943ddb9105a6d20043a3de284d14da98bb0d5a97dce84f99649d2329f038393ae1b1c0c7d1e72f5a915f109955538c6d222e3388c9e
|
data/lib/curation.rb
CHANGED
@@ -25,13 +25,7 @@ module Curation
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def title
|
28
|
-
|
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
|
-
|
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
|
-
|
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
|
data/lib/curation/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2020-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: metainspector
|