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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d9222f10d181e9fc090dede1530321b6d25cf1f25c847ed701b0b27d0dc09aef
4
- data.tar.gz: 7ef2fef6b5dfdab7f5e54afda3471180f262e0fda96f86e65cb477ce95bc3875
3
+ metadata.gz: 4b5280223b8fb9efe76165961a2de236de282fb658813ac140bf5e99f7478889
4
+ data.tar.gz: 2e38b6c7f139929a2d37a303edd43c5c25c2d3653fed79b45d139850eb2df647
5
5
  SHA512:
6
- metadata.gz: b8cd5282b1d97250f191825b79d74a9a1e10457dbaa7a959cca6526e3232fc8fa2f209b3c453ef05499232f202be4dc7259066991383a99cf25776f79d78b86f
7
- data.tar.gz: e99096baf780ed5ebafd2d63b262bcb526f1caf0b075c0eecc1a8353233c836b361fea73140f93535be7b7757977e84648ef030a5551f6aafd9d5d1553183ee3
6
+ metadata.gz: 1777d731abaaea07081f4127a0058579092f7914f03fa8c558fa7ffa69510863dd875b7fdeff0efd47ee2f84fd127d12a4865e232cb530ea485195c563c957d1
7
+ data.tar.gz: ac4b4a99ef43e216a1b91e6607a01cfc399be3e3435bfd51d7f4e2580196e9efaca84b1856b334a37a1552df386c564dc3f85bb693647e248817a475b16eed63
@@ -1,10 +1,11 @@
1
- name: Ruby
1
+ name: CI
2
2
 
3
3
  on:
4
4
  workflow_dispatch:
5
5
  pull_request:
6
6
  push:
7
- branches: [ $default-branch ]
7
+ branches:
8
+ - main
8
9
 
9
10
  jobs:
10
11
  test:
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jekyll-indico (0.1.0)
4
+ jekyll-indico (0.2.0)
5
5
  jekyll (>= 3.8, < 5.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,3 +1,8 @@
1
+ # Jekyll-Indico
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/jekyll-indico.svg)](https://badge.fury.io/rb/jekyll-indico)
4
+ ![CI](https://github.com/iris-hep/jekyll-indico/workflows/CI/badge.svg)
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
- <!-- Feature not added yet
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
- require 'jekyll-indico/rake_task'
45
-
46
- JekyllIndico::RakeTask.new(:cache)
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
 
@@ -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
@@ -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
@@ -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
- "https://indico.cern.ch#{join_url(indico_id, kargs)}"
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 name.to_s, number
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JekyllIndico
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-indico
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henry Schreiner