link_preview 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/link_preview/content.rb +6 -6
- data/lib/link_preview/parser.rb +1 -0
- data/lib/link_preview/version.rb +1 -1
- data/spec/files/requests/thinglink_html5_embed.yml +6874 -0
- data/spec/link_preview_spec.rb +81 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b662c55f80ea8cfd8930b9330661fd479a06977
|
4
|
+
data.tar.gz: 64e9c6bbc68fcfc113471da67c06c3b22469566c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f82922a2ff9eeeb750a77dca1c650ba3e4700f286feb943dc4e2e612fdf39d7d4ef1664a9736700dba99b6be01c8d5c053a999d67cb10787e25dfe0032f970b5
|
7
|
+
data.tar.gz: 206b5c6e0f387a43e69605c118e71772a0e7ae52eac1946e5db5a6e3926b56da1dd54605aea22e6279087546e81d0b41ab1b3dc5e726504d6451da03896a2608
|
data/lib/link_preview/content.rb
CHANGED
@@ -238,11 +238,11 @@ module LinkPreview
|
|
238
238
|
def property_source_priority(property)
|
239
239
|
case property
|
240
240
|
when :description
|
241
|
-
[:html, :oembed, :default]
|
241
|
+
[:html, :oembed, :opengraph_oembed, :opengraph, :default]
|
242
242
|
when :image_data, :image_content_type, :image_file_name
|
243
|
-
[:image, :oembed, :default]
|
243
|
+
[:image, :oembed, :opengraph_oembed, :opengraph, :default]
|
244
244
|
else
|
245
|
-
[:oembed, :html, :image, :default]
|
245
|
+
[:oembed, :opengraph_oembed, :opengraph, :html, :image, :default]
|
246
246
|
end
|
247
247
|
end
|
248
248
|
|
@@ -288,6 +288,7 @@ module LinkPreview
|
|
288
288
|
version: '1.0',
|
289
289
|
provider_name: site_name,
|
290
290
|
provider_url: site_url,
|
291
|
+
url: url,
|
291
292
|
title: title,
|
292
293
|
description: description,
|
293
294
|
type: 'link',
|
@@ -303,7 +304,7 @@ module LinkPreview
|
|
303
304
|
end
|
304
305
|
|
305
306
|
def content_type_video?
|
306
|
-
content_type =~ %r{\Avideo/.*}
|
307
|
+
content_type =~ %r{\Avideo/.*} ? true : false
|
307
308
|
end
|
308
309
|
|
309
310
|
def content_type_flash?
|
@@ -311,11 +312,10 @@ module LinkPreview
|
|
311
312
|
end
|
312
313
|
|
313
314
|
def content_type_embed?
|
314
|
-
get_property(:html)
|
315
|
+
get_property(:html) ? true : false
|
315
316
|
end
|
316
317
|
|
317
318
|
def content_html
|
318
|
-
return unless content_url.present?
|
319
319
|
return content_html_embed if content_type_embed?
|
320
320
|
return content_html_video if content_type_video?
|
321
321
|
return content_html_flash if content_type_flash?
|
data/lib/link_preview/parser.rb
CHANGED
@@ -118,6 +118,7 @@ module LinkPreview
|
|
118
118
|
|
119
119
|
def parse_opengraph_video_data(doc)
|
120
120
|
opengraph_video_array_first_elem = find_meta_property_array(doc, 'og:video').detect { |x| x['og:video:type'] != 'text/html' }
|
121
|
+
return {} unless opengraph_video_array_first_elem
|
121
122
|
parse_opengraph_common_data(doc).merge(
|
122
123
|
video_url: opengraph_video_array_first_elem['og:video'] || opengraph_video_array_first_elem['og:video:url'],
|
123
124
|
video_secure_url: opengraph_video_array_first_elem['og:video:secure_url'],
|
data/lib/link_preview/version.rb
CHANGED