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

26 lines
717 B
Ruby
Raw Normal View History

2017-06-06 23:08:10 +02:00
# Helper for the digest/markdown views
module DigestHelper
# Important mechanism, to ensure the digest will not have the same footnote
# link multiple times
def renumber_footnotes(id, description)
2017-06-09 17:37:24 +02:00
return if description.nil? || description.blank?
2018-09-15 15:05:21 +02:00
2017-06-06 23:29:45 +02:00
description.gsub(/\[(\d)+\]/, "[#{id}_\\1]")
2017-06-06 23:08:10 +02:00
end
def count_by_country(events)
events.group_by { |e| e.region&.region || e.region }.collect do |region, es|
"#{region}: #{es.size}"
end.join ', '
end
# [country city] title - date
def to_title(event)
["[#{event.region.region&.code || event.region&.code}",
"#{event.city}]",
"[#{event.title}](#{event_url event})",
'-',
display_date(event)].join ' '
end
2017-06-06 23:08:10 +02:00
end