Sort blogposts and events instead of relying on filesystem sorting

This commit is contained in:
Rien Maertens 2017-09-30 17:42:52 +02:00
parent 82c6c989e6
commit 615fb30e29
No known key found for this signature in database
GPG key ID: 943CAB70C511D23C
3 changed files with 11 additions and 4 deletions

View file

@ -1,6 +1,11 @@
module ArchiveHelper
def academic_years
Set.new(items.find_all('/blog/*/*').map { |i| i.identifier.to_s[/\d\d-\d\d/] }).to_a
# Set.to_a to prevent duplicates
Set.new(items
.find_all('/blog/*/*')
.map { |i| i.identifier.to_s[/\d\d-\d\d/] })
.to_a
.sort
end
def academic_years_blog_items

View file

@ -22,7 +22,7 @@ module EventsHelper
end
def academic_years_event_items
items.find_all('/events/*').map { |e| [e[:academic_year], e] }.reverse
items.find_all('/events/*').map { |e| [e[:academic_year], e] }.sort_by(&:first)
end
def grouped_events

View file

@ -1,8 +1,10 @@
module PreprocessHelper
def ignore_old_blogposts
@items.delete_if do |item|
next unless item.identifier.to_s.start_with?('/blog/')
!item.identifier.to_s.start_with?('/blog/16-17/')
path = item.identifier.to_s
next unless path.start_with?('/blog/')
year = path.gsub(%r{/blog/(\d\d)-\d\d/.*}, '\1').to_i
year < 16
end
end