@@ -250,78 +250,79 @@ class FilesController(BaseRepoController
try:
self.scm_model.commit_change(repo=c.rhodecode_repo,
repo_name=repo_name, cs=c.cs,
user=self.rhodecode_user,
author=author, message=message,
content=content, f_path=f_path)
h.flash(_('Successfully committed to %s' % f_path),
category='success')
except Exception:
log.error(traceback.format_exc())
h.flash(_('Error occurred during commit'), category='error')
return redirect(url('changeset_home',
repo_name=c.repo_name, revision='tip'))
return render('files/files_edit.html')
@HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
'repository.admin')
def archivefile(self, repo_name, fname):
fileformat = None
revision = None
ext = None
subrepos = request.GET.get('subrepos') == 'true'
for a_type, ext_data in ARCHIVE_SPECS.items():
archive_spec = fname.split(ext_data[1])
if len(archive_spec) == 2 and archive_spec[1] == '':
fileformat = a_type or ext_data[1]
revision = archive_spec[0]
ext = ext_data[1]
dbrepo = RepoModel().get_by_repo_name(repo_name)
if dbrepo.enable_downloads is False:
return _('downloads disabled')
cs = c.rhodecode_repo.get_changeset(revision)
content_type = ARCHIVE_SPECS[fileformat][0]
except ChangesetDoesNotExistError:
return _('Unknown revision %s') % revision
except EmptyRepositoryError:
return _('Empty repository')
except (ImproperArchiveTypeError, KeyError):
return _('Unknown archive type')
response.content_type = content_type
response.content_disposition = 'attachment; filename=%s-%s%s' \
% (repo_name, revision, ext)
import tempfile
archive = tempfile.mkstemp()[1]
t = open(archive, 'wb')
cs.fill_archive(stream=t, kind=fileformat)
cs.fill_archive(stream=t, kind=fileformat, subrepos=subrepos)
def get_chunked_archive(archive):
stream = open(archive, 'rb')
while True:
data = stream.read(4096)
if not data:
os.remove(archive)
break
yield data
return get_chunked_archive(archive)
def diff(self, repo_name, f_path):
diff1 = request.GET.get('diff1')
diff2 = request.GET.get('diff2')
c.action = request.GET.get('diff')
c.no_changes = diff1 == diff2
c.f_path = f_path
c.big_diff = False
if diff1 not in ['', None, 'None', '0' * 12, '0' * 40]:
@@ -143,48 +143,51 @@
<div class="field">
<div class="label">
<label>${_('Download')}:</label>
</div>
<div class="input-short">
%if len(c.rhodecode_repo.revisions) == 0:
${_('There are no downloads yet')}
%elif c.enable_downloads is False:
${_('Downloads are disabled for this repository')}
%if h.HasPermissionAll('hg.admin')('enable stats on from summary'):
[${h.link_to(_('enable'),h.url('edit_repo',repo_name=c.repo_name))}]
%endif
%else:
${h.select('download_options',c.rhodecode_repo.get_changeset().raw_id,c.download_options)}
%for cnt,archive in enumerate(c.rhodecode_repo._get_archives()):
%if cnt >=1:
|
<span class="tooltip" title="${_('Download %s as %s') %('tip',archive['type'])}"
id="${archive['type']+'_link'}">${h.link_to(archive['type'],
h.url('files_archive_home',repo_name=c.dbrepo.repo_name,
fname='tip'+archive['extension']),class_="archive_icon")}</span>
%endfor
<span style="vertical-align: bottom">
<input id="archive_subrepos" type="checkbox" name="subrepos"/> <span class="tooltip" title="${_('Check this to download archive with subrepos')}" >${_('with subrepos')}</span>
</span>
<label>${_('Feeds')}:</label>
%if c.rhodecode_user.username != 'default':
${h.link_to(_('RSS'),h.url('rss_feed_home',repo_name=c.dbrepo.repo_name,api_key=c.rhodecode_user.api_key),class_='rss_icon')}
${h.link_to(_('Atom'),h.url('atom_feed_home',repo_name=c.dbrepo.repo_name,api_key=c.rhodecode_user.api_key),class_='atom_icon')}
${h.link_to(_('RSS'),h.url('rss_feed_home',repo_name=c.dbrepo.repo_name),class_='rss_icon')}
${h.link_to(_('Atom'),h.url('atom_feed_home',repo_name=c.dbrepo.repo_name),class_='atom_icon')}
<script type="text/javascript">
YUE.onDOMReady(function(e){
id = 'clone_url';
YUE.on(id,'click',function(e){
@@ -257,69 +260,70 @@
show_more.appendChild(td);
show_more.appendChild(document.createElement('td'));
tbl.appendChild(show_more);
}
if(no_data){
var tr = document.createElement('tr');
var td1 = document.createElement('td');
td1.innerHTML = "${c.no_data_msg}";
tr.appendChild(td1);
tbl.appendChild(tr);
YUD.get('lang_stats').appendChild(tbl);
YUE.on('code_stats_show_more','click',function(){
l = YUD.getElementsByClassName('stats_hidden')
for (e in l){
YUD.setStyle(l[e],'display','');
};
YUD.setStyle(YUD.get('code_stats_show_more'),
'display','none');
})
YUE.on('download_options','change',function(e){
var new_cs = e.target.options[e.target.selectedIndex];
var tmpl_links = {}
tmpl_links['${archive['type']}'] = '${h.link_to(archive['type'],
fname='__CS__'+archive['extension']),class_="archive_icon")}';
fname='__CS__'+archive['extension'],subrepos='__SUB__'),class_="archive_icon")}';
YUE.on(['download_options','archive_subrepos'],'change',function(e){
var sm = YUD.get('download_options');
var new_cs = sm.options[sm.selectedIndex];
for(k in tmpl_links){
var s = YUD.get(k+'_link')
var s = YUD.get(k+'_link');
title_tmpl = "${_('Download %s as %s') % ('__CS_NAME__','__CS_EXT__')}";
s.title = title_tmpl.replace('__CS_NAME__',new_cs.text);
s.title = s.title.replace('__CS_EXT__',k);
s.innerHTML = tmpl_links[k].replace('__CS__',new_cs.value);
var url = tmpl_links[k].replace('__CS__',new_cs.value);
var subrepos = YUD.get('archive_subrepos').checked
url = url.replace('__SUB__',subrepos);
s.innerHTML = url
});
</script>
<div class="box box-right" style="min-height:455px">
<!-- box / title -->
<div class="title">
<h5>${_('Commit activity by day / author')}</h5>
<div class="graph">
<div style="padding:0 10px 10px 15px;font-size: 1.2em;">
%if c.no_data:
${c.no_data_msg}
${_('Loaded in')} ${c.stats_percentage} %
<div id="commit_history" style="width:450px;height:300px;float:left"></div>
<div style="clear: both;height: 10px"></div>
<div id="overview" style="width:450px;height:100px;float:left"></div>
Status change: