Skip to content

Commit 22044da

Browse files
authored
feat: add project lifecycles (#1456)
1 parent 2e839a8 commit 22044da

File tree

8 files changed

+125
-9
lines changed

8 files changed

+125
-9
lines changed

Gemfile

+4-1
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,8 @@ gem 'pkg-config', '~> 1.4'
5454
# Performance-booster for watching directories on Windows
5555
gem 'wdm', '~> 0.1.0' if Gem.win_platform?
5656

57-
# Required on Ruby 3+
57+
# Required on Ruby 3+ (next Jekyll will fix this missing dep)
5858
gem 'webrick'
59+
60+
# Required on Ruby 2.6 (polyfill)
61+
gem 'ruby-next'

Gemfile.lock

+13-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ GEM
66
ast (2.4.2)
77
colorator (1.1.0)
88
concurrent-ruby (1.1.10)
9+
diff-lcs (1.5.0)
910
em-websocket (0.5.3)
1011
eventmachine (>= 0.12.9)
1112
http_parser.rb (~> 0)
@@ -106,6 +107,13 @@ GEM
106107
parser (>= 3.1.1.0)
107108
rubocop-rake (0.6.0)
108109
rubocop (~> 1.0)
110+
ruby-next (0.15.1)
111+
ruby-next-core (= 0.15.1)
112+
ruby-next-parser (>= 3.1.1.0)
113+
unparser (~> 0.6.0)
114+
ruby-next-core (0.15.1)
115+
ruby-next-parser (3.1.1.3)
116+
parser (>= 3.0.3.1)
109117
ruby-progressbar (1.11.0)
110118
safe_yaml (1.0.5)
111119
sassc (2.4.0)
@@ -115,6 +123,9 @@ GEM
115123
typhoeus (1.4.0)
116124
ethon (>= 0.9.0)
117125
unicode-display_width (1.8.0)
126+
unparser (0.6.4)
127+
diff-lcs (~> 1.3)
128+
parser (>= 3.1.0)
118129
webrick (1.7.0)
119130
yell (2.2.2)
120131

@@ -137,11 +148,12 @@ DEPENDENCIES
137148
rake
138149
rubocop (~> 1.25.0)
139150
rubocop-rake
151+
ruby-next
140152
tzinfo-data
141153
webrick
142154

143155
RUBY VERSION
144156
ruby 2.7.3p183
145157

146158
BUNDLED WITH
147-
2.2.23
159+
2.3.13

_includes/head.html

+6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222

2323
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
2424

25+
{{ page.includes | default: "" }}
26+
27+
{% if page.layout == "focus-area" or page.mermaid %}
28+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/mermaid.min.js" integrity="sha384-6qzFcd+IG/OgXej451KTI/pbrex++8tdIfKsNF+gDVx1gfkmIG7z+uIIspvxAP7u" crossorigin="anonymous"></script>
29+
{% endif %}
30+
2531
<!-- Global site tag (gtag.js) - Google Analytics -->
2632
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-127196353-1"></script>
2733
<script>

_layouts/focus-area.html

+8
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,14 @@ <h2 class="alt-h2 text-center mb-3 mt-lg-6" id="join-us">Join us</h2>
146146
</div>
147147
</section>
148148

149+
{% if sorted.size > 0 %}
150+
{{ sorted | gantt_project: page.title }}
151+
152+
<script>
153+
mermaid.initialize({ startOnLoad: true });
154+
</script>
155+
{% endif %}
156+
149157

150158
</main>
151159
</div>

_plugins/filters.rb

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def dig(*args)
1616
end
1717
end
1818

19+
# IRIS-HEP modules
1920
module IrisHep
2021
# Adding useful filters
2122
module Filters

_plugins/gantt.rb

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# frozen_string_literal: true
2+
3+
if Gem.ruby_version < Gem::Version.new('2.7.0')
4+
# Add filter_map
5+
require 'ruby-next'
6+
using RubyNext
7+
end
8+
9+
def process_projects(projects)
10+
projects.filter_map do |project|
11+
project['start-date'] && {
12+
title: project['title'],
13+
focus_area: [*project['focus-area']],
14+
start: project['start-date'],
15+
end: project['end-date'] || Date.today,
16+
maturity: project['maturity'],
17+
status: MAT_TO_KW[project['maturity']]
18+
}
19+
end
20+
end
21+
22+
MAT_TO_KW = {
23+
'Development' => 'done',
24+
'Exploratory' => 'done',
25+
'Testing' => 'done',
26+
'Unknown' => 'done',
27+
'Deployed' => 'active',
28+
'Archived' => 'crit'
29+
}.freeze
30+
31+
def make_section(projects)
32+
projects.map do |p|
33+
format(' %<title>-34s :%<status>-7s, %<start>s, %<end>s', p)
34+
end.join("\n")
35+
end
36+
37+
# IRIS-HEP modules
38+
module IrisHep
39+
# IRIS-HEP project gantt charts
40+
module GanttFilters
41+
def gantt_projects(projects_raw)
42+
projects = process_projects(projects_raw)
43+
result = "<div class=\"mermaid\">
44+
gantt
45+
title IRIS-HEP project lifecyles
46+
dateFormat YYYY-MM-DD
47+
axisFormat %Y
48+
"
49+
ia = projects.filter { |p| p[:focus_area].include?('ia') }
50+
doma = projects.filter { |p| p[:focus_area].include?('doma') || p[:focus_area].include?('osglhc') }
51+
as = projects - ia - doma
52+
{ ia: ia, doma: doma, as: as }.each do |sec, val|
53+
result += "\n section #{sec}\n"
54+
result += make_section(val)
55+
end
56+
result += "\n</div>"
57+
result
58+
end
59+
60+
def gantt_project(projects_raw, name)
61+
projects = process_projects(projects_raw)
62+
result = "<div class=\"mermaid\">
63+
gantt
64+
title #{name} project lifecyles
65+
dateFormat YYYY-MM-DD
66+
axisFormat %Y
67+
"
68+
result += make_section(projects)
69+
result += '</div>'
70+
result
71+
end
72+
end
73+
end
74+
75+
Liquid::Template.register_filter(IrisHep::GanttFilters)

_scripts/get_project_dates.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ def process_projects(projects)
2727
end
2828
end
2929

30+
def make_section(projects)
31+
projects.each { printf(" %<title>-30s :%<status>-7s, %<start>s, %<end>s\n", _1) }
32+
end
33+
3034
project_files = Pathname.glob('pages/projects/*.md')
3135

3236
projects_raw = project_files.map do |fn|
@@ -50,7 +54,5 @@ def process_projects(projects)
5054

5155
{ ia: ia, doma: doma, as: as }.each do |sec, val|
5256
puts "\n section #{sec}"
53-
val.each do |proj|
54-
printf(" %<title>-30s :%<status>-7s, %<start>s, %<end>s\n", proj)
55-
end
57+
make_section(val)
5658
end

pages/projects.md

+13-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
permalink: /projects.html
33
layout: default
44
title: IRIS/HEP Projects
5+
mermaid: true
56
---
67

78
# IRIS-HEP Projects
@@ -12,11 +13,12 @@ table {
1213
}
1314
</style>
1415

16+
1517
| Name | Focus Area(s) | Maturity | Description |
1618
|------|-------|-------|:------------|
1719
{% assign sorted = site.pages | sort_natural: 'title' -%}
18-
{%- for mypage in sorted -%}
19-
{%- if mypage.pagetype == 'project' -%}
20+
{% assign projects = sorted | where: "pagetype", "project" -%}
21+
{% for mypage in projects %}
2022
{%- capture focus-areas -%}
2123
{%- assign notfirst = false -%}
2224
{%- for fa in mypage.focus-area -%}
@@ -28,5 +30,12 @@ table {
2830
{%- endfor -%}
2931
{%- endcapture -%}
3032
| [{{mypage.title}}](/projects/{{mypage.shortname}}.html) | {{focus-areas}} | {% include maturity.html project=mypage %} | {{ mypage.blurb }} |
31-
{% endif -%}
32-
{% endfor -%}
33+
{% endfor %}
34+
35+
<br/>
36+
37+
{{ projects | gantt_projects }}
38+
39+
<script>
40+
mermaid.initialize({ startOnLoad: true });
41+
</script>

0 commit comments

Comments
 (0)