From 959c2c2f5385d081c1250d360a379ee5b2561adb Mon Sep 17 00:00:00 2001 From: bsag Date: Sun, 16 Apr 2006 18:39:00 +0000 Subject: [PATCH] The current page is now marked in the navigation bar at the top with a black bottom border and black text (as when the link is hovered over). I've also added accesskeys for the notes page (alt/ctrl n) and the preferences page (alt/ctrl u for user preferences). Fixes #231 git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@224 a4c988fc-2ded-0310-b66e-134b36920a42 --- tracks/app/helpers/application_helper.rb | 26 +++++++++++++++++++++++- tracks/app/views/layouts/standard.rhtml | 14 ++++++------- tracks/config/routes.rb | 2 +- 3 files changed, 33 insertions(+), 9 deletions(-) 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 @@