Add download directory in menu
Add subdirectory params for RepositoriesController#archive
This commit is contained in:
parent
8b9da458ec
commit
e028276d34
4 changed files with 17 additions and 2 deletions
|
@ -23,7 +23,7 @@ class Projects::RepositoriesController < Projects::ApplicationController
|
|||
append_sha = false if @filename == shortname
|
||||
end
|
||||
|
||||
send_git_archive @repository, ref: @ref, format: params[:format], append_sha: append_sha
|
||||
send_git_archive @repository, ref: @ref, subdirectory: params[:subdirectory], format: params[:format], append_sha: append_sha
|
||||
rescue => ex
|
||||
logger.error("#{self.class.name}: #{ex}")
|
||||
git_not_found!
|
||||
|
|
|
@ -27,6 +27,14 @@ module ProjectsHelper
|
|||
image_tag(src, width: opts[:size], class: classes, alt: '', "data-src" => avatar)
|
||||
end
|
||||
|
||||
def is_directory
|
||||
@path.empty? ? false : true
|
||||
end
|
||||
|
||||
def get_directory_path
|
||||
@path ? "#{@path}/" : ''
|
||||
end
|
||||
|
||||
def author_content_tag(author, opts = {})
|
||||
default_opts = { author_class: 'author', tooltip: false, by_username: false }
|
||||
opts = default_opts.merge(opts)
|
||||
|
|
|
@ -31,6 +31,7 @@ module WorkhorseHelper
|
|||
|
||||
# Archive a Git repository and send it through Workhorse
|
||||
def send_git_archive(repository, **kwargs)
|
||||
kwargs.delete(:subdirectory) if kwargs[:subdirectory].nil?
|
||||
headers.store(*Gitlab::Workhorse.send_git_archive(repository, **kwargs))
|
||||
head :ok
|
||||
end
|
||||
|
|
|
@ -8,8 +8,14 @@
|
|||
%span.sr-only= _('Select Archive Format')
|
||||
= sprite_icon("arrow-down")
|
||||
%ul.dropdown-menu.dropdown-menu-right{ role: 'menu' }
|
||||
- if is_directory
|
||||
%li.dropdown-header
|
||||
#{ _('Directory') }
|
||||
%li
|
||||
= link_to project_archive_path(project, subdirectory: get_directory_path, id: tree_join(ref, archive_prefix), format: 'zip'), rel: 'nofollow', download: '' do
|
||||
%span= _('Download zip')
|
||||
%li.dropdown-header
|
||||
#{ _('Source code') }
|
||||
#{ _('Repository') }
|
||||
%li
|
||||
= link_to project_archive_path(project, id: tree_join(ref, archive_prefix), format: 'zip'), rel: 'nofollow', download: '' do
|
||||
%span= _('Download zip')
|
||||
|
|
Loading…
Reference in a new issue