2014-08-06 14:47:47 +02:00
|
|
|
# Helper for the event views
|
2013-12-28 23:45:13 +01:00
|
|
|
module EventsHelper
|
2014-08-06 14:47:47 +02:00
|
|
|
def set_events_meta
|
|
|
|
set_meta_tags \
|
2014-08-09 18:59:11 +02:00
|
|
|
description: t('layouts.application.subtitle'),
|
2014-09-05 21:42:35 +02:00
|
|
|
keywords: @events.map(&:tags).join(' ').split.group_by { |i| i }
|
2014-08-06 14:47:47 +02:00
|
|
|
.reject { |_k, v| v.size < 2 }.map { |k, _v| k },
|
|
|
|
DC: {
|
|
|
|
title: t('layouts.application.title'),
|
2014-08-07 22:16:05 +02:00
|
|
|
subject: t('layouts.application.subtitle'),
|
|
|
|
publisher: 'april'
|
2014-08-06 14:47:47 +02:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def set_event_meta
|
|
|
|
set_meta_tags \
|
|
|
|
keywords: @event.tags,
|
|
|
|
DC: { title: @event.title, date: @event.start_time.to_s },
|
|
|
|
geo: {
|
|
|
|
placename: @event.city,
|
2015-02-15 15:50:47 +01:00
|
|
|
region: @event.region,
|
2014-08-24 12:19:45 +02:00
|
|
|
position: "#{@event.latitude};#{@event.longitude}",
|
|
|
|
ICBM: "#{@event.latitude}, #{@event.longitude}"
|
2014-08-06 14:47:47 +02:00
|
|
|
}
|
|
|
|
end
|
2014-08-16 17:39:24 +02:00
|
|
|
|
2014-08-26 16:51:52 +02:00
|
|
|
def display_date(event = @event)
|
2014-09-02 01:02:51 +02:00
|
|
|
if event.start_time.to_date == event.end_time.to_date
|
2014-11-05 21:25:18 +01:00
|
|
|
display_sameday event
|
2014-08-26 16:51:52 +02:00
|
|
|
else
|
2014-11-05 21:25:18 +01:00
|
|
|
display_multi_days event
|
2014-08-26 16:51:52 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-11-05 21:25:18 +01:00
|
|
|
def display_sameday(event)
|
|
|
|
t 'date.formats.same_day',
|
|
|
|
date: l(event.start_time.to_date, format: :long),
|
|
|
|
start: l(event.start_time, format: :hours),
|
|
|
|
end: l(event.end_time, format: :hours)
|
|
|
|
end
|
|
|
|
|
|
|
|
def display_multi_days(event)
|
|
|
|
t 'date.formats.period',
|
|
|
|
start: l(event.start_time, format: :at),
|
|
|
|
end: l(event.end_time, format: :at)
|
|
|
|
end
|
|
|
|
|
2014-08-16 17:39:24 +02:00
|
|
|
def wrap(s, width = 78)
|
|
|
|
s.gsub(/(.{1,#{width}})(\s+|\Z)/, "\\1\n")
|
|
|
|
end
|
2016-03-01 22:54:52 +01:00
|
|
|
|
|
|
|
# Select the events to display in a month, sorted
|
|
|
|
def month_events(events, date)
|
|
|
|
events.select { |e| (e.start_time.to_date..e.end_time.to_date).cover? date }
|
|
|
|
.sort_by(&:city)
|
|
|
|
end
|
2013-12-28 23:45:13 +01:00
|
|
|
end
|