Commit 0ca6ff67 authored by Douwe Maan's avatar Douwe Maan

Add download_snippet_path helper

parent 2b3fc5e6
...@@ -118,15 +118,15 @@ module BlobHelper ...@@ -118,15 +118,15 @@ module BlobHelper
icon("#{file_type_icon_class('file', mode, name)} fw") icon("#{file_type_icon_class('file', mode, name)} fw")
end end
def blob_raw_url(params = {}) def blob_raw_url
if @snippet if @snippet
if @snippet.project_id if @snippet.project_id
raw_namespace_project_snippet_path(@project.namespace, @project, @snippet, params) raw_namespace_project_snippet_path(@project.namespace, @project, @snippet)
else else
raw_snippet_path(@snippet, params) raw_snippet_path(@snippet)
end end
elsif @blob elsif @blob
namespace_project_raw_path(@project.namespace, @project, @id, params) namespace_project_raw_path(@project.namespace, @project, @id)
end end
end end
......
...@@ -8,6 +8,14 @@ module SnippetsHelper ...@@ -8,6 +8,14 @@ module SnippetsHelper
end end
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 # Return the path of a snippets index for a user or for a project
# #
# @returns String, path to snippet index # @returns String, path to snippet index
......
...@@ -18,6 +18,6 @@ ...@@ -18,6 +18,6 @@
= copy_blob_source_button(blob) = copy_blob_source_button(blob)
= open_raw_blob_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 = render 'projects/blob/content', blob: blob
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