2014-07-18 19:33:42 -07:00
|
|
|
module NavigationHelpers
|
2014-07-24 00:16:33 -06:00
|
|
|
def path_to(page_name)
|
|
|
|
append_root = false
|
|
|
|
case page_name
|
|
|
|
when /^landing$/i
|
|
|
|
path = :root
|
|
|
|
when /^confirmation$/i
|
|
|
|
path = "/conferences/bikebike/#{@last_conference.slug}/register/confirm/#{@last_registration.confirmation_token}"
|
|
|
|
when /^pay registration$/i
|
|
|
|
path = "/conferences/bikebike/#{@last_conference.slug}/register/pay-registration/#{@last_registration.confirmation_token}"
|
2014-07-24 22:43:26 -06:00
|
|
|
when /^confirm paypal$/i
|
2014-07-24 21:12:39 -06:00
|
|
|
path = "/conferences/bikebike/#{@last_conference.slug}/register/paypal-confirm/#{@last_registration.payment_confirmation_token}"
|
2014-07-24 22:43:26 -06:00
|
|
|
when /^cancel paypal$/i
|
2014-07-24 21:12:39 -06:00
|
|
|
path = "/conferences/bikebike/#{@last_conference.slug}/register/paypal-cancel/#{@last_registration.confirmation_token}"
|
2014-07-24 00:16:33 -06:00
|
|
|
when /^translation list$/i
|
|
|
|
path = '/translations/'
|
|
|
|
when /^(.+) translations?$/i
|
|
|
|
path = '/translations/' + get_language_code(Regexp.last_match(1))
|
|
|
|
when /^organization list$/i
|
|
|
|
path = '/organizations/'
|
|
|
|
end
|
2014-07-18 19:33:42 -07:00
|
|
|
|
2014-07-24 00:16:33 -06:00
|
|
|
if path.is_a?(Symbol)
|
|
|
|
begin
|
|
|
|
path = self.send((path.to_s + '_url').to_sym).gsub(/^http:\/\/.+?(\/.*)$/, '\1')
|
|
|
|
rescue Object => e
|
|
|
|
raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
|
|
|
|
"#{path}_url\n" +
|
|
|
|
"Now, go and add a mapping in #{__FILE__}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
path
|
|
|
|
end
|
2014-07-18 19:33:42 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
World(NavigationHelpers)
|