Support predefined locations
The service that looks up the locations changes sometimes. Therefore it is useful to have some "predefined" locations, which we can change in one place; the format is "$NAME". Since the metadata is yaml, this exclude the nice "#NAME" or even ":NAME".
This commit is contained in:
parent
918cc9b08b
commit
afae88656a
1
Rules
1
Rules
|
@ -36,6 +36,7 @@ preprocess do
|
|||
|
||||
add_report_metadata
|
||||
add_project_metadata
|
||||
convert_locations
|
||||
end
|
||||
|
||||
#
|
||||
|
|
|
@ -12,6 +12,14 @@ module PreprocessHelper
|
|||
}
|
||||
end
|
||||
|
||||
def predefined_locations
|
||||
{
|
||||
'$kelder' => 'Zeus WPI, Gent',
|
||||
'$s9' => 'S9, Gent',
|
||||
'$therminal' => 'De Therminal, Gent'
|
||||
}
|
||||
end
|
||||
|
||||
def allowed_privacy_status
|
||||
%w(additional general processor development)
|
||||
end
|
||||
|
@ -87,6 +95,16 @@ module PreprocessHelper
|
|||
end
|
||||
end
|
||||
|
||||
def convert_locations
|
||||
@items.find_all('/events/*/*.md').each do |event|
|
||||
location_link = event[:locationlink]&.downcase&.strip
|
||||
if location_link&.start_with?('$') && !predefined_locations.key?(location_link)
|
||||
raise "unknown location variable #{location_link}, must be one of #{predefined_locations.keys}"
|
||||
end
|
||||
event[:locationlink] = predefined_locations.fetch(location_link, event[:locationlink])
|
||||
end
|
||||
end
|
||||
|
||||
def add_report_metadata
|
||||
@items.find_all('/about/verslagen/*/*').each do |report|
|
||||
report[:academic_year] = report.identifier.to_s.split('/')[-2]
|
||||
|
|
Loading…
Reference in a new issue