2016-09-13 18:12:52 +02:00
|
|
|
require 'uri'
|
2016-08-24 01:01:17 +02:00
|
|
|
module EventsHelper
|
|
|
|
def all_events
|
2016-10-03 15:15:48 +02:00
|
|
|
@items.find_all('/events/*/*').sort_by { |x| x[:time] }
|
|
|
|
end
|
|
|
|
|
|
|
|
def upcoming_events
|
2016-10-06 00:39:12 +02:00
|
|
|
all_events.reject { |x| x[:time] <= Date.today }
|
2016-10-03 15:15:48 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def past_events
|
2016-10-06 00:39:12 +02:00
|
|
|
all_events.reject { |x| x[:time] > Date.today }
|
2016-08-24 01:01:17 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def grouped_events
|
|
|
|
@items.find_all('/events/*/*/main.md')
|
|
|
|
end
|
|
|
|
|
|
|
|
def sub_events(grouped_event)
|
|
|
|
if grouped_event.identifier =~ /main.md/
|
|
|
|
query = grouped_event.identifier.to_s.split('/')[0..-2].join('/') + '/*'
|
|
|
|
@items.find_all(query).reject do |i|
|
|
|
|
i.identifier =~ /main.md/
|
|
|
|
end
|
|
|
|
else
|
|
|
|
[]
|
|
|
|
end
|
|
|
|
end
|
2016-09-13 18:12:52 +02:00
|
|
|
|
|
|
|
def locationlink(location)
|
|
|
|
"https://www.google.com/maps/embed/v1/place?key=AIzaSyBDTmw7LtDG28o9QjCnNucAJv2zTZpLjJU&q=#{URI.escape(location)}" if location
|
|
|
|
end
|
2016-08-24 01:01:17 +02:00
|
|
|
end
|