Add download_snippet_path helper
This commit is contained in:
parent
2b3fc5e624
commit
0ca6ff67e4
3 changed files with 13 additions and 5 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue