2009-05-22 14:13:46 +02:00
|
|
|
# Methods added to this helper will be available to all templates in the application.
|
|
|
|
module ApplicationHelper
|
2009-06-11 13:05:09 +02:00
|
|
|
|
|
|
|
def breadcrumbs(sep = "/", include_home = true)
|
|
|
|
levels = request.path.split('?')[0].split('/')
|
|
|
|
levels.delete_at(0)
|
|
|
|
|
|
|
|
#links = "You are here: "
|
|
|
|
links = content_tag('a', "HOME", :href => "/") if include_home
|
|
|
|
|
2010-08-07 13:30:53 +02:00
|
|
|
nocrumb = ["collections", "albums", "photos", "tags", "new", "edit", "tags"]
|
2009-06-11 13:05:09 +02:00
|
|
|
|
|
|
|
levels.each_with_index do |level, index|
|
2009-06-16 15:51:06 +02:00
|
|
|
level = level.gsub(/^[0-9]+\-/,"") #if levels[index-1] == "photos"
|
2009-06-11 13:05:09 +02:00
|
|
|
level = level.gsub("-", " ")
|
|
|
|
if index+1 == levels.length
|
2009-06-30 21:24:06 +02:00
|
|
|
#links += " #{sep} #{level.upcase}" unless nocrumb.include?(level)
|
2010-07-28 00:27:47 +02:00
|
|
|
elsif !nocrumb.include?(level)
|
|
|
|
links += " " + sep + " "
|
|
|
|
links += content_tag('a', level.upcase, :href => '/'+levels[0..index].join('/'))
|
2009-06-11 13:05:09 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-06-30 21:24:06 +02:00
|
|
|
content_tag("div", links, :id => "breadcrumb")
|
2009-06-11 13:05:09 +02:00
|
|
|
end
|
2009-05-22 14:13:46 +02:00
|
|
|
end
|