From 73ece643cac31e90ee5b1ab11c97fa58f9e295c6 Mon Sep 17 00:00:00 2001 From: Stefan Schlott Date: Sun, 25 Aug 2013 09:54:05 +0200 Subject: [PATCH] Merge location data in events --- Rules | 1 + lib/location.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 lib/location.rb diff --git a/Rules b/Rules index c066e33b..1428af4c 100644 --- a/Rules +++ b/Rules @@ -3,6 +3,7 @@ preprocess do generate_archive_pages generate_twitter_archive_pages + merge_location_data() end diff --git a/lib/location.rb b/lib/location.rb new file mode 100644 index 00000000..23777b4b --- /dev/null +++ b/lib/location.rb @@ -0,0 +1,13 @@ +def merge_item_location_data(location) + if (location && location[:location]) + templates = @items['/_data/locations/'].attributes + if templates[location[:location].to_sym] + location.merge!(templates[location[:location].to_sym]) + end + end +end + +def merge_location_data() + items.select { |i| i[:kind] == 'event' }.each { |e| merge_item_location_data(e[:location]) } +end +