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 @@
- - <%= link_to( "Home", {:controller => "todo", :action => "list"}, {:accesskey=>"t", :title=>"Home"} ) %>
- - <%= link_to( "Contexts", {:controller => "context", :action => "list"}, {:accesskey=>"c", :title=>"Contexts"} ) %>
- - <%= link_to( "Projects", {:controller => "project", :action => "list"}, {:accesskey=>"p", :title=>"Projects"} ) %>
- - <%= link_to( "Done", {:controller => "todo", :action => "completed"}, {:accesskey=>"d", :title=>"Completed"} ) %>
- - <%= link_to( "Notes", {:controller => "note", :action => "index"}, :title => "Show all notes" ) %>
- - <%= link_to( "Preferences", {:controller => "user", :action => "preferences"}, :title => "Show my preferences" ) %>
+ - <%= navigation_link("Home", {:controller => "todo", :action => "list"}, {:accesskey => "t", :title => "Home"} ) %>
+ - <%= navigation_link( "Contexts", {:controller => "context", :action => "list"}, {:accesskey=>"c", :title=>"Contexts"} ) %>
+ - <%= navigation_link( "Projects", {:controller => "project", :action => "list"}, {:accesskey=>"p", :title=>"Projects"} ) %>
+ - <%= navigation_link( "Done", {:controller => "todo", :action => "completed"}, {:accesskey=>"d", :title=>"Completed"} ) %>
+ - <%= navigation_link( "Notes", {:controller => "note", :action => "index"}, {:accesskey => "n", :title => "Show all notes"} ) %>
+ - <%= navigation_link( "Preferences", {:controller => "user", :action => "preferences"}, {:accesskey => "u", :title => "Show my preferences"} ) %>
- Show
- Hide
- - <%= link_to(image_tag("feed-icon", :size => "16X16", :border => 0), {:controller => "todo", :action => "feeds"}, :title => "See a list of available feeds" ) %>
+ - <%= navigation_link(image_tag("feed-icon", :size => "16X16", :border => 0), {:controller => "todo", :action => "feeds"}, :title => "See a list of available feeds" ) %>
<% if @user.is_admin? -%>
- <%= link_to "Add users", :controller => "login", :action => "signup" %>
<% end -%>
diff --git a/tracks/config/routes.rb b/tracks/config/routes.rb
index 534a40e9..6b867bc9 100644
--- a/tracks/config/routes.rb
+++ b/tracks/config/routes.rb
@@ -23,7 +23,7 @@ ActionController::Routing::Routes.draw do |map|
map.connect 'signup', :controller => 'login', :action => 'signup'
# ToDo Routes
- map.connect 'completed', :controller => 'todo', :action => 'completed'
+ map.connect 'done', :controller => 'todo', :action => 'completed'
map.connect 'delete/todo/:id', :controller =>'todo', :action => 'destroy'
# Context Routes