<commit_before>module Odania
	module Controllers
		# TODO: Better name?
		module UrlHelpers
			# The current site depending on the host, e.g. www.odania.de
			def current_site
				@current_site ||= Odania::Site.active.where(host: request.host_with_port).first
			end

			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

			# Thanks to https://github.com/mbleigh/acts-as-taggable-on
			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
		end
	end
end
<commit_msg>Returning "empty menu" if none is defined<commit_after>module Odania
	module Controllers
		# TODO: Better name?
		module UrlHelpers
			# The current site depending on the host, e.g. www.odania.de
			def current_site
				@current_site ||= Odania::Site.active.where(host: request.host_with_port).first
			end

			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)
				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

			# Thanks to https://github.com/mbleigh/acts-as-taggable-on
			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
		end
	end
end

{'fraction_non_alphanumeric': 0.1041562343515273, 'fraction_numerical': 0.012018027040560842, 'mean_word_length': 3.2875536480686693, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6597213', 'n_tokens_mistral': 854, 'n_tokens_neox': 689, 'n_words': 151}