Module: Odania::Controllers::UrlHelpers

Defined in:
lib/odania/controllers/url_helpers.rb

Overview

TODO: Better name?

Instance Method Summary collapse

Instance Method Details

#current_menuObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/odania/controllers/url_helpers.rb', line 10

def current_menu
	cur_locale = params[:locale]
	if cur_locale.nil?
		cur_locale = current_site.default_language.iso_639_1
	end

	@current_menu ||= current_site.get_current_menu(cur_locale)
	I18n.locale = @current_menu.language.iso_639_1 unless @current_menu.nil?
	return @current_menu
end

#current_siteObject

The current site depending on the host, e.g. www.odania.de



6
7
8
# File 'lib/odania/controllers/url_helpers.rb', line 6

def current_site
	@current_site ||= Odania::Site.active.where(host: request.host_with_port).first
end

#tag_cloud(tags, classes) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/odania/controllers/url_helpers.rb', line 22

def tag_cloud(tags, classes)
	return [] if tags.empty?

	max_count = tags.sort_by(&:count).last.count.to_f

	tags.each do |tag|
		index = ((tag.count / max_count) * (classes.size - 1))
		yield tag, classes[index.nan? ? 0 : index.round]
	end
end