This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
commit 216998ca8cccb4d9d7365a65d7ee73da2984f5cf
tree 50b9d7f19ab992e6ca1aefd63fc431458a39507b
parent 869981b5e579b69ee245e05cd43be0c657fa69dc
tree 50b9d7f19ab992e6ca1aefd63fc431458a39507b
parent 869981b5e579b69ee245e05cd43be0c657fa69dc
| name | age | message | |
|---|---|---|---|
| |
MIT-LICENSE | Sun May 04 10:46:42 -0700 2008 | |
| |
README | Tue May 27 21:47:25 -0700 2008 | |
| |
Rakefile | Sun May 04 10:46:42 -0700 2008 | |
| |
generators/ | Tue May 27 21:35:16 -0700 2008 | |
| |
init.rb | Sun May 04 10:46:42 -0700 2008 | |
| |
install.rb | Sun May 04 10:46:42 -0700 2008 | |
| |
lib/ | Fri Nov 21 15:04:17 -0800 2008 | |
| |
tasks/ | Sun May 04 10:46:42 -0700 2008 | |
| |
test/ | Sun May 04 10:46:42 -0700 2008 | |
| |
uninstall.rb | Sun May 04 10:46:42 -0700 2008 |
README
SimpleNav
=========
SimpleNav is a plugin that provides helpers the make navigation display simple.
It breaks down navigation into 3 parts:
1. The Links that your site has for navigation
(all of them, regardless if they are going to show up on every request)
2. The order to display them for this request. This order can be any subset of the above list.
3. The process to select the tab that is currently marked with the "selected" css class
(this part is broken into a basic and advanced version)
Once you have configured the 3 parts, you can just call
nav_links anywhere in your view to get your nav ul:
<ul>
<li><a href="/home">Home</a></li>
<li class="selected"><a href="/login">Login</a></li>
</ul>
To generate your NavigationHelper, run:
./script/generate nav_helper <helper_name>
where <helper_name> is "navigation" or what ever word you want to use (w/o the "helper" word)
The generated helper is documented with the method stubs for the above 3 parts
Namespaces
==========
If you are upgrading from a previous version of SimpleNav, you need to add
a namespace parameter as the last parameter of every helper in your
navigation helper. Example:
OLD:
def nav_list
def nav_selection_advanced(controller, action)
NEW:
def nav_list(namespace)
def nav_selection_advanced(controller, action, namespace)
Every nav helper method takes a "namespace" parameter as its last or only parameter.
The namespace parameter can be used to differentiate between different sets of
navigation links. (i.e. main nav, and sub nav)
If you only have 1 set of nav links, ignore the namespace parameter.
If you have multiple sets of links, you can pass the namespace to
the "nav_links" method to get the appropriate links for that namespace.
Namespaces should be symbols or strings, just be consistent.
Example
=======
Here is an example of a nav helper that is being used on my blog:
module NavigationHelper
include SimpleNavHelper
def nav_list
{
:blog => {:text => "blog", :href => '/', :class => []},
:resources => {:text => "resources", :href => resources_path, :class => []},
:about => {:text => "about", :href => about_path, :class => []},
:admin => {:text => "admin", :href => admin_path, :class => ["right"]}
}
end
def nav_order
[:blog, :resources, :about, :admin]
end
def nav_selection_hash(controller, action)
{
:pages => {[:error_404, :error_500] => :false, :else => action},
:posts => {[:index, :show, :search, :tags] => :blog},
:links => {:resources => :resources},
:else => :admin
}
end
end







