public
Description: The open source social networking platform in Ruby on Rails from the author of RailsSpace
Homepage: http://insoshi.com
Clone URL: git://github.com/insoshi/insoshi.git
Decent general menu generation
Michael Hartl (author)
Tue Feb 19 17:06:53 -0800 2008
commit  657e9a1eab47418dacf73e36cb41da2229f05901
tree    f2bf042eab282c82fe67852566f217c3585b86a6
parent  bf4704a52a8fe1ec2a07f91e2f1835bff34b975c
...
8
9
10
11
 
12
...
8
9
10
 
11
12
0
@@ -8,4 +8,4 @@ class ApplicationController < ActionController::Base
0
   # See ActionController::RequestForgeryProtection for details
0
   # Uncomment the :secret if you're not using the cookie session store
0
   protect_from_forgery # :secret => '71a8c82e6d248750397d166001c5e308'
0
-end
0
+end
0
\ No newline at end of file
...
1
2
3
 
 
4
5
6
7
8
9
10
11
12
13
14
15
16
...
1
2
 
3
4
5
6
7
8
9
10
 
 
 
 
11
12
13
0
@@ -1,16 +1,13 @@
0
 class PeopleController < ApplicationController
0
   
0
-
0
+
0
+
0
   # render new.rhtml
0
   def new
0
   end
0
 
0
   def create
0
     cookies.delete :auth_token
0
- # protects against session fixation attacks, wreaks havoc with
0
- # request forgery protection.
0
- # uncomment at your own risk
0
- # reset_session
0
     @person = Person.new(params[:person])
0
     @person.save
0
     if @person.errors.empty?
...
1
2
 
 
 
 
 
 
 
 
 
3
...
1
2
3
4
5
6
7
8
9
10
11
12
0
@@ -1,3 +1,12 @@
0
 # Methods added to this helper will be available to all templates in the application.
0
 module ApplicationHelper
0
+ def menu
0
+ [{ :content => "Home", :href => home_url },
0
+ { :content => "People", :href => people_url }]
0
+ end
0
+
0
+ def menu_link_to(link, options = {})
0
+ options.merge!({ :id => "current" }) if current_page?(link[:href])
0
+ link_to(link[:content], link[:href], options)
0
+ end
0
 end
...
22
23
24
25
26
27
28
29
 
 
 
30
31
32
...
43
44
45
46
47
48
49
...
52
53
54
55
56
57
58
...
22
23
24
 
 
 
 
 
25
26
27
28
29
30
...
41
42
43
 
44
45
46
...
49
50
51
 
52
53
54
0
@@ -22,11 +22,9 @@
0
         
0
         <div id="navcontainer">
0
           <ul id="navlist">
0
- <li id="active" class="" ><a href="#" id="current">Item one</a></li>
0
- <li class=""><a href="#" >Item two</a></li>
0
- <li class=""><a href="#" >Item three</a></li>
0
- <li class=""><a href="#" >Item four</a></li>
0
- <li class=""><a href="#" >Item five</a></li>
0
+ <%- menu.each do |link| -%>
0
+ <li><%= menu_link_to link %></li>
0
+ <%- end -%>
0
           </ul>
0
         </div>
0
       </div>
0
@@ -43,7 +41,6 @@
0
       </div>
0
       <div class="column span-6 last">
0
         <h3>Right</h3>
0
- <div class="box">
0
           <h4>
0
             <%- if logged_in? -%>
0
               <%= link_to "Sign out", logout_path %>
0
@@ -52,7 +49,6 @@
0
               <%= link_to "Sign up", signup_path %>
0
             <%- end -%>
0
           </h4>
0
- </div>
0
         <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
0
         </p>
0
       </div>
...
1
2
3
4
 
5
6
7
 
8
9
10
...
1
2
3
 
4
5
6
7
8
9
10
11
0
@@ -1,10 +1,11 @@
0
 ActionController::Routing::Routes.draw do |map|
0
   map.resources :people
0
   map.resource :session
0
-
0
+
0
   map.signup '/signup', :controller => 'people', :action => 'new'
0
   map.login '/login', :controller => 'sessions', :action => 'new'
0
   map.logout '/logout', :controller => 'sessions', :action => 'destroy'
0
+ map.home '/', :controller => 'home'
0
 
0
   # The priority is based upon order of creation: first created -> highest priority.
0
 

Comments

    No one has commented yet.