Changeset 1785

Show
Ignore:
Timestamp:
09/10/08 18:00:45 (4 months ago)
Author:
dbryson
Message:


Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • community_hive/trunk/community_hive_web/app/helpers/application_helper.rb

    r1720 r1785  
    22module ApplicationHelper 
    33   
    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] 
    208  end 
    219   
    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("&nbsp;|&nbsp;").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("&nbsp;|&nbsp;").to_s 
     61     
     62    content_tag(:p,"#{un}: #{links}",:class => 'welcome') 
    2663  end 
    2764   
  • community_hive/trunk/community_hive_web/app/helpers/users_helper.rb

    r1620 r1785  
    11module UsersHelper 
     2   
    23  def true_false_tag(value) 
    34    if value 
     
    78    end 
    89  end 
     10   
     11  def bee_info(user) 
     12    info = "n/a" 
     13    info = "#{user.host}" unless user.host.blank? 
     14    info << " (#{user.ip})" unless user.ip.blank? 
     15    info 
     16  end 
     17   
    918   
    1019  def change_access_key(user)