jekyll-indico 0.4.5 → 0.5.0
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/CHANGELOG.md +4 -0
- data/Gemfile.lock +3 -3
- data/README.md +2 -0
- data/lib/jekyll-indico/core.rb +26 -11
- data/lib/jekyll-indico/generator.rb +2 -1
- 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: 4e2a1ea8813f626061be2c5da553cafe9453aaac
|
4
|
+
data.tar.gz: '06758dd8b0908b58f065a13a5fc8f8990ff1ab0d'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f909dd6bffbd0f595c03daa73d2da3fc234a3ff9f72ccca3e35e532a962dada79dc5be4f978b3aa4e4c92edbb6248807d03be92e08658fb7d45c679576a4dc1
|
7
|
+
data.tar.gz: 246baf00d16729890482b79743ef9c625e6976c52bf8c336c91b66bfd039c6a6c3f1333f6984e393e8de366b391ce6be2b499b1ddd257a7b50161b42550967ad
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
jekyll-indico (0.
|
4
|
+
jekyll-indico (0.5.0)
|
5
5
|
jekyll (>= 3.8, < 5.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -54,12 +54,12 @@ GEM
|
|
54
54
|
public_suffix (4.0.6)
|
55
55
|
rainbow (3.1.1)
|
56
56
|
rake (13.0.6)
|
57
|
-
rb-fsevent (0.11.
|
57
|
+
rb-fsevent (0.11.1)
|
58
58
|
rb-inotify (0.10.1)
|
59
59
|
ffi (~> 1.0)
|
60
60
|
regexp_parser (2.2.0)
|
61
61
|
rexml (3.2.5)
|
62
|
-
rouge (3.
|
62
|
+
rouge (3.28.0)
|
63
63
|
rspec (3.10.0)
|
64
64
|
rspec-core (~> 3.10.0)
|
65
65
|
rspec-expectations (~> 3.10.0)
|
data/README.md
CHANGED
@@ -14,6 +14,8 @@ indico:
|
|
14
14
|
url: https://indico.cern.ch # Indico instance to use (REQUIRED)
|
15
15
|
data: indico # Optional, folder name in _data to use
|
16
16
|
cache-command: bundle exec rake cache # Optional, user msg if you support it
|
17
|
+
paginate: 20 # Optional integer number of results per page (auto-iterates over all pages)
|
18
|
+
timeout: 120 # Optional timeout in number of seconds (default: 60)
|
17
19
|
ids:
|
18
20
|
topical: 10570
|
19
21
|
blueprint: 11329
|
data/lib/jekyll-indico/core.rb
CHANGED
@@ -23,10 +23,10 @@ module JekyllIndico
|
|
23
23
|
attr_accessor :dict
|
24
24
|
|
25
25
|
# ID for IRIS-HEP: 10570
|
26
|
-
def initialize(base_url, indico_id, **kargs)
|
26
|
+
def initialize(base_url, indico_id, limit: nil, **kargs)
|
27
27
|
@dict = {}
|
28
28
|
|
29
|
-
download_and_iterate(base_url, indico_id, **kargs) do |i|
|
29
|
+
download_and_iterate(base_url, indico_id, limit: limit, **kargs) do |i|
|
30
30
|
# Trim paragraph tags
|
31
31
|
d = i['description']
|
32
32
|
d = d[3..-1] if d.start_with? '<p>'
|
@@ -62,9 +62,10 @@ module JekyllIndico
|
|
62
62
|
|
63
63
|
private
|
64
64
|
|
65
|
-
|
66
|
-
|
67
|
-
|
65
|
+
def get_parsed_results(base_url, indico_id, timeout: nil, **params)
|
66
|
+
opts = { use_ssl: true }
|
67
|
+
opts[:read_timeout] = timeout if timeout
|
68
|
+
|
68
69
|
uri = URI.join(base_url, "/export/categ/#{indico_id}.json")
|
69
70
|
uri.query = URI.encode_www_form(params)
|
70
71
|
|
@@ -75,15 +76,29 @@ module JekyllIndico
|
|
75
76
|
raise Error, 'Use INDICO_TOKEN with a new-style token'
|
76
77
|
end
|
77
78
|
|
78
|
-
opts = { use_ssl: true }
|
79
|
-
opts[:read_timeout] = timeout if timeout
|
80
|
-
|
81
79
|
response = Net::HTTP.start(uri.hostname, uri.port, **opts) { |http| http.request(req) }
|
82
80
|
|
83
|
-
|
84
|
-
parsed
|
81
|
+
parsed = JSON.parse(response.body)
|
82
|
+
parsed['results']
|
83
|
+
end
|
84
|
+
|
85
|
+
# Run a block over each item in the downloaded results
|
86
|
+
def download_and_iterate(base_url, indico_id, limit: nil, **params, &block)
|
87
|
+
params[:limit] = limit if limit
|
88
|
+
params[:pretty] = 'no'
|
85
89
|
|
86
|
-
|
90
|
+
unless limit
|
91
|
+
results = get_parsed_results(base_url, indico_id, **params)
|
92
|
+
results.each(&block)
|
93
|
+
return
|
94
|
+
end
|
95
|
+
|
96
|
+
0.step.each do |n|
|
97
|
+
results = get_parsed_results(base_url, indico_id, offset: n * limit, **params)
|
98
|
+
break if results.empty?
|
99
|
+
|
100
|
+
results.each(&block)
|
101
|
+
end
|
87
102
|
end
|
88
103
|
end
|
89
104
|
end
|
@@ -35,6 +35,7 @@ module JekyllIndico
|
|
35
35
|
@site.data[data_path] = {} unless @site.data.key? data_path
|
36
36
|
|
37
37
|
timeout = @site.config.dig('indico', 'timeout')
|
38
|
+
limit = @site.config.dig('indico', 'paginate')
|
38
39
|
|
39
40
|
# Do nothing if already downloaded
|
40
41
|
return if @site.data[data_path].key? name
|
@@ -42,7 +43,7 @@ module JekyllIndico
|
|
42
43
|
msg = @cache_msg ? " - run `#{@cache_msg}` to cache" : ''
|
43
44
|
print "Accessing Indico meeting API for #{name}:#{number}#{msg}"
|
44
45
|
time = Benchmark.realtime do
|
45
|
-
iris_meeting = Meetings.new(base_url, number, timeout: timeout)
|
46
|
+
iris_meeting = Meetings.new(base_url, number, timeout: timeout, limit: limit)
|
46
47
|
@site.data[data_path][name] = iris_meeting.dict
|
47
48
|
end
|
48
49
|
puts ", took #{time.round(1)} s"
|
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
|
+
version: 0.5.0
|
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-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|