jekyll-indico 0.1.0 → 0.2.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/.github/workflows/ci.yml +3 -2
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/README.md +21 -6
- data/exe/jekyll-indico-cache +2 -1
- data/lib/jekyll-indico/cache.rb +2 -2
- data/lib/jekyll-indico/core.rb +20 -6
- data/lib/jekyll-indico/generator.rb +4 -2
- data/lib/jekyll-indico/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b5280223b8fb9efe76165961a2de236de282fb658813ac140bf5e99f7478889
|
4
|
+
data.tar.gz: 2e38b6c7f139929a2d37a303edd43c5c25c2d3653fed79b45d139850eb2df647
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1777d731abaaea07081f4127a0058579092f7914f03fa8c558fa7ffa69510863dd875b7fdeff0efd47ee2f84fd127d12a4865e232cb530ea485195c563c957d1
|
7
|
+
data.tar.gz: ac4b4a99ef43e216a1b91e6607a01cfc399be3e3435bfd51d7f4e2580196e9efaca84b1856b334a37a1552df386c564dc3f85bb693647e248817a475b16eed63
|
data/.github/workflows/ci.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,13 @@
|
|
1
|
+
# Version 0.2.0
|
2
|
+
|
3
|
+
Support for base URLs. The `indico: url:` parameter is *required*.
|
4
|
+
|
1
5
|
# Version 0.1.0
|
2
6
|
|
3
7
|
First version to be published, pulled from the IRIS-HEP website.
|
4
8
|
|
5
9
|
Extra features added during the transition include:
|
10
|
+
|
6
11
|
* Config settings for IDs and data path.
|
7
12
|
* `jekyll-indico-cache` script has customizable `--config` location.
|
8
13
|
* Some basic unit testing
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# Jekyll-Indico
|
2
|
+
|
3
|
+
[](https://badge.fury.io/rb/jekyll-indico)
|
4
|
+

|
5
|
+
|
1
6
|
This is a tool for importing meeting information from Indico.
|
2
7
|
|
3
8
|
#### Setup: config
|
@@ -6,6 +11,7 @@ Your `_config.yaml` file should contain the categories you want to download:
|
|
6
11
|
|
7
12
|
```yaml
|
8
13
|
indico:
|
14
|
+
url: https://indico.cern.ch # Indico instance to use (REQUIRED)
|
9
15
|
data: indico # Optional, folder name in _data to use
|
10
16
|
ids:
|
11
17
|
topical: 10570
|
@@ -37,17 +43,26 @@ If you want to cache for local website development, you can run:
|
|
37
43
|
bundle exec jekyll-indico-cache --config _config.yaml
|
38
44
|
```
|
39
45
|
|
40
|
-
|
41
|
-
Or, if you use rake, you can add the provided task:
|
46
|
+
Or, if you use rake, you can add a task like this:
|
42
47
|
|
43
48
|
```ruby
|
44
|
-
|
45
|
-
|
46
|
-
|
49
|
+
task: cache do
|
50
|
+
sh 'jekyll-indico-cache'
|
51
|
+
end
|
47
52
|
```
|
48
53
|
|
49
54
|
Now the "cache" task will cache your Indico reads.
|
50
|
-
|
55
|
+
|
56
|
+
|
57
|
+
#### Internals
|
58
|
+
|
59
|
+
This works by calling the Indico API and pulling meeting information, then
|
60
|
+
storing it in `site.data[config.indico.data][config.indico.id][number]` (or
|
61
|
+
caching it in
|
62
|
+
`_data/<config.indico.data>/<config.indico.id.key>/<number>.yml`). This then
|
63
|
+
available directly in liquid from this location. You can have as many ids as
|
64
|
+
you want (key is a category name that you select, the value is the group ID
|
65
|
+
number on Indico).
|
51
66
|
|
52
67
|
#### Setting up for development:
|
53
68
|
|
data/exe/jekyll-indico-cache
CHANGED
@@ -19,8 +19,9 @@ puts "Reading #{options[:config]}"
|
|
19
19
|
|
20
20
|
config = YAML.safe_load(File.read(options[:config]))
|
21
21
|
meeting_ids = JekyllIndico::Meetings.meeting_ids(config)
|
22
|
+
base_url = JekyllIndico::Meetings.base_url(config)
|
22
23
|
data_path = config.dig('indico', 'data') || 'indico'
|
23
24
|
|
24
|
-
JekyllIndico.cache(meeting_ids, data_path) do |name, number|
|
25
|
+
JekyllIndico.cache(base_url, meeting_ids, data_path) do |name, number|
|
25
26
|
puts "Accessing #{number} for #{name}"
|
26
27
|
end
|
data/lib/jekyll-indico/cache.rb
CHANGED
@@ -9,7 +9,7 @@ require 'jekyll-indico/core'
|
|
9
9
|
module JekyllIndico
|
10
10
|
# This will cache the hash of meeting IDs given into the data_path in _data
|
11
11
|
# in the current directory.
|
12
|
-
def self.cache(meeting_ids, data_path)
|
12
|
+
def self.cache(base_url, meeting_ids, data_path)
|
13
13
|
meeting_ids.each do |name, number|
|
14
14
|
yield name, number
|
15
15
|
indico_dir = Pathname.new('_data') / data_path
|
@@ -17,7 +17,7 @@ module JekyllIndico
|
|
17
17
|
indico_dir.mkdir unless indico_dir.directory?
|
18
18
|
folder.mkdir unless folder.directory?
|
19
19
|
|
20
|
-
iris_meeting = JekyllIndico::Meetings.new number
|
20
|
+
iris_meeting = JekyllIndico::Meetings.new(base_url, number)
|
21
21
|
iris_meeting.to_files(folder) { |key| puts "Making #{folder / key}.yml\n" }
|
22
22
|
end
|
23
23
|
end
|
data/lib/jekyll-indico/core.rb
CHANGED
@@ -9,15 +9,21 @@ require 'time'
|
|
9
9
|
require 'openssl'
|
10
10
|
|
11
11
|
module JekyllIndico
|
12
|
+
class Error < StandardError
|
13
|
+
end
|
14
|
+
|
15
|
+
class MissingURL < Error
|
16
|
+
end
|
17
|
+
|
12
18
|
# Look for topical meetings
|
13
19
|
class Meetings
|
14
20
|
attr_accessor :dict
|
15
21
|
|
16
22
|
# ID for IRIS-HEP: 10570
|
17
|
-
def initialize(indico_id, **kargs)
|
23
|
+
def initialize(base_url, indico_id, **kargs)
|
18
24
|
@dict = {}
|
19
25
|
|
20
|
-
download_and_iterate(indico_id, **kargs) do |i|
|
26
|
+
download_and_iterate(base_url, indico_id, **kargs) do |i|
|
21
27
|
# Trim paragraph tags
|
22
28
|
d = i['description']
|
23
29
|
d = d[3..-1] if d.start_with? '<p>'
|
@@ -56,11 +62,19 @@ module JekyllIndico
|
|
56
62
|
config.dig('indico', 'ids')
|
57
63
|
end
|
58
64
|
|
65
|
+
# Get base URL from a config
|
66
|
+
def self.base_url(config = {})
|
67
|
+
url = config.dig('indico', 'url')
|
68
|
+
raise MissingURL('indico: url: MISSING from your config!') unless url
|
69
|
+
|
70
|
+
url
|
71
|
+
end
|
72
|
+
|
59
73
|
private
|
60
74
|
|
61
75
|
# Run a block over each item in the downloaded results
|
62
|
-
def download_and_iterate(indico_id, **kargs, &block)
|
63
|
-
url = build_url(indico_id, **kargs)
|
76
|
+
def download_and_iterate(base_url, indico_id, **kargs, &block)
|
77
|
+
url = build_url(base_url, indico_id, **kargs)
|
64
78
|
uri = URI.parse(url)
|
65
79
|
response = Net::HTTP.get_response(uri)
|
66
80
|
|
@@ -77,7 +91,7 @@ module JekyllIndico
|
|
77
91
|
end
|
78
92
|
|
79
93
|
# Automatically signs request if environment has INDICO_API/SECRET_KEY
|
80
|
-
def build_url(indico_id, **kargs)
|
94
|
+
def build_url(base_url, indico_id, **kargs)
|
81
95
|
kargs[:pretty] = 'no'
|
82
96
|
|
83
97
|
if ENV['INDICO_API_KEY']
|
@@ -89,7 +103,7 @@ module JekyllIndico
|
|
89
103
|
end
|
90
104
|
end
|
91
105
|
|
92
|
-
"
|
106
|
+
"#{base_url}#{join_url(indico_id, kargs)}"
|
93
107
|
end
|
94
108
|
end
|
95
109
|
end
|
@@ -15,13 +15,15 @@ module JekyllIndico
|
|
15
15
|
|
16
16
|
meeting_ids = Meetings.meeting_ids(@site.config)
|
17
17
|
meeting_ids.each do |name, number|
|
18
|
-
collect_meeting
|
18
|
+
collect_meeting(name.to_s, number)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
private
|
23
23
|
|
24
24
|
def collect_meeting(name, number)
|
25
|
+
base_url = Meetings.base_url(@site.config)
|
26
|
+
|
25
27
|
data_path = @site.config.dig('indico', 'data') || 'indico'
|
26
28
|
@site.data[data_path] = {} unless @site.data.key? data_path
|
27
29
|
|
@@ -30,7 +32,7 @@ module JekyllIndico
|
|
30
32
|
|
31
33
|
puts "Accessing Indico meeting API for #{name}:#{number} " \
|
32
34
|
'- run `bundle exec rake cache` to cache'
|
33
|
-
iris_meeting = Meetings.new(number)
|
35
|
+
iris_meeting = Meetings.new(base_url, number)
|
34
36
|
@site.data[data_path][name] = iris_meeting.dict
|
35
37
|
end
|
36
38
|
end
|