2016-12-26 22:44:03 -05:00
|
|
|
module WikiHelper
|
|
|
|
# Produces a pure text breadcrumb for a given page.
|
|
|
|
#
|
|
|
|
# page_slug - The slug of a WikiPage object.
|
|
|
|
#
|
|
|
|
# Returns a String composed of the capitalized name of each directory and the
|
|
|
|
# capitalized name of the page itself.
|
|
|
|
def breadcrumb(page_slug)
|
2017-06-21 09:48:12 -04:00
|
|
|
page_slug.split('/')
|
|
|
|
.map { |dir_or_page| WikiPage.unhyphenize(dir_or_page).capitalize }
|
|
|
|
.join(' / ')
|
2016-12-26 22:44:03 -05:00
|
|
|
end
|
2017-08-16 08:13:34 -04:00
|
|
|
|
|
|
|
def wiki_breadcrumb_dropdown_links(page_slug)
|
|
|
|
page_slug_split = page_slug.split('/')
|
|
|
|
page_slug_split.pop(1)
|
|
|
|
current_slug = ""
|
|
|
|
page_slug_split
|
|
|
|
.map do |dir_or_page|
|
2017-09-06 06:55:23 -04:00
|
|
|
current_slug = "#{current_slug}#{dir_or_page}/"
|
2017-08-16 08:13:34 -04:00
|
|
|
add_to_breadcrumb_dropdown link_to(WikiPage.unhyphenize(dir_or_page).capitalize, project_wiki_path(@project, current_slug)), location: :after
|
|
|
|
end
|
|
|
|
end
|
2016-12-26 22:44:03 -05:00
|
|
|
end
|