Skip to content

Commit 81975e5

Browse files
authored
feat: allow pages to ordered in projects (#787)
1 parent 74509bd commit 81975e5

File tree

6 files changed

+20
-17
lines changed

6 files changed

+20
-17
lines changed

_layouts/focus-area.html

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,15 @@
1313
{{content}}
1414
</div>
1515

16-
{% assign doProjects = 0 %}
17-
{% assign sorted = site.pages | sort_natural: 'title' %}
18-
{% for mypage in sorted %}
19-
{% if mypage.pagetype == 'project' %}
2016
{% assign page_focus_area = page.name | basename %}
21-
{% if mypage.focus-area contains page_focus_area %}
22-
{% assign doProjects = 1 %}
23-
{% break %}
24-
{% endif %}
25-
{% endif %}
26-
{% endfor %}
17+
{% assign sorted = site.pages | smart_page_sort: "focus-area", page_focus_area %}
2718

28-
{% if doProjects ==1 %}
19+
{% unless sorted.empty %}
2920
<div class="container-fluid projects">
3021
<h2 class="alt-h2 text-center mb-3 mt-lg-6" id="projects">{{ page.short_title | upcase }} Projects</h2><br>
3122
<center>
3223
<div class="row">
3324
{% for mypage in sorted %}
34-
{% if mypage.pagetype == 'project' %}
35-
{% assign page_focus_area = page.name | basename %}
36-
{% if mypage.focus-area contains page_focus_area %}
3725
<div class="card" style="width: 17rem;">
3826
<a href=/projects/{{mypage.shortname}}.html>
3927
<img class="card-img-top" src="/assets/{{mypage.image | default: "logos/Iris-hep-5-just-graphic.png"}}" alt="Card image cap">
@@ -46,14 +34,12 @@ <h2 class="alt-h2 text-center mb-3 mt-lg-6" id="projects">{{ page.short_title |
4634
</div>
4735
</div>
4836
</div>
49-
{% endif %}
50-
{% endif %}
5137
{% endfor %}
5238
</div>
5339
</center>
5440
<br>
5541
</div>
56-
{% endif %}
42+
{% endunless %}
5743

5844

5945
{% assign sorted_presentations = site.data['sorted_presentations'] %}

_plugins/smart_sort.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# frozen_string_literal: true
2+
3+
module IrisHep
4+
# Adding useful file filters
5+
module SmartSort
6+
def smart_page_sort(input, field, match)
7+
input.select { |p| p['pagetype'] == 'project' && p[field].include?(match) }
8+
.sort_by { |p| [p['position'] || 0, p['title'].downcase] }
9+
end
10+
end
11+
end
12+
13+
Liquid::Template.register_filter(IrisHep::SmartSort)

pages/projects/osg-networking.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pagetype: project
77
image: logos/Iris-hep-5-just-graphic.png
88
blurb: Provide network monitoring for LHC and OSG sites
99
focus-area: osglhc
10+
position: -1
1011
team:
1112
- smckee
1213
- djw8605

pages/projects/osg-operations.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ shortname: osg-operations
66
pagetype: project
77
image: logos/Iris-hep-5-just-graphic.png
88
blurb: Operate OSG-LHC services
9+
position: -1
910
focus-area:
1011
- doma
1112
- osglhc

pages/projects/osg-security.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ shortname: osg-security
66
pagetype: project
77
image: logos/Iris-hep-5-just-graphic.png
88
blurb: OSG Cybersecurity team
9+
position: -1
910
focus-area: osglhc
1011
team:
1112
- mtstanfield

pages/projects/osg-software.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ shortname: osg-software
66
pagetype: project
77
image: logos/Iris-hep-5-just-graphic.png
88
blurb: Provide integrated software for running dHTC services
9+
position: -1
910
focus-area: osglhc
1011
team:
1112
- brianhlin

0 commit comments

Comments
 (0)