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

Move the links decision to helper.

parent 5d25f3d9
...@@ -180,6 +180,18 @@ module CommitsHelper ...@@ -180,6 +180,18 @@ module CommitsHelper
return old_lines, new_lines return old_lines, new_lines
end 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 protected
# Private: Returns a link to a person. If the person has a matching user and # Private: Returns a link to a person. If the person has a matching user and
......
...@@ -7,12 +7,7 @@ ...@@ -7,12 +7,7 @@
- if commit.description? - if commit.description?
%a.text-expander.js-toggle-button ... %a.text-expander.js-toggle-button ...
- if @repo && @repo.blob_at(commit.id, @path) = link_to_browse_code(project, commit)
= 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"
.notes_count .notes_count
- if @note_counts - 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