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 869981b5e579b69ee245e05cd43be0c657fa69dc
tree 3ff7a860fcad8749f61396effff111c1ff80c05c
parent a829ab1a08d611222750892b1b3d2f48986a385c
tree 3ff7a860fcad8749f61396effff111c1ff80c05c
parent a829ab1a08d611222750892b1b3d2f48986a385c
| name | age | message | |
|---|---|---|---|
| |
MIT-LICENSE | ||
| |
README | ||
| |
Rakefile | ||
| |
generators/ | ||
| |
init.rb | ||
| |
install.rb | ||
| |
lib/ | ||
| |
tasks/ | ||
| |
test/ | ||
| |
uninstall.rb |
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








