jekyll-url-metadata 1.0.0 → 1.0.1
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 +4 -4
- data/lib/jekyll-url-metadata/main.rb +34 -1
- data/lib/jekyll-url-metadata/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: a3048e805f8d9c5aebcec7168ade03463791061b48eca4819656d9954b3a08e5
|
4
|
+
data.tar.gz: a62831160686205005734c3c4ded035627fda472f316778e9065f414c28f15c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8591ced4c0ba81dd04a28f84a45b2f1342b5117f020b3591d88ed98b471261d4ba77e1df7e31d9d97b8d3cb4aa4b24a397ec12eceebfa2ffacdf0673dcdd505a
|
7
|
+
data.tar.gz: e4102af544b8d0ad4a83b58ab641563e83b658639d9fbe85bc2a185449d3b5409f09bca434ab95ec88d37a77c5f325510e6d81e8e85ca00d9979edce6900b126
|
@@ -4,6 +4,15 @@ require "nokogiri"
|
|
4
4
|
module Jekyll
|
5
5
|
module URLMetadata
|
6
6
|
|
7
|
+
def url_config
|
8
|
+
@@url_config ||= @context.registers[:site].config['url_metadata'].nil? ? {} :
|
9
|
+
@context.registers[:site].config['url_metadata']
|
10
|
+
end
|
11
|
+
|
12
|
+
def cache
|
13
|
+
@@cache ||= Jekyll::Cache.new("Jekyll::URLMetadata")
|
14
|
+
end
|
15
|
+
|
7
16
|
def metadata(input)
|
8
17
|
if !input.is_a?(String)
|
9
18
|
log("Expected input type \"String\". Got \"#{input.class}\".")
|
@@ -15,10 +24,34 @@ module Jekyll
|
|
15
24
|
return
|
16
25
|
end
|
17
26
|
|
27
|
+
if !url_config["open_timeout"].nil? && !url_config["open_timeout"].is_a?(Integer)
|
28
|
+
log("Expected an \"Integer\" value for config \"open_timeout\". Got #{url_config["open_timeout"]}.")
|
29
|
+
|
30
|
+
return
|
31
|
+
end
|
32
|
+
|
33
|
+
if !url_config["read_timeout"].nil? && !url_config["read_timeout"].is_a?(Integer)
|
34
|
+
log("Expected an \"Integer\" value for config \"read_timeout\". Got #{url_config["read_timeout"]}.")
|
35
|
+
|
36
|
+
return
|
37
|
+
end
|
38
|
+
|
39
|
+
# The getset() API implements a cache first strategy
|
40
|
+
cache.getset(input) do
|
41
|
+
generate_hashmap(input)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def generate_hashmap(input)
|
18
46
|
# parse HTML from URL
|
19
|
-
doc = Nokogiri::HTML(URI.open(input
|
47
|
+
doc = Nokogiri::HTML(URI.open(input, {
|
48
|
+
:open_timeout => url_config["open_timeout"].nil? ? 1 : url_config["open_timeout"],
|
49
|
+
:read_timeout => url_config["read_timeout"].nil? ? 1 : url_config["read_timeout"]
|
50
|
+
}))
|
51
|
+
|
20
52
|
if !doc
|
21
53
|
log("Failed to parse HTML from #{input}. Please double check for URL validity.")
|
54
|
+
return
|
22
55
|
end
|
23
56
|
|
24
57
|
hash = Hash.new
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-url-metadata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gourav Khunger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|