Module: Odania::Controllers::UrlHelpers
- Defined in:
- lib/odania/controllers/url_helpers.rb
Overview
TODO: Better name?
Instance Method Summary collapse
- #current_menu ⇒ Object
-
#current_site ⇒ Object
The current site depending on the host, e.g.
-
#tag_cloud(tags, classes) ⇒ Object
Thanks to github.com/mbleigh/acts-as-taggable-on.
Instance Method Details
#current_menu ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/odania/controllers/url_helpers.rb', line 10 def cur_locale = params[:locale] cur_locale = current_site.default_language.iso_639_1 if cur_locale.nil? @current_menu ||= current_site.(cur_locale) unless @current_menu.nil? I18n.locale = @current_menu.language.iso_639_1 return @current_menu end Odania::Menu.new(language_id: current_site.default_language.id) end |
#current_site ⇒ Object
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
Thanks to github.com/mbleigh/acts-as-taggable-on
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/odania/controllers/url_helpers.rb', line 24 def tag_cloud(, classes) return [] if .empty? max_count = .sort_by(&:count).last.count.to_f .each do |tag| index = ((tag.count / max_count) * (classes.size - 1)) yield tag, classes[index.nan? ? 0 : index.round] end end |