2014-09-14 16:00:41 -07:00
|
|
|
module NavigationHelpers
|
2015-08-18 22:18:29 -07:00
|
|
|
def path_to(path)
|
|
|
|
path = path.to_sym
|
|
|
|
|
|
|
|
case path
|
2014-09-14 16:00:41 -07:00
|
|
|
when /^landing$/i
|
2015-04-01 18:02:51 -07:00
|
|
|
path = :home
|
2014-09-14 16:00:41 -07:00
|
|
|
when /^registration$/i
|
2015-08-18 22:18:29 -07:00
|
|
|
path = "/conferences/#{@last_conference.slug}/register/"
|
2015-09-14 21:16:22 -07:00
|
|
|
when /^edit conference$/i
|
|
|
|
path = "/conferences/#{@last_conference.slug}/edit/"
|
2015-08-18 22:18:29 -07:00
|
|
|
when /^(workshops|stats|broadcast)$/i
|
|
|
|
path = "/conferences/#{@last_conference.slug}/#{path}/"
|
2015-10-11 08:56:02 -07:00
|
|
|
when /^(stats.xls)$/i
|
|
|
|
path = "/conferences/#{@last_conference.slug}/stats.xls"
|
2014-09-14 16:00:41 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
if path.is_a?(Symbol)
|
|
|
|
begin
|
2015-08-18 22:18:29 -07:00
|
|
|
path = Rails.application.routes.url_helpers.send("#{path}_path".to_sym)
|
2014-09-14 16:00:41 -07:00
|
|
|
rescue Object => e
|
2015-08-18 22:18:29 -07:00
|
|
|
raise "Can't find mapping from \"#{path}\" to a path."
|
2014-09-14 16:00:41 -07:00
|
|
|
end
|
|
|
|
end
|
2015-08-18 22:18:29 -07:00
|
|
|
|
|
|
|
if path.blank?
|
|
|
|
raise "Can't find mapping from \"#{page_name}\" to a path."
|
|
|
|
end
|
|
|
|
|
|
|
|
return path
|
2014-09-14 16:00:41 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
World(NavigationHelpers)
|