GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Description: A Ruby on Rails-based OpenID server for all ya identity providers out there. It is pretty close to the current OpenID specifications and supports SReg, AX (only fetch requests, yet) and PAPE
Homepage: http://dennisbloete.de/projects/masquerade/
Clone URL: git://github.com/dbloete/masquerade.git
Click here to lend your support to: masquerade and make a donation at www.pledgie.com !
commit  aea5cb03125095c5e8f7b54405a7386abe5d85ed
tree    573eb7850e2369067561872281c0ad1883ad859e
parent  1f9c844a65a72eb9fe091a51966730643cb1f3e9
masquerade / app / helpers / application_helper.rb
100644 63 lines (55 sloc) 2.246 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
module ApplicationHelper
  
  def page_title
    @page_title ? "#{@page_title} | #{APP_CONFIG['name']}" : APP_CONFIG['name']
  end
  
  def label_tag(field, text = nil, options = {})
    content_tag :label, text ? text : field.to_s.humanize, options.reverse_merge(:for => field.to_s)
  end
  
  # Is the current page an identity page? This is used to display
  # further information (like the endoint url) in the <head>
  def identity_page?
    active_page? 'accounts' => ['show']
  end
  
  # Extracts the hostname from the given url, which is used to
  # display the name of the requesting website to the user
  def extract_host(u)
    URI.parse(u).host
  end
  
  # Custom label names for request properties (like SReg data)
  def property_label_text(property)
    case property.to_sym
    when :fullname then 'Full name'
    when :dob then 'Birth date'
    when :address_business then 'Address'
    when :address_additional then 'Additional'
    when :address_additional_business then 'Additional'
    when :postcode_business then 'Postcode'
    when :city_business then 'City'
    when :state_business then 'State'
    when :country_business then 'Country'
    when :im_aim then 'AIM'
    when :im_icq then 'ICQ'
    when :im_msn then 'MSN'
    when :im_yahoo then 'Yahoo'
    when :im_jabber then 'Jabber'
    when :im_skype then 'Skype'
    when :image_default then 'Image URL'
    when :web_default then 'Website URL'
    when :web_blog then 'Blog URL'
    else property.to_s.humanize
    end
  end
  
  # Renders a navigation element and marks it as active where
  # appropriate. See active_page? for details
  def nav(name, url, pages = nil, active = false)
    content_tag :li, link_to(name, url), :class => (active || (pages && active_page?(pages)) ? 'act' : nil)
  end
  
  # Takes a hash with pages and tells whether the current page is among them.
  # The keys must be controller names and their value must be an array of
  # action names. If the array is empty, every action is supposed to be valid.
  def active_page?(pages = {})
    is_active = pages.include?(params[:controller])
    is_active = pages[params[:controller]].include?(params[:action]) if is_active && !pages[params[:controller]].empty?
    is_active
  end
  
end