diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-05-02 08:53:29 -0500 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-05-02 08:53:29 -0500 |
commit | 0ca6ff67e438a8218ac53edd6280041d2f4b7a9c (patch) | |
tree | fe363ceb7df8961e3b32cc265f50a34cfe760c48 /app | |
parent | 2b3fc5e624bd0c8b9e1c68bf2b3741d8898cf0b0 (diff) | |
download | gitlab-ce-0ca6ff67e438a8218ac53edd6280041d2f4b7a9c.tar.gz |
Add download_snippet_path helper
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/blob_helper.rb | 8 | ||||
-rw-r--r-- | app/helpers/snippets_helper.rb | 8 | ||||
-rw-r--r-- | app/views/shared/snippets/_blob.html.haml | 2 |
3 files changed, 13 insertions, 5 deletions
diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index 5a8f615fc2d..377b080b3c6 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -118,15 +118,15 @@ module BlobHelper icon("#{file_type_icon_class('file', mode, name)} fw") end - def blob_raw_url(params = {}) + def blob_raw_url if @snippet if @snippet.project_id - raw_namespace_project_snippet_path(@project.namespace, @project, @snippet, params) + raw_namespace_project_snippet_path(@project.namespace, @project, @snippet) else - raw_snippet_path(@snippet, params) + raw_snippet_path(@snippet) end elsif @blob - namespace_project_raw_path(@project.namespace, @project, @id, params) + namespace_project_raw_path(@project.namespace, @project, @id) end end diff --git a/app/helpers/snippets_helper.rb b/app/helpers/snippets_helper.rb index 979264c9421..2fd64b3441e 100644 --- a/app/helpers/snippets_helper.rb +++ b/app/helpers/snippets_helper.rb @@ -8,6 +8,14 @@ module SnippetsHelper end end + def download_snippet_path(snippet) + if snippet.project_id + raw_namespace_project_snippet_path(@project.namespace, @project, snippet, inline: false) + else + raw_snippet_path(snippet, inline: false) + end + end + # Return the path of a snippets index for a user or for a project # # @returns String, path to snippet index diff --git a/app/views/shared/snippets/_blob.html.haml b/app/views/shared/snippets/_blob.html.haml index fd4ee840a19..9bcb4544b97 100644 --- a/app/views/shared/snippets/_blob.html.haml +++ b/app/views/shared/snippets/_blob.html.haml @@ -18,6 +18,6 @@ = copy_blob_source_button(blob) = open_raw_blob_button(blob) - = link_to icon('download'), blob_raw_url(inline: false), target: '_blank', class: "btn btn-sm has-tooltip", title: 'Download', data: { container: 'body' } + = link_to icon('download'), download_snippet_path(@snippet), target: '_blank', class: "btn btn-sm has-tooltip", title: 'Download', data: { container: 'body' } = render 'projects/blob/content', blob: blob |