durfdoen-2.0/lib/helpers/verenigingen.rb

48 lines
1.3 KiB
Ruby
Raw Normal View History

2020-02-27 21:43:59 +01:00
# frozen_string_literal: true
module VerenigingenLists
# Helpers for navbar partial
2020-02-27 21:43:59 +01:00
def current_child_of(item)
child_of(item, @item)
end
2020-02-27 21:43:59 +01:00
def child_of(parent, child)
children_of(parent).include?(child)
end
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
@items.find_all("**/verenigingen/*").map{|x| x[:themas]}.flatten.uniq.compact
2020-02-27 21:43:59 +01:00
end
def konventen
@items.find_all("**/konventen/*").to_a
end
def projecten
@items.find_all("**/projecten/*").to_a
end
def konventen_and_projecten
konventen.union(projecten)
end
def verenigingen
@items.find_all("**/verenigingen/*").map{|x| {
"naam" => x[:naam],
"verkorte_naam" => x[:verkorte_naam],
"konvent" => x[:konvent],
"themas" => x[:themas]
}}.to_a
2020-02-27 21:43:59 +01:00
end
def abbreviation(item)
item.identifier.without_ext.split('/').last
end
def image_url(item)
"https://aniekwendt.nl/wp-content/upload_folders/aniekwendt.nl/mijn-puppy-komt-niet-als-ik-roep.jpg"
end
def themas
@items.find_all("**/themas/*")
end
end