public
Description: Rails Plugin: Simple site navigation helper
Homepage:
Clone URL: git://github.com/arya/simple_nav.git
name age message
file MIT-LICENSE Sun May 04 10:46:42 -0700 2008 initial version of simple_nav, no tests yet, fu... [Arya Asemanfar]
file README Tue May 27 21:47:25 -0700 2008 * Updated README [Arya Asemanfar]
file Rakefile Sun May 04 10:46:42 -0700 2008 initial version of simple_nav, no tests yet, fu... [Arya Asemanfar]
directory generators/ Tue May 27 21:35:16 -0700 2008 * added support for namespaces [Arya Asemanfar]
file init.rb Sun May 04 10:46:42 -0700 2008 initial version of simple_nav, no tests yet, fu... [Arya Asemanfar]
file install.rb Sun May 04 10:46:42 -0700 2008 initial version of simple_nav, no tests yet, fu... [Arya Asemanfar]
directory lib/ Fri Nov 21 15:04:17 -0800 2008 Rails changed the way content_tag works (the re... [Arya Asemanfar]
directory tasks/ Sun May 04 10:46:42 -0700 2008 initial version of simple_nav, no tests yet, fu... [Arya Asemanfar]
directory test/ Sun May 04 10:46:42 -0700 2008 initial version of simple_nav, no tests yet, fu... [Arya Asemanfar]
file uninstall.rb Sun May 04 10:46:42 -0700 2008 initial version of simple_nav, no tests yet, fu... [Arya Asemanfar]
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