agenda-libre-ruby/app/helpers/events_helper.rb

31 lines
867 B
Ruby

# Helper for the event views
module EventsHelper
def set_events_meta
set_meta_tags \
description: t('layouts.application.subtitle'),
keywords: @events.map { |e| e.tags }.join(' ').split.group_by { |i| i }
.reject { |_k, v| v.size < 2 }.map { |k, _v| k },
DC: {
title: t('layouts.application.title'),
subject: t('layouts.application.subtitle'),
publisher: 'april'
}
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,
region: @event.related_region,
position: "#{@event.latitude};#{@event.longitude}",
ICBM: "#{@event.latitude}, #{@event.longitude}"
}
end
def wrap(s, width = 78)
s.gsub(/(.{1,#{width}})(\s+|\Z)/, "\\1\n")
end
end