Update for the new academic year

This commit is contained in:
Lorin Werthen 2018-07-11 20:35:06 +02:00
parent 1f67ea6ea9
commit f7ce92fc7c
No known key found for this signature in database
GPG key ID: F11FFC921E0E08E0
2 changed files with 10 additions and 5 deletions

View file

@ -19,10 +19,15 @@ module PreprocessHelper
end end
def ignore_old_content(*paths) def ignore_old_content(*paths)
paths.each do |path|
latest_year_with_content = @items.find_all("/#{path}/**/*").map { |it| it.identifier.to_s.match(%r{/(\d\d-\d\d)/})[1] }.sort[-1]
latest_year = [latest_year_with_content, @config[:academic_year]].min
@items.delete_if do |item| @items.delete_if do |item|
next unless item.identifier.match?(%r{^/(#{paths.join('|')})/}) next unless item.identifier.match?(%r{^/#{path}/})
year = item.identifier.to_s.match(%r{/(\d\d-\d\d)/})[1] year = item.identifier.to_s.match(%r{/(\d\d-\d\d)/})[1]
year != @config[:academic_year] year != latest_year
end
end end
end end

View file

@ -1,5 +1,5 @@
title: Zeus WPI title: Zeus WPI
academic_year: 17-18 academic_year: 18-19
# Needed for atom_feed # Needed for atom_feed
author_name: '' author_name: ''
author_uri: '' author_uri: ''