| 4 | | def nav_bar |
|---|
| 5 | | b = "" |
|---|
| 6 | | b << "<li>#{link_to("Check a URL", :controller => 'main', :action => 'index')}</li>" |
|---|
| 7 | | b << "<li>#{link_to("Search URLs", :controller => 'urls', :action => 'index')}</li>" |
|---|
| 8 | | b << "<li>#{link_to("Stats", :controller => 'statistics', :action => 'index')}</li>" |
|---|
| 9 | | b << "<li>#{link_to("About", :controller => 'about', :action => 'index')}</li>" |
|---|
| 10 | | if logged_in? |
|---|
| 11 | | b << "<li>#{link_to("My Account", :controller => 'users', :action => 'myprofile')}</li>" |
|---|
| 12 | | b << "<li>#{link_to("Logout", :controller => 'account', :action => 'logout')}</li>" |
|---|
| 13 | | if current_user.admin |
|---|
| 14 | | b << "<li>#{link_to("Admin", :controller => 'users', :action => 'index')}</li>" |
|---|
| 15 | | end |
|---|
| 16 | | else |
|---|
| 17 | | b << "<li>#{link_to("Login", :controller => 'account', :action => 'login')}</li>" |
|---|
| 18 | | end |
|---|
| 19 | | b |
|---|
| | 4 | def menu |
|---|
| | 5 | home = menu_element("Submit a Url",root_path()) |
|---|
| | 6 | check = menu_element("Search Catalog",urls_path()) |
|---|
| | 7 | [home, check] |
|---|
| 22 | | def show_message |
|---|
| 23 | | [:error, :message].collect do |key| |
|---|
| 24 | | content_tag(:div, flash[key], :class => "flash flash_#{key}") unless flash[key].blank? |
|---|
| 25 | | end.join |
|---|
| | 10 | def menu_element(content, address) |
|---|
| | 11 | { :content => content, :href => address } |
|---|
| | 12 | end |
|---|
| | 13 | |
|---|
| | 14 | def menu_link_to(link, options = {}) |
|---|
| | 15 | link_to(link[:content], link[:href], options) |
|---|
| | 16 | end |
|---|
| | 17 | |
|---|
| | 18 | def menu_li(link, options = {}) |
|---|
| | 19 | klass = "n-#{link[:content].downcase}" |
|---|
| | 20 | klass += " active" if current_page?(link[:href]) |
|---|
| | 21 | content_tag(:li, menu_link_to(link, options), :class => klass) |
|---|
| | 22 | end |
|---|
| | 23 | |
|---|
| | 24 | def loginbar |
|---|
| | 25 | bar = [] |
|---|
| | 26 | if logged_in? |
|---|
| | 27 | bar << "#{current_user.login}" |
|---|
| | 28 | bar << "#{link_to('My Account',user_path)}" |
|---|
| | 29 | if current_user.admin |
|---|
| | 30 | bar << "#{link_to("Admin", :controller => 'users', :action => 'index')}" |
|---|
| | 31 | end |
|---|
| | 32 | bar << "#{link_to('Sign out', :controller => 'account', :action => 'logout')}" |
|---|
| | 33 | else |
|---|
| | 34 | bar << "#{link_to("Sign in", :controller => 'account', :action => 'login')}" |
|---|
| | 35 | end |
|---|
| | 36 | links = bar.join(" | ").to_s |
|---|
| | 37 | content_tag(:p,links,:class => 'welcome') |
|---|
| | 38 | end |
|---|
| | 39 | |
|---|
| | 40 | def menu_item(content,address) |
|---|
| | 41 | lk = link_to(content,address) |
|---|
| | 42 | "#{lk}" |
|---|
| | 43 | end |
|---|
| | 44 | |
|---|
| | 45 | def menubar |
|---|
| | 46 | bar = [] |
|---|
| | 47 | un = "" |
|---|
| | 48 | bar << menu_item("Submit a Url",root_path) |
|---|
| | 49 | bar << menu_item("Search Catalog",urls_path) |
|---|
| | 50 | |
|---|
| | 51 | if logged_in? |
|---|
| | 52 | un = "#{current_user.login}" |
|---|
| | 53 | bar << menu_item("My Account",user_path(current_user)) |
|---|
| | 54 | bar << menu_item("Admin",users_path) if current_user.admin? |
|---|
| | 55 | bar << menu_item("Sign out", logout_path) |
|---|
| | 56 | else |
|---|
| | 57 | bar << menu_item("Sign in", login_path) |
|---|
| | 58 | end |
|---|
| | 59 | |
|---|
| | 60 | links = bar.join(" | ").to_s |
|---|
| | 61 | |
|---|
| | 62 | content_tag(:p,"#{un}: #{links}",:class => 'welcome') |
|---|