2020-02-27 21:43:59 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-02-28 13:26:02 +01:00
|
|
|
# Helpers for verenigingen
|
|
|
|
module VerenigingenHelper
|
2020-02-27 21:43:59 +01:00
|
|
|
# Returns every navigable item
|
|
|
|
# A navigable item contains the :navigable attribute
|
|
|
|
# Optionally contains an order attribute, determining the order in the navbar
|
|
|
|
def themes
|
2020-02-28 12:56:41 +01:00
|
|
|
@items.find_all("**/verenigingen/*").map{|x| x[:themas]}.flatten.uniq.compact
|
2020-02-27 21:43:59 +01:00
|
|
|
end
|
|
|
|
def konvents
|
|
|
|
@items.find_all("**/verenigingen/*").map{|x| x[:konvent]}.uniq.compact
|
|
|
|
end
|
2020-03-19 21:05:26 +01:00
|
|
|
def verenigingen
|
|
|
|
@items.find_all("**/verenigingen/*").map{|x| {
|
|
|
|
"titel" => x[:titel],
|
|
|
|
"naam" => x[:naam],
|
|
|
|
"konvent" => x[:konvent],
|
|
|
|
"themas" => x[:themas]
|
|
|
|
}}.to_a
|
|
|
|
end
|
2020-08-23 03:03:35 +02:00
|
|
|
def abbreviation(item)
|
|
|
|
item.identifier.without_ext.split('/').last
|
|
|
|
end
|
|
|
|
def verenigingen_random(amount)
|
|
|
|
@items.find_all("**/verenigingen/*").map{|x| {
|
|
|
|
"titel" => x[:titel],
|
|
|
|
"naam" => x[:naam],
|
|
|
|
"konvent" => x[:konvent],
|
|
|
|
"themas" => x[:themas]
|
|
|
|
}}.to_a.shuffle[0..amount]
|
|
|
|
end
|
2020-03-19 21:05:26 +01:00
|
|
|
end
|