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 |
# File 'lib/odania/controllers/url_helpers.rb', line 10 def cur_locale = params[:locale] if cur_locale.nil? cur_locale = current_site.default_language.iso_639_1 end @current_menu ||= current_site.(cur_locale) I18n.locale = @current_menu.language.iso_639_1 unless @current_menu.nil? return @current_menu 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
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/odania/controllers/url_helpers.rb', line 22 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 |