downloads: added more archive options that we support. Exposing this to users so they actually
know we support more then .zip downloads.
This commit is contained in:
parent
26bc071ae3
commit
ca1ac56a3b
7 changed files with 57 additions and 20 deletions
|
|
@ -86,6 +86,7 @@ from rhodecode.lib.utils2 import (
|
|||
from rhodecode.lib.markup_renderer import MarkupRenderer, relative_links
|
||||
from rhodecode.lib.vcs.exceptions import CommitDoesNotExistError
|
||||
from rhodecode.lib.vcs.backends.base import BaseChangeset, EmptyCommit
|
||||
from rhodecode.lib.vcs.conf.settings import ARCHIVE_SPECS
|
||||
from rhodecode.lib.index.search_utils import get_matching_line_offsets
|
||||
from rhodecode.config.conf import DATE_FORMAT, DATETIME_FORMAT
|
||||
from rhodecode.model.changeset_status import ChangesetStatusModel
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ BACKENDS = {
|
|||
|
||||
|
||||
ARCHIVE_SPECS = [
|
||||
('tbz2', 'application/x-bzip2', 'tbz2'),
|
||||
('tbz2', 'application/x-bzip2', '.tbz2'),
|
||||
('tbz2', 'application/x-bzip2', '.tar.bz2'),
|
||||
|
||||
('tgz', 'application/x-gzip', '.tgz'),
|
||||
|
|
|
|||
|
|
@ -262,10 +262,17 @@ input[type="button"] {
|
|||
}
|
||||
|
||||
|
||||
.btn-action-switcher-container{
|
||||
.btn-action-switcher-container {
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
right: 0;
|
||||
|
||||
&.left-align {
|
||||
left: 0;
|
||||
}
|
||||
&.right-align {
|
||||
right: 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.btn-action-switcher {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
<i class="icon-down"></i>
|
||||
</a>
|
||||
|
||||
<div class="btn-action-switcher-container">
|
||||
<div class="btn-action-switcher-container right-align">
|
||||
<ul class="btn-action-switcher" role="menu" style="min-width: 200px">
|
||||
<li>
|
||||
<a class="action_button" href="${h.route_path('repo_files_upload_file',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path)}">
|
||||
|
|
|
|||
|
|
@ -516,7 +516,7 @@
|
|||
<i class="icon-down"></i>
|
||||
</a>
|
||||
|
||||
<div class="btn-action-switcher-container" id="update-commits-switcher">
|
||||
<div class="btn-action-switcher-container right-align" id="update-commits-switcher">
|
||||
<ul class="btn-action-switcher" role="menu" style="min-width: 300px;">
|
||||
<li>
|
||||
<a href="#forceUpdate" onclick="updateController.forceUpdateCommits(this); return false">
|
||||
|
|
|
|||
|
|
@ -184,14 +184,37 @@
|
|||
${h.link_to(_('Enable downloads'),h.route_path('edit_repo',repo_name=c.repo_name, _anchor='repo_enable_downloads'))}
|
||||
% endif
|
||||
% else:
|
||||
<span class="enabled">
|
||||
<div class="enabled pull-left" style="margin-right: 10px">
|
||||
|
||||
<a id="archive_link" class="btn btn-small" href="${h.route_path('repo_archivefile',repo_name=c.rhodecode_db_repo.repo_name, fname=c.rhodecode_db_repo.landing_ref_name+'.zip')}">
|
||||
<i class="icon-download"></i>
|
||||
${c.rhodecode_db_repo.landing_ref_name}.zip
|
||||
## replaced by some JS on select
|
||||
</a>
|
||||
</span>
|
||||
<div class="btn-group btn-group-actions">
|
||||
<a class="archive_link btn btn-small" data-ext=".zip" href="${h.route_path('repo_archivefile',repo_name=c.rhodecode_db_repo.repo_name, fname=c.rhodecode_db_repo.landing_ref_name+'.zip')}">
|
||||
<i class="icon-download"></i>
|
||||
${c.rhodecode_db_repo.landing_ref_name}.zip
|
||||
## replaced by some JS on select
|
||||
</a>
|
||||
|
||||
<a class="tooltip btn btn-primary" style="margin-left: -1px" data-toggle="dropdown" aria-pressed="false" role="button" title="${_('more download options')}">
|
||||
<i class="icon-down"></i>
|
||||
</a>
|
||||
|
||||
<div class="btn-action-switcher-container left-align">
|
||||
<ul class="btn-action-switcher" role="menu" style="min-width: 200px">
|
||||
% for a_type, content_type, extension in h.ARCHIVE_SPECS:
|
||||
% if extension not in ['.zip']:
|
||||
<li>
|
||||
|
||||
<a class="archive_link" data-ext="${extension}" href="${h.route_path('repo_archivefile',repo_name=c.rhodecode_db_repo.repo_name, fname=c.rhodecode_db_repo.landing_ref_name+extension)}">
|
||||
<i class="icon-download"></i>
|
||||
${c.rhodecode_db_repo.landing_ref_name+extension}
|
||||
</a>
|
||||
</li>
|
||||
% endif
|
||||
% endfor
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
${h.hidden('download_options')}
|
||||
% endif
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -87,16 +87,22 @@ $(document).ready(function(){
|
|||
// on change of download options
|
||||
$('#download_options').on('change', function(e) {
|
||||
// format of Object {text: "v0.0.3", type: "tag", id: "rev"}
|
||||
var ext = '.zip';
|
||||
var selected_cs = e.added;
|
||||
var fname = e.added.raw_id + ext;
|
||||
var href = pyroutes.url('repo_archivefile', {'repo_name': templateContext.repo_name, 'fname':fname});
|
||||
// set new label
|
||||
var selectedReference = e.added;
|
||||
var ico = '<i class="icon-download"></i>';
|
||||
$('#archive_link').html(ico+' {0}{1}'.format(escapeHtml(e.added.text), ext));
|
||||
|
||||
// set new url to button,
|
||||
$('#archive_link').attr('href', href)
|
||||
$.each($('.archive_link'), function (key, val) {
|
||||
var ext = $(this).data('ext');
|
||||
var fname = selectedReference.raw_id + ext;
|
||||
var href = pyroutes.url('repo_archivefile', {
|
||||
'repo_name': templateContext.repo_name,
|
||||
'fname': fname
|
||||
});
|
||||
// set new label
|
||||
$(this).html(ico + ' {0}{1}'.format(escapeHtml(e.added.text), ext));
|
||||
// set new url to button,
|
||||
$(this).attr('href', href)
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue