diff options
author | Kia Mei Somabes <kssomabes@up.edu.ph> | 2018-07-12 10:23:00 +0800 |
---|---|---|
committer | Kia Mei Somabes <kssomabes@up.edu.ph> | 2018-07-12 10:23:00 +0800 |
commit | 9f57ae11e935d2a8a2b175d8382ed87020727845 (patch) | |
tree | 87a309a07ce9f1765700bdd062544cb3c9acc398 /app/helpers/blob_helper.rb | |
parent | 50c128944e5e65fb5124aeb790cc0f1ec06049d3 (diff) | |
download | gitlab-ce-9f57ae11e935d2a8a2b175d8382ed87020727845.tar.gz |
Set content-disposition header for single file download in repository
Diffstat (limited to 'app/helpers/blob_helper.rb')
-rw-r--r-- | app/helpers/blob_helper.rb | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index 16a8764dc41..0fec8e891b7 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -114,7 +114,7 @@ module BlobHelper icon("#{file_type_icon_class('file', mode, name)} fw") end - def blob_raw_url(only_path: false) + def blob_raw_url(only_path: false, inline: nil) if @build && @entry raw_project_job_artifacts_url(@project, @build, path: @entry.path, only_path: only_path) elsif @snippet @@ -124,7 +124,7 @@ module BlobHelper raw_snippet_url(@snippet, only_path: only_path) end elsif @blob - project_raw_url(@project, @id, only_path: only_path) + project_raw_url(@project, @id, only_path: only_path, inline: inline) end end @@ -226,16 +226,16 @@ module BlobHelper def open_raw_blob_button(blob) return if blob.empty? - icon = icon('file-code-o') - title = 'Open raw' - link_to icon, blob_raw_path, class: 'btn btn-sm has-tooltip', target: '_blank', rel: 'noopener noreferrer', title: title, data: { container: 'body' } + unless blob.raw_binary? || blob.stored_externally? + title = 'Open raw' + link_to icon('file-code-o'), blob_raw_url(:inline => true), class: 'btn btn-sm has-tooltip', target: '_blank', rel: 'noopener noreferrer', title: title, data: { container: 'body' } + end end - def download_button(blob) + def download_blob_button(blob) return if blob.empty? - icon = sprite_icon('download') title = 'Download' - link_to icon, blob_raw_path, download: '', class: 'btn btn-sm has-tooltip', target: '_blank', rel: 'noopener noreferrer', title: title, data: { container: 'body' } + link_to sprite_icon('download'), blob_raw_url, download: @path, class: 'btn btn-sm has-tooltip', target: '_blank', rel: 'noopener noreferrer', title: title, data: { container: 'body' } end def blob_render_error_reason(viewer) |