Skip to content

Commit 1d4d174

Browse files
authored
Merge pull request #899 from Philippus/current-events
Show current events on the upcoming events page until they are over
2 parents bc7a956 + 822329e commit 1d4d174

File tree

7 files changed

+33
-18
lines changed

7 files changed

+33
-18
lines changed

_layouts/events.html

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,16 @@
22
layout: inner-page-parent
33
---
44

5-
{% include events-training-list-top.html collection=paginator.events %}
5+
{% capture now %}{{site.time | date: '%s' | plus: 0}}{% endcapture %}
6+
{% assign upcomingEvents = '' | split: ',' %}
7+
{% for event in paginator.events %}
8+
{% capture date %}{{event.end|date: '%s'|plus: 86400}}{% endcapture %}
9+
{% if now <= date %}
10+
{% assign upcomingEvents = upcomingEvents | push: event %}
11+
{% endif %}
12+
{% endfor %}
13+
14+
{% include events-training-list-top.html collection=upcomingEvents %}
615

716
{{content}}
817
</div>

_layouts/pastevents.html

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,16 @@
22
layout: inner-page-parent
33
---
44

5-
{% include events-training-list-top.html collection=paginator.events %}
5+
{% capture now %}{{site.time | date: '%s' | plus: 0}}{% endcapture %}
6+
{% assign pastEvents = '' | split: ',' %}
7+
{% for event in paginator.events %}
8+
{% capture date %}{{event.end|date: '%s'|plus: 86400}}{% endcapture %}
9+
{% if now > date %}
10+
{% assign pastEvents = pastEvents | push: event %}
11+
{% endif %}
12+
{% endfor %}
13+
14+
{% include events-training-list-top.html collection=pastEvents %}
615

716
{{content}}
817
</div>

_layouts/training.html

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,17 @@
22
layout: inner-page-parent
33
---
44

5-
{% include events-training-list-top.html collection=paginator.trainings %}
5+
{% capture now %}{{site.time | date: '%s' | plus: 0}}{% endcapture %}
6+
{% assign upcomingTrainings = '' | split: ',' %}
7+
{% for training in paginator.trainings %}
8+
{% capture date %}{{training.when|date: '%s'|plus: 86400}}{% endcapture %}
9+
{% if now <= date %}
10+
{% assign upcomingTrainings = upcomingTrainings | push: training %}
11+
{% endif %}
12+
{% endfor %}
13+
14+
{% include events-training-list-top.html collection=upcomingTrainings %}
615
</div>
716

817
{% include paginator.html urlPath="training" %}
9-
</div>
18+
</div>

_plugins/octopress-paginate.rb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -175,16 +175,6 @@ def collection(page)
175175
collection = collection.reject{|p| (p.data['tags'] & tags).empty?}
176176
end
177177

178-
# Custom mod: reject all "past" (with date before our current 'tomorrow') elements if "discardPastItems" is set to true:
179-
if page.data['paginate']['discardPastItems']
180-
collection = collection.reject{|p| (p.date < (Date.today.next_day(1)).to_time)}
181-
end
182-
183-
# Custom mod: retrieve only "past" (with date before our 'today') elements if "pastItems" is set to true:
184-
if page.data['paginate']['pastItems']
185-
collection = collection.select{|p| (p.date < Date.today.to_time)}
186-
end
187-
188178
collection
189179
end
190180

events/index.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ paginate:
88
per_page: 9999
99
collection: events
1010
permalink: /:num/
11-
discardPastItems: true
1211
title_suffix: ""
1312
---
1413

pastevents/index.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ paginate:
88
collection: events
99
per_page: 9999
1010
permalink: /:num/
11-
pastItems: true
1211
reversed: true
1312
title_suffix: ""
1413
---

training/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ permalink: /training/
55

66
# Pagination
77
paginate:
8+
per_page: 9999
89
collection: trainings
910
permalink: /:num/
10-
discardPastItems: true
1111
title_suffix: ""
12-
---
12+
---

0 commit comments

Comments
 (0)