##// END OF EJS Templates
merged default branch into stable
merged default branch into stable

File last commit:

r5004:81bea8a2 default
r5342:5c131067 merge stable
Show More
files.mako
378 lines | 13.4 KiB | application/x-mako | MakoHtmlLexer
templating: use .mako as extensions for template files.
r1282 <%inherit file="/base/base.mako"/>
<%def name="title(*args)">
ui: new file tree switcher...
r3655 ${_('{} Files').format(c.repo_name)}
templating: use .mako as extensions for template files.
r1282 %if hasattr(c,'file'):
files: don't use safe_unicode calls
r5004 &middot; ${(h.safe_str(c.file.path) or '\\')}
templating: use .mako as extensions for template files.
r1282 %endif
%if c.rhodecode_name:
&middot; ${h.branding(c.rhodecode_name)}
%endif
</%def>
<%def name="breadcrumbs_links()">
${_('Files')}
%if c.file:
@ ${h.show_id(c.commit)}
%endif
</%def>
<%def name="menu_bar_nav()">
${self.menu_items(active='repositories')}
</%def>
<%def name="menu_bar_subnav()">
${self.repo_menu(active='files')}
</%def>
<%def name="main()">
js: refactor js and move logic to files.js
r3713 <script type="text/javascript">
var fileSourcePage = ${c.file_source_page};
var atRef = '${request.GET.get('at', '')}';
// global state for fetching metadata
metadataRequest = null;
// global metadata about URL
files: fixed case of partial url in generating files metadata
r3716 filesUrlData = ${h.files_url_data(request)|n};
js: refactor js and move logic to files.js
r3713 </script>
ui: new file tree switcher...
r3655 <div>
ui: new commits page....
r3882 <div>
templating: use .mako as extensions for template files.
r1282 <%include file='files_pjax.mako'/>
</div>
</div>
gravatars: reduce the size of fonts inside the initials gravatar
r3654
js: refactor js and move logic to files.js
r3713 <script type="text/javascript">
templating: use .mako as extensions for template files.
r1282
files: updated based on new design
r3706 var initFileJS = function () {
js: refactor js and move logic to files.js
r3713 var state = getFileState();
files: updated based on new design
r3706
// select code link event
$("#hlcode").mouseup(getSelectionLink);
// file history select2 used for history of file, and switch to
var initialCommitData = {
at_ref: atRef,
id: null,
text: '${c.commit.raw_id}',
type: 'sha',
raw_id: '${c.commit.raw_id}',
idx: ${c.commit.idx},
files_url: null,
};
// check if we have ref info.
var selectedRef = fileTreeRefs[atRef];
if (selectedRef !== undefined) {
$.extend(initialCommitData, selectedRef)
}
js: refactor js and move logic to files.js
r3713 var loadUrl = pyroutes.url('repo_file_history', {'repo_name': templateContext.repo_name, 'commit_id': state.commit_id,'f_path': state.f_path});
files: updated based on new design
r3706 var cacheKey = '__SINGLE_FILE_REFS__';
var cachedDataSource = {};
var loadRefsData = function (query) {
$.ajax({
url: loadUrl,
data: {},
dataType: 'json',
type: 'GET',
success: function (data) {
cachedDataSource[cacheKey] = data;
query.callback({results: data.results});
}
});
};
var feedRefsData = function (query, cachedData) {
var data = {results: []};
//filter results
$.each(cachedData.results, function () {
var section = this.text;
var children = [];
$.each(this.children, function () {
if (query.term.length === 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0) {
children.push(this)
}
});
data.results.push({
'text': section,
'children': children
})
});
query.callback(data);
};
var select2FileHistorySwitcher = function (targetElement, loadUrl, initialData) {
var formatResult = function (result, container, query) {
return formatSelect2SelectionRefs(result);
};
var formatSelection = function (data, container) {
var commit_ref = data;
var tmpl = '';
if (commit_ref.type === 'sha') {
tmpl = (commit_ref.raw_id || "").substr(0,8);
} else if (commit_ref.type === 'branch') {
tmpl = tmpl.concat('<i class="icon-branch"></i> ');
tmpl = tmpl.concat(escapeHtml(commit_ref.text));
} else if (commit_ref.type === 'tag') {
tmpl = tmpl.concat('<i class="icon-tag"></i> ');
tmpl = tmpl.concat(escapeHtml(commit_ref.text));
} else if (commit_ref.type === 'book') {
tmpl = tmpl.concat('<i class="icon-bookmark"></i> ');
tmpl = tmpl.concat(escapeHtml(commit_ref.text));
}
var idx = commit_ref.idx || 0;
files: don't format 0 revision in select pickers
r3707 if (idx !== 0) {
tmpl = tmpl.concat('<span class="select-index-number">r{0}</span>'.format(idx));
}
files: updated based on new design
r3706 return tmpl
};
$(targetElement).select2({
dropdownAutoWidth: true,
width: "resolve",
containerCssClass: "drop-menu",
dropdownCssClass: "drop-menu-dropdown",
query: function(query) {
var cachedData = cachedDataSource[cacheKey];
if (cachedData) {
feedRefsData(query, cachedData)
} else {
loadRefsData(query)
}
},
initSelection: function(element, callback) {
callback(initialData);
},
formatResult: formatResult,
formatSelection: formatSelection
});
};
select2FileHistorySwitcher('#file_refs_filter', loadUrl, initialCommitData);
dan
files: fixed the repo switcher at flag beeing nor persistens...
r4294 // switcher for files
files: updated based on new design
r3706 $('#file_refs_filter').on('change', function(e) {
var data = $('#file_refs_filter').select2('data');
var commit_id = data.id;
dan
files: fixed the repo switcher at flag beeing nor persistens...
r4294 var params = {
'repo_name': templateContext.repo_name,
'commit_id': commit_id,
'f_path': state.f_path
};
if(data.at_rev !== undefined && data.at_rev !== "") {
params['at'] = data.at_rev;
}
files: updated based on new design
r3706
if ("${c.annotate}" === "True") {
dan
files: fixed the repo switcher at flag beeing nor persistens...
r4294 var url = pyroutes.url('repo_files:annotated', params);
files: updated based on new design
r3706 } else {
dan
files: fixed the repo switcher at flag beeing nor persistens...
r4294 var url = pyroutes.url('repo_files', params);
files: updated based on new design
r3706 }
window.location = url;
});
// load file short history
$('#file_history_overview').on('click', function(e) {
e.preventDefault();
path = state.f_path;
if (path.indexOf("#") >= 0) {
path = path.slice(0, path.indexOf("#"));
}
changelog: rename changelog to commits pages
r3742 var url = pyroutes.url('repo_commits_file',
files: updated based on new design
r3706 {'repo_name': templateContext.repo_name,
js: refactor js and move logic to files.js
r3713 'commit_id': state.commit_id, 'f_path': path, 'limit': 6});
files: updated based on new design
r3706 $('#file_history_container').show();
$('#file_history_container').html('<div class="file-history-inner">{0}</div>'.format(_gettext('Loading ...')));
$.pjax({
url: url,
container: '#file_history_container',
push: false,
timeout: 5000
hovercacrds: added new tooltips and hovercards to expose certain information for objects shown in UI
r4026 }).complete(function () {
tooltipActivate();
files: updated based on new design
r3706 });
});
};
var initTreeJS = function () {
js: refactor js and move logic to files.js
r3713 var state = getFileState();
files: updated based on new design
r3706 getFilesMetadata();
// fuzzy file filter
fileBrowserListeners(state.node_list_url, state.url_base);
// switch to widget
var initialCommitData = {
at_ref: atRef,
id: null,
text: '${c.commit.raw_id}',
type: 'sha',
raw_id: '${c.commit.raw_id}',
idx: ${c.commit.idx},
files_url: null,
};
// check if we have ref info.
var selectedRef = fileTreeRefs[atRef];
if (selectedRef !== undefined) {
$.extend(initialCommitData, selectedRef)
}
var loadUrl = pyroutes.url('repo_refs_data', {'repo_name': templateContext.repo_name});
var cacheKey = '__ALL_FILE_REFS__';
var cachedDataSource = {};
var loadRefsData = function (query) {
$.ajax({
url: loadUrl,
data: {},
dataType: 'json',
type: 'GET',
success: function (data) {
cachedDataSource[cacheKey] = data;
query.callback({results: data.results});
}
});
};
var feedRefsData = function (query, cachedData) {
var data = {results: []};
//filter results
$.each(cachedData.results, function () {
var section = this.text;
var children = [];
$.each(this.children, function () {
if (query.term.length === 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0) {
children.push(this)
}
});
data.results.push({
'text': section,
'children': children
})
});
//push the typed in commit idx
if (!isNaN(query.term)) {
var files_url = pyroutes.url('repo_files',
{'repo_name': templateContext.repo_name,
'commit_id': query.term, 'f_path': state.f_path});
data.results.push({
'text': _gettext('go to numeric commit'),
'children': [{
at_ref: null,
id: null,
text: 'r{0}'.format(query.term),
type: 'sha',
raw_id: query.term,
idx: query.term,
files_url: files_url,
}]
});
}
query.callback(data);
};
var select2RefFileSwitcher = function (targetElement, loadUrl, initialData) {
var formatResult = function (result, container, query) {
return formatSelect2SelectionRefs(result);
};
var formatSelection = function (data, container) {
var commit_ref = data;
var tmpl = '';
if (commit_ref.type === 'sha') {
tmpl = (commit_ref.raw_id || "").substr(0,8);
} else if (commit_ref.type === 'branch') {
tmpl = tmpl.concat('<i class="icon-branch"></i> ');
tmpl = tmpl.concat(escapeHtml(commit_ref.text));
} else if (commit_ref.type === 'tag') {
tmpl = tmpl.concat('<i class="icon-tag"></i> ');
tmpl = tmpl.concat(escapeHtml(commit_ref.text));
} else if (commit_ref.type === 'book') {
tmpl = tmpl.concat('<i class="icon-bookmark"></i> ');
tmpl = tmpl.concat(escapeHtml(commit_ref.text));
}
var idx = commit_ref.idx || 0;
files: don't format 0 revision in select pickers
r3707 if (idx !== 0) {
tmpl = tmpl.concat('<span class="select-index-number">r{0}</span>'.format(idx));
}
files: updated based on new design
r3706 return tmpl
};
$(targetElement).select2({
dropdownAutoWidth: true,
width: "resolve",
containerCssClass: "drop-menu",
dropdownCssClass: "drop-menu-dropdown",
query: function(query) {
var cachedData = cachedDataSource[cacheKey];
if (cachedData) {
feedRefsData(query, cachedData)
} else {
loadRefsData(query)
}
},
initSelection: function(element, callback) {
callback(initialData);
},
formatResult: formatResult,
formatSelection: formatSelection
});
};
select2RefFileSwitcher('#refs_filter', loadUrl, initialCommitData);
dan
files: fixed the repo switcher at flag beeing nor persistens...
r4294 // switcher for file tree
files: updated based on new design
r3706 $('#refs_filter').on('change', function(e) {
var data = $('#refs_filter').select2('data');
window.location = data.files_url
});
};
$(document).ready(function() {
templating: use .mako as extensions for template files.
r1282 timeagoActivate();
hovercacrds: added new tooltips and hovercards to expose certain information for objects shown in UI
r4026 tooltipActivate();
templating: use .mako as extensions for template files.
r1282
if ($('#trimmed_message_box').height() < 50) {
$('#message_expand').hide();
}
$('#message_expand').on('click', function(e) {
$('#trimmed_message_box').css('max-height', 'none');
$(this).hide();
});
if (fileSourcePage) {
files: updated based on new design
r3706 initFileJS()
} else {
initTreeJS()
templating: use .mako as extensions for template files.
r1282 }
gravatars: reduce the size of fonts inside the initials gravatar
r3654
templating: use .mako as extensions for template files.
r1282 var search_GET = "${request.GET.get('search','')}";
dan
files: added option to use highlight marker to show keywords inside file source.
r3315 if (search_GET === "1") {
files: made file filter an active input instead of a button.
r3694 NodeFilter.initFilter();
NodeFilter.focus();
templating: use .mako as extensions for template files.
r1282 }
});
</script>
ui: new file tree switcher...
r3655 </%def>