Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2012-11-02 01:58:13 +0400
committerRobert Speicher <rspeicher@gmail.com>2012-11-02 01:58:13 +0400
commite60185699b0cd34fe3ae37db6db318478232c84b (patch)
tree74f20706aa728164b70ca9fc3079eefd215c3d8a /app/helpers/tree_helper.rb
parentb1be377fb0b5e76fc1b0d78700eb3e714b66f1c2 (diff)
Add 'breadcrumbs' helper for Commit breadcrumb links
Closes #1731
Diffstat (limited to 'app/helpers/tree_helper.rb')
-rw-r--r--app/helpers/tree_helper.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/app/helpers/tree_helper.rb b/app/helpers/tree_helper.rb
index 4fe87a25554..0f2b695e0ad 100644
--- a/app/helpers/tree_helper.rb
+++ b/app/helpers/tree_helper.rb
@@ -67,4 +67,29 @@ module TreeHelper
can?(current_user, :push_code, @project)
end
end
+
+ # Breadcrumb links for a Project and, if applicable, a tree path
+ def breadcrumbs
+ return unless @project && @ref
+
+ # Add the root project link and the arrow icon
+ crumbs = content_tag(:li) do
+ content_tag(:span, nil, class: 'arrow') +
+ link_to(@project.name, project_commits_path(@project, @ref))
+ end
+
+ if @path
+ parts = @path.split('/')
+
+ parts.each_with_index do |part, i|
+ crumbs += content_tag(:span, '/', class: 'divider')
+ crumbs += content_tag(:li) do
+ # The text is just the individual part, but the link needs all the parts before it
+ link_to part, project_commits_path(@project, tree_join(@ref, parts[0..i].join('/')))
+ end
+ end
+ end
+
+ crumbs.html_safe
+ end
end