refactor duplication

pull/7926/head
ulferts 5 years ago
parent a749e40c45
commit f52c9b4511
No known key found for this signature in database
GPG Key ID: A205708DE1284017
  1. 18
      app/helpers/wiki_helper.rb

@ -42,13 +42,21 @@ module WikiHelper
end
def breadcrumb_for_page(page, action = nil)
related_pages = page.ancestors.reverse
if action
related_pages = page.ancestors.reverse + [page]
breadcrumb_paths(*(related_pages.map { |parent| link_to h(parent.breadcrumb_title), id: parent.title, project_id: parent.project, action: 'show' } + [action]))
else
related_pages = page.ancestors.reverse
breadcrumb_paths(*(related_pages.map { |parent| link_to h(parent.breadcrumb_title), id: parent.title, project_id: parent.project, action: 'show' } + [h(page.breadcrumb_title)]))
related_pages += [page]
end
paths = related_pages.map { |parent| link_to h(parent.breadcrumb_title), project_wiki_path(parent, parent.project) }
paths += if action
[action]
else
[h(page.breadcrumb_title)]
end
breadcrumb_paths(*paths)
end
def nl2br(content)

Loading…
Cancel
Save