##// END OF EJS Templates
downloads: added more archive options that we support. Exposing this to users so they actually...
dan -
r4450:9a24f7d4 default
parent child Browse files
Show More
@@ -86,6 +86,7 b' from rhodecode.lib.utils2 import ('
86 from rhodecode.lib.markup_renderer import MarkupRenderer, relative_links
86 from rhodecode.lib.markup_renderer import MarkupRenderer, relative_links
87 from rhodecode.lib.vcs.exceptions import CommitDoesNotExistError
87 from rhodecode.lib.vcs.exceptions import CommitDoesNotExistError
88 from rhodecode.lib.vcs.backends.base import BaseChangeset, EmptyCommit
88 from rhodecode.lib.vcs.backends.base import BaseChangeset, EmptyCommit
89 from rhodecode.lib.vcs.conf.settings import ARCHIVE_SPECS
89 from rhodecode.lib.index.search_utils import get_matching_line_offsets
90 from rhodecode.lib.index.search_utils import get_matching_line_offsets
90 from rhodecode.config.conf import DATE_FORMAT, DATETIME_FORMAT
91 from rhodecode.config.conf import DATE_FORMAT, DATETIME_FORMAT
91 from rhodecode.model.changeset_status import ChangesetStatusModel
92 from rhodecode.model.changeset_status import ChangesetStatusModel
@@ -41,7 +41,7 b' BACKENDS = {'
41
41
42
42
43 ARCHIVE_SPECS = [
43 ARCHIVE_SPECS = [
44 ('tbz2', 'application/x-bzip2', 'tbz2'),
44 ('tbz2', 'application/x-bzip2', '.tbz2'),
45 ('tbz2', 'application/x-bzip2', '.tar.bz2'),
45 ('tbz2', 'application/x-bzip2', '.tar.bz2'),
46
46
47 ('tgz', 'application/x-gzip', '.tgz'),
47 ('tgz', 'application/x-gzip', '.tgz'),
@@ -265,9 +265,16 b' input[type="button"] {'
265 .btn-action-switcher-container{
265 .btn-action-switcher-container {
266 position: absolute;
266 position: absolute;
267 top: 100%;
267 top: 100%;
268
269 &.left-align {
270 left: 0;
271 }
272 &.right-align {
268 right: 0;
273 right: 0;
269 }
274 }
270
275
276 }
277
271 .btn-action-switcher {
278 .btn-action-switcher {
272 display: block;
279 display: block;
273 position: relative;
280 position: relative;
@@ -28,7 +28,7 b''
28 <i class="icon-down"></i>
28 <i class="icon-down"></i>
29 </a>
29 </a>
30
30
31 <div class="btn-action-switcher-container">
31 <div class="btn-action-switcher-container right-align">
32 <ul class="btn-action-switcher" role="menu" style="min-width: 200px">
32 <ul class="btn-action-switcher" role="menu" style="min-width: 200px">
33 <li>
33 <li>
34 <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)}">
34 <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 b''
516 <i class="icon-down"></i>
516 <i class="icon-down"></i>
517 </a>
517 </a>
518
518
519 <div class="btn-action-switcher-container" id="update-commits-switcher">
519 <div class="btn-action-switcher-container right-align" id="update-commits-switcher">
520 <ul class="btn-action-switcher" role="menu" style="min-width: 300px;">
520 <ul class="btn-action-switcher" role="menu" style="min-width: 300px;">
521 <li>
521 <li>
522 <a href="#forceUpdate" onclick="updateController.forceUpdateCommits(this); return false">
522 <a href="#forceUpdate" onclick="updateController.forceUpdateCommits(this); return false">
@@ -184,14 +184,37 b''
184 ${h.link_to(_('Enable downloads'),h.route_path('edit_repo',repo_name=c.repo_name, _anchor='repo_enable_downloads'))}
184 ${h.link_to(_('Enable downloads'),h.route_path('edit_repo',repo_name=c.repo_name, _anchor='repo_enable_downloads'))}
185 % endif
185 % endif
186 % else:
186 % else:
187 <span class="enabled">
187 <div class="enabled pull-left" style="margin-right: 10px">
188
188
189 <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')}">
189 <div class="btn-group btn-group-actions">
190 <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')}">
190 <i class="icon-download"></i>
191 <i class="icon-download"></i>
191 ${c.rhodecode_db_repo.landing_ref_name}.zip
192 ${c.rhodecode_db_repo.landing_ref_name}.zip
192 ## replaced by some JS on select
193 ## replaced by some JS on select
193 </a>
194 </a>
194 </span>
195
196 <a class="tooltip btn btn-primary" style="margin-left: -1px" data-toggle="dropdown" aria-pressed="false" role="button" title="${_('more download options')}">
197 <i class="icon-down"></i>
198 </a>
199
200 <div class="btn-action-switcher-container left-align">
201 <ul class="btn-action-switcher" role="menu" style="min-width: 200px">
202 % for a_type, content_type, extension in h.ARCHIVE_SPECS:
203 % if extension not in ['.zip']:
204 <li>
205
206 <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)}">
207 <i class="icon-download"></i>
208 ${c.rhodecode_db_repo.landing_ref_name+extension}
209 </a>
210 </li>
211 % endif
212 % endfor
213 </ul>
214 </div>
215 </div>
216
217 </div>
195 ${h.hidden('download_options')}
218 ${h.hidden('download_options')}
196 % endif
219 % endif
197 </div>
220 </div>
@@ -87,16 +87,22 b''
87 // on change of download options
87 // on change of download options
88 $('#download_options').on('change', function(e) {
88 $('#download_options').on('change', function(e) {
89 // format of Object {text: "v0.0.3", type: "tag", id: "rev"}
89 // format of Object {text: "v0.0.3", type: "tag", id: "rev"}
90 var ext = '.zip';
90 var selectedReference = e.added;
91 var selected_cs = e.added;
91 var ico = '<i class="icon-download"></i>';
92 var fname = e.added.raw_id + ext;
92
93 var href = pyroutes.url('repo_archivefile', {'repo_name': templateContext.repo_name, 'fname':fname});
93 $.each($('.archive_link'), function (key, val) {
94 var ext = $(this).data('ext');
95 var fname = selectedReference.raw_id + ext;
96 var href = pyroutes.url('repo_archivefile', {
97 'repo_name': templateContext.repo_name,
98 'fname': fname
99 });
94 // set new label
100 // set new label
95 var ico = '<i class="icon-download"></i>';
101 $(this).html(ico + ' {0}{1}'.format(escapeHtml(e.added.text), ext));
96 $('#archive_link').html(ico+' {0}{1}'.format(escapeHtml(e.added.text), ext));
102 // set new url to button,
103 $(this).attr('href', href)
104 });
97
105
98 // set new url to button,
99 $('#archive_link').attr('href', href)
100 });
106 });
101
107
102
108
General Comments 0
You need to be logged in to leave comments. Login now