jekyll-indico 0.4.1 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/Gemfile.lock +1 -1
- data/README.md +3 -3
- data/lib/jekyll-indico/core.rb +11 -20
- data/lib/jekyll-indico/generator.rb +10 -8
- data/lib/jekyll-indico/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91bed0b6b864fa3f7a1b8dee140c9f9eb791823b
|
4
|
+
data.tar.gz: 6519f4dd2b0681d3961ce636733701342eed4a7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f5064ba79a8af25de947a654f5718e70b48a19533f05afa1cb6739ffd07a9c6c25d4296def57d50b00a5f34e57467629ad048b5d6ed6858d6fbb8811dca7d79
|
7
|
+
data.tar.gz: 260ecb6e6b9b1801928d0f6eeb204e71217db6f3e6d5fd77128fe750128b976d5401725556054c939cad347f2aebb7071540b35ac4dd08931584d121f35831c1
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
# Version 0.4.5
|
2
|
+
|
3
|
+
Fix timeout being incorrectly called again.
|
4
|
+
|
5
|
+
# Version 0.4.4
|
6
|
+
|
7
|
+
Fix timeout being incorrectly called.
|
8
|
+
|
9
|
+
# Version 0.4.3
|
10
|
+
|
11
|
+
Fix warning message for classic tokens. Add time printout to help judge need for
|
12
|
+
timeout setting.
|
13
|
+
|
14
|
+
# Version 0.4.2
|
15
|
+
|
16
|
+
Remove broken support for classic tokens. Modern `INDICO_TOKEN` required.
|
17
|
+
|
1
18
|
# Version 0.4.1
|
2
19
|
|
3
20
|
Fix a few issues in Jekyll generator.
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -20,9 +20,9 @@ indico:
|
|
20
20
|
```
|
21
21
|
|
22
22
|
This plugin will automatically use an API token if your environment contains
|
23
|
-
`INDICO_TOKEN`.
|
24
|
-
|
25
|
-
|
23
|
+
`INDICO_TOKEN`. You should generate this and replace `INDICO_API_KEY` and
|
24
|
+
`INDICO_SECRET_KEY` with it. You'll want the "Classic API" read permissions set
|
25
|
+
on it.
|
26
26
|
|
27
27
|
#### Usage: installing
|
28
28
|
|
data/lib/jekyll-indico/core.rb
CHANGED
@@ -63,36 +63,27 @@ module JekyllIndico
|
|
63
63
|
private
|
64
64
|
|
65
65
|
# Run a block over each item in the downloaded results
|
66
|
-
def download_and_iterate(base_url, indico_id, **
|
66
|
+
def download_and_iterate(base_url, indico_id, timeout: nil, **params, &block)
|
67
|
+
params[:pretty] = 'no'
|
67
68
|
uri = URI.join(base_url, "/export/categ/#{indico_id}.json")
|
68
|
-
params = build_params(**kargs)
|
69
69
|
uri.query = URI.encode_www_form(params)
|
70
70
|
|
71
71
|
req = Net::HTTP::Get.new(uri)
|
72
|
-
|
72
|
+
if ENV['INDICO_TOKEN']
|
73
|
+
req['Authorization'] = "Bearer #{ENV['INDICO_TOKEN']}"
|
74
|
+
elsif ENV['INDICO_SECRET_KEY'] || ENV['INDICO_API_KEY']
|
75
|
+
raise Error, 'Use INDICO_TOKEN with a new-style token'
|
76
|
+
end
|
77
|
+
|
78
|
+
opts = { use_ssl: true }
|
79
|
+
opts[:read_timeout] = timeout if timeout
|
73
80
|
|
74
|
-
response = Net::HTTP.start(uri.hostname, uri.port,
|
81
|
+
response = Net::HTTP.start(uri.hostname, uri.port, **opts) { |http| http.request(req) }
|
75
82
|
|
76
83
|
string = response.body
|
77
84
|
parsed = JSON.parse(string) # returns a hash
|
78
85
|
|
79
86
|
parsed['results'].each(&block)
|
80
87
|
end
|
81
|
-
|
82
|
-
# Automatically signs request if environment has INDICO_API/SECRET_KEY
|
83
|
-
def build_params(**kargs)
|
84
|
-
kargs[:pretty] = 'no'
|
85
|
-
|
86
|
-
if ENV['INDICO_API_KEY'] && !ENV['INDICO_TOKEN']
|
87
|
-
kargs[:ak] = ENV['INDICO_API_KEY']
|
88
|
-
if ENV['INDICO_SECRET_KEY']
|
89
|
-
kargs[:timestamp] = Time.new.to_i.to_s
|
90
|
-
requeststr = join_url(indico_id, kargs)
|
91
|
-
kargs[:signature] = OpenSSL::HMAC.hexdigest('SHA1', ENV['INDICO_SECRET_KEY'], requeststr)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
kargs
|
96
|
-
end
|
97
88
|
end
|
98
89
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'benchmark'
|
4
|
+
require 'net/http'
|
3
5
|
require 'yaml'
|
4
6
|
|
5
7
|
require 'jekyll'
|
6
8
|
|
7
9
|
require 'jekyll-indico/core'
|
8
10
|
|
9
|
-
require 'net/http'
|
10
|
-
|
11
11
|
module JekyllIndico
|
12
12
|
# This is a Jekyll Generator
|
13
13
|
class GetIndico < Jekyll::Generator
|
@@ -16,9 +16,6 @@ module JekyllIndico
|
|
16
16
|
@site = site
|
17
17
|
@cache_msg = @site.config.dig('indico', 'cache-command')
|
18
18
|
|
19
|
-
timeout = @site.config.dig('indico', 'timeout')
|
20
|
-
Net::HTTP.read_timeout = timeout if timeout
|
21
|
-
|
22
19
|
meeting_ids = @site.config.dig('indico', 'ids')
|
23
20
|
raise MissingIDs, 'indico: ids: MISSING from your config!' unless meeting_ids
|
24
21
|
raise MissingIDs, 'indico: ids: must be a hash!' unless meeting_ids.is_a?(Hash)
|
@@ -37,13 +34,18 @@ module JekyllIndico
|
|
37
34
|
data_path = @site.config.dig('indico', 'data') || 'indico'
|
38
35
|
@site.data[data_path] = {} unless @site.data.key? data_path
|
39
36
|
|
37
|
+
timeout = @site.config.dig('indico', 'timeout')
|
38
|
+
|
40
39
|
# Do nothing if already downloaded
|
41
40
|
return if @site.data[data_path].key? name
|
42
41
|
|
43
42
|
msg = @cache_msg ? " - run `#{@cache_msg}` to cache" : ''
|
44
|
-
|
45
|
-
|
46
|
-
|
43
|
+
print "Accessing Indico meeting API for #{name}:#{number}#{msg}"
|
44
|
+
time = Benchmark.realtime do
|
45
|
+
iris_meeting = Meetings.new(base_url, number, timeout: timeout)
|
46
|
+
@site.data[data_path][name] = iris_meeting.dict
|
47
|
+
end
|
48
|
+
puts ", took #{time.round(1)} s"
|
47
49
|
end
|
48
50
|
end
|
49
51
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-indico
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henry Schreiner
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-02-
|
11
|
+
date: 2022-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|