Commit 6b121aa5 authored by Marin Jankovski's avatar Marin Jankovski

Move the links decision to helper.

parent 5d25f3d9
......@@ -180,6 +180,18 @@ module CommitsHelper
return old_lines, new_lines
end
def link_to_browse_code(project, commit)
if current_controller?(:projects, :commits)
if @repo.blob_at(commit.id, @path)
link_to "Browse File »", project_blob_path(project, tree_join(commit.id, @path)), class: "pull-right"
else
link_to "Browse Dir »", project_tree_path(project, tree_join(commit.id, @path)), class: "pull-right"
end
else
link_to "Browse Code »", project_tree_path(project, commit), class: "pull-right"
end
end
protected
# Private: Returns a link to a person. If the person has a matching user and
......
......@@ -7,12 +7,7 @@
- if commit.description?
%a.text-expander.js-toggle-button ...
- if @repo && @repo.blob_at(commit.id, @path)
= link_to "Browse File »", project_blob_path(project, tree_join(commit.id, @path)), class: "pull-right"
- elsif @path.blank?
= link_to "Browse Code »", project_tree_path(project, commit), class: "pull-right"
- else
= link_to "Browse Dir »", project_tree_path(project, tree_join(commit.id, @path)), class: "pull-right"
= link_to_browse_code(project, commit)
.notes_count
- if @note_counts
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment