mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-31 13:15:17 +01:00
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
This commit is contained in:
parent
7a9a19a563
commit
959c2c2f53
3 changed files with 33 additions and 9 deletions
|
|
@ -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)
|
||||
"<a href=\"#{url}\"#{tag_options}#{id_tag}>#{name || url}</a>"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -28,15 +28,15 @@
|
|||
</div>
|
||||
<div id="navcontainer">
|
||||
<ul id="navlist">
|
||||
<li><%= link_to( "Home", {:controller => "todo", :action => "list"}, {:accesskey=>"t", :title=>"Home"} ) %></li>
|
||||
<li><%= link_to( "Contexts", {:controller => "context", :action => "list"}, {:accesskey=>"c", :title=>"Contexts"} ) %></li>
|
||||
<li><%= link_to( "Projects", {:controller => "project", :action => "list"}, {:accesskey=>"p", :title=>"Projects"} ) %></li>
|
||||
<li><%= link_to( "Done", {:controller => "todo", :action => "completed"}, {:accesskey=>"d", :title=>"Completed"} ) %></li>
|
||||
<li><%= link_to( "Notes", {:controller => "note", :action => "index"}, :title => "Show all notes" ) %></li>
|
||||
<li><%= link_to( "Preferences", {:controller => "user", :action => "preferences"}, :title => "Show my preferences" ) %></li>
|
||||
<li><%= navigation_link("Home", {:controller => "todo", :action => "list"}, {:accesskey => "t", :title => "Home"} ) %></li>
|
||||
<li><%= navigation_link( "Contexts", {:controller => "context", :action => "list"}, {:accesskey=>"c", :title=>"Contexts"} ) %></li>
|
||||
<li><%= navigation_link( "Projects", {:controller => "project", :action => "list"}, {:accesskey=>"p", :title=>"Projects"} ) %></li>
|
||||
<li><%= navigation_link( "Done", {:controller => "todo", :action => "completed"}, {:accesskey=>"d", :title=>"Completed"} ) %></li>
|
||||
<li><%= navigation_link( "Notes", {:controller => "note", :action => "index"}, {:accesskey => "n", :title => "Show all notes"} ) %></li>
|
||||
<li><%= navigation_link( "Preferences", {:controller => "user", :action => "preferences"}, {:accesskey => "u", :title => "Show my preferences"} ) %></li>
|
||||
<li><a href="javascript:toggleAll('notes','block')" accesskey="S" title="Show all notes">Show</a></li>
|
||||
<li><a href="javascript:toggleAll('notes','none')" accesskey="H" title="Hide all notes">Hide</a></li>
|
||||
<li><%= link_to(image_tag("feed-icon", :size => "16X16", :border => 0), {:controller => "todo", :action => "feeds"}, :title => "See a list of available feeds" ) %></li>
|
||||
<li><%= navigation_link(image_tag("feed-icon", :size => "16X16", :border => 0), {:controller => "todo", :action => "feeds"}, :title => "See a list of available feeds" ) %></li>
|
||||
<% if @user.is_admin? -%>
|
||||
<li><%= link_to "Add users", :controller => "login", :action => "signup" %>
|
||||
<% end -%>
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue