@@ -226,126 +226,127 @@ class FilesController(BaseRepoController
revision=c.cs.raw_id, f_path=f_path))
c.file_history = self._get_node_history(c.cs, f_path)
c.f_path = f_path
if r_post:
old_content = c.file.content
sl = old_content.splitlines(1)
first_line = sl[0] if sl else ''
# modes: 0 - Unix, 1 - Mac, 2 - DOS
mode = detect_mode(first_line, 0)
content = convert_line_endings(r_post.get('content'), mode)
message = r_post.get('message') or (_('Edited %s via RhodeCode')
% (f_path))
author = self.rhodecode_user.full_contact
if content == old_content:
h.flash(_('No changes'),
category='warning')
return redirect(url('changeset_home', repo_name=c.repo_name,
revision='tip'))
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.big_diff = False
if diff1 not in ['', None, 'None', '0' * 12, '0' * 40]:
c.changeset_1 = c.rhodecode_repo.get_changeset(diff1)
node1 = c.changeset_1.get_node(f_path)
else:
c.changeset_1 = EmptyChangeset(repo=c.rhodecode_repo)
node1 = FileNode('.', '', changeset=c.changeset_1)
if diff2 not in ['', None, 'None', '0' * 12, '0' * 40]:
c.changeset_2 = c.rhodecode_repo.get_changeset(diff2)
node2 = c.changeset_2.get_node(f_path)
c.changeset_2 = EmptyChangeset(repo=c.rhodecode_repo)
node2 = FileNode('.', '', changeset=c.changeset_2)
except RepositoryError:
return redirect(url('files_home',
repo_name=c.repo_name, f_path=f_path))
if c.action == 'download':
diff = differ.DiffProcessor(differ.get_gitdiff(node1, node2),
format='gitdiff')
diff_name = '%s_vs_%s.diff' % (diff1, diff2)
response.content_type = 'text/plain'
response.content_disposition = 'attachment; filename=%s' \
% diff_name
@@ -119,96 +119,99 @@
<span class="tooltip" title="${c.rhodecode_repo.last_change}">
${h.age(c.rhodecode_repo.last_change)}</span><br/>
${_('by')} ${h.get_changeset_safe(c.rhodecode_repo,'tip').author}
</div>
<div class="field">
<div class="label">
<label>${_('Clone url')}:</label>
<div class="input-short">
<input type="text" id="clone_url" readonly="readonly" value="${c.rhodecode_repo.alias} clone ${c.clone_repo_url}" size="70"/>
<label>${_('Trending source files')}:</label>
<div id="lang_stats"></div>
<label>${_('Download')}:</label>
%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){
if(YUD.hasClass(id,'selected')){
return
}
else{
YUD.addClass(id,'selected');
YUD.get(id).select();
})
var data = ${c.trending_languages|n};
var total = 0;
var no_data = true;
for (k in data){
total += data[k].count;
no_data = false;
var tbl = document.createElement('table');
tbl.setAttribute('class','trending_language_tbl');
var cnt = 0;
cnt += 1;
var hide = cnt>2;
var tr = document.createElement('tr');
@@ -233,117 +236,118 @@
if (percentage>22){
trending_language.innerHTML = "<b style='font-size:0.8em'>"+percentage+"% "+nr_files+ "</b>";
trending_language.innerHTML = "<b style='font-size:0.8em'>"+percentage+"%</b>";
trending_language.setAttribute("class", 'trending_language top-right-rounded-corner bottom-right-rounded-corner');
trending_language.style.width=percentage+"%";
td2.appendChild(trending_language);
tr.appendChild(td1);
tr.appendChild(td2);
tbl.appendChild(tr);
if(cnt == 3){
var show_more = document.createElement('tr');
var td = document.createElement('td');
lnk = document.createElement('a');
lnk.href='#';
lnk.innerHTML = "${_('show more')}";
lnk.id='code_stats_show_more';
td.appendChild(lnk);
show_more.appendChild(td);
show_more.appendChild(document.createElement('td'));
tbl.appendChild(show_more);
if(no_data){
var td1 = document.createElement('td');
td1.innerHTML = "${c.no_data_msg}";
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>
<div id="legend_data" style="clear:both;margin-top:10px;">
<div id="legend_container"></div>
<div id="legend_choices">
<table id="legend_choices_tables" style="font-size:smaller;color:#545454"></table>
/**
* Plots summary graph
*
* @class SummaryPlot
* @param {from} initial from for detailed graph
* @param {to} initial to for detailed graph
* @param {dataset}
* @param {overview_dataset}
*/
function SummaryPlot(from,to,dataset,overview_dataset) {
var initial_ranges = {
"xaxis":{
"from":from,
"to":to,
},
Status change: