diff --git a/tracks/app/helpers/application_helper.rb b/tracks/app/helpers/application_helper.rb index 3f5822b9..44c7ece2 100644 --- a/tracks/app/helpers/application_helper.rb +++ b/tracks/app/helpers/application_helper.rb @@ -32,5 +32,29 @@ module ApplicationHelper def urlize(name) name.to_s.gsub(/ /, "_") end - + + # Replicates the link_to method but also checks request.request_uri to find + # current page. If that matches the name parameter, the link is marked + # id = "current" + # + def navigation_link(name, options = {}, html_options = nil, *parameters_for_method_reference) + curr_path = request.request_uri.to_s + if curr_path =~ /([a-z]+)$/ + curr_page = $& + elsif curr_path == "/" + curr_page = "home" + end + + id_tag = (curr_page == name.downcase) ? " id=\"current\"" : "" + + if html_options + html_options = html_options.stringify_keys + convert_options_to_javascript!(html_options) + tag_options = tag_options(html_options) + else + tag_options = nil + end + url = options.is_a?(String) ? options : self.url_for(options, *parameters_for_method_reference) + "#{name || url}" + end end diff --git a/tracks/app/views/layouts/standard.rhtml b/tracks/app/views/layouts/standard.rhtml index 2897f3fe..d5174262 100644 --- a/tracks/app/views/layouts/standard.rhtml +++ b/tracks/app/views/layouts/standard.rhtml @@ -28,15 +28,15 @@