AgileMantis / agile-mantis-navigation

Rails plugin: Site navigation via Controller Class Methods and one helper tag (Rails 2.2.2, Ruby 1.8.6)

This URL has Read+Write access

agile-mantis-navigation / plugins / agile_mantis_navigation / README
100644 63 lines (48 sloc) 2.647 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
AgileMantisNavigation
=====================
 
Site navigation via Controller Class Methods and one helper tag. No config files or hassling with mulitple links sprinkled across many views.
Sample controllers and CSS file included.
 
Features:
1 - Sort order, explicit or default of alphabetic.
2 - Security to determine (at time of render, not during app load), if a link should be rendered or not.
3 - Support for different css when user is "on" one of the page links (e.g. to remove underline, bold, change tab background, change hover, etc.)
4 - Visual seperators, or not, your choice (html or text)
5 - Support of 'link_to' helper, with both 'options' and 'html_options'
6 - Simple link definitions, if desired, or complex definitions.
7 - Auto discovery of links via Controller Class Methods upon initializaiton, no config files.
8 - Links defined in the controllers, a logical place to manage actions and their links.
9 - Support for Namespace Controllers
 
Examples
========
 
# Example: A simple link to the Gallery controler, index view:
def self.agile_mantis_navigation_primary
    { :name => 'Our Gallery' }
end
 
# Produces:
<div class="agile_mantis_navigation"><ul><li><a href="/gallery">Our Gallery</a></li></ul></div>
 
# If the Browser is 'on' the view, the link looks like:
<a href="/gallery" class="on">Our Gallery</a>
 
# Example: Multiple links, via an Array. Explicit sort order and view definition:
def self.agile_mantis_navigation_primary
    links = Array.new
    links << { :name => 'About Us', :sort_order => 1, :link_to_options => { :action => 'about' } }
    links << { :name => 'Terms & Conditions', :sort_order => 99999, :link_to_options => { :action => 'terms' } }
end
 
# Security example:
def self.link_allowed_method
  true # Or custom logic
end
 
def self.agile_mantis_navigation_primary
  { :name => 'Admin Page', :permission => :link_allowed_method }
end
 
 
 
Installation
============
1) Drop plugin in plugins folder
2) Add helper tag to layout:
   - No separator: <%= agile_mantis_navigation_links %>
   - Separator: <%= agile_mantis_navigation_links(" | ") %> Replace pipe with text or html
3) Add CSS tags for a custom look/feel (see sample_app\public\stylesheets\agile_mantis_navigation.css for examples and tag names)
4) To override default sort order and use the :sort_order option, add the following to environment.rb
   AGILE_MANTIS_NAVIGATION_PRIMARY_SORT_ORDER = :use_sort_order_symbol
5) Add links to controller methods self.agile_mantis_navigation_primary
 
 
Copyright (c) 2009 [Ledsworth Consluting LLC], released under the MIT license