diff --git a/rhodecode/apps/repository/views/repo_files.py b/rhodecode/apps/repository/views/repo_files.py
index 6f0fd960..094c5723 100644
--- a/rhodecode/apps/repository/views/repo_files.py
+++ b/rhodecode/apps/repository/views/repo_files.py
@@ -873,18 +873,17 @@ class RepoFilesView(RepoAppView):
self.db_repo_name, self.db_repo.repo_id, commit.raw_id, f_path)
return {'nodes': metadata}
- def _create_references(
- self, branches_or_tags, symbolic_reference, f_path):
+ def _create_references(self, branches_or_tags, symbolic_reference, f_path, ref_type):
items = []
for name, commit_id in branches_or_tags.items():
- sym_ref = symbolic_reference(commit_id, name, f_path)
- items.append((sym_ref, name))
+ sym_ref = symbolic_reference(commit_id, name, f_path, ref_type)
+ items.append((sym_ref, name, ref_type))
return items
- def _symbolic_reference(self, commit_id, name, f_path):
+ def _symbolic_reference(self, commit_id, name, f_path, ref_type):
return commit_id
- def _symbolic_reference_svn(self, commit_id, name, f_path):
+ def _symbolic_reference_svn(self, commit_id, name, f_path, ref_type):
new_f_path = vcspath.join(name, f_path)
return u'%s@%s' % (new_f_path, commit_id)
@@ -914,7 +913,7 @@ class RepoFilesView(RepoAppView):
for commit in commits:
branch = ' (%s)' % commit.branch if commit.branch else ''
n_desc = 'r%s:%s%s' % (commit.idx, commit.short_id, branch)
- commits_group[0].append((commit.raw_id, n_desc,))
+ commits_group[0].append((commit.raw_id, n_desc, 'sha'))
history.append(commits_group)
symbolic_reference = self._symbolic_reference
@@ -930,11 +929,11 @@ class RepoFilesView(RepoAppView):
symbolic_reference = self._symbolic_reference_svn
branches = self._create_references(
- self.rhodecode_vcs_repo.branches, symbolic_reference, f_path)
+ self.rhodecode_vcs_repo.branches, symbolic_reference, f_path, 'branch')
branches_group = (branches, _("Branches"))
tags = self._create_references(
- self.rhodecode_vcs_repo.tags, symbolic_reference, f_path)
+ self.rhodecode_vcs_repo.tags, symbolic_reference, f_path, 'tag')
tags_group = (tags, _("Tags"))
history.append(branches_group)
@@ -962,7 +961,7 @@ class RepoFilesView(RepoAppView):
for obj in file_history:
res.append({
'text': obj[1],
- 'children': [{'id': o[0], 'text': o[1]} for o in obj[0]]
+ 'children': [{'id': o[0], 'text': o[1], 'type': o[2]} for o in obj[0]]
})
data = {
diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py
index d2aa792b..710a2bf4 100644
--- a/rhodecode/lib/helpers.py
+++ b/rhodecode/lib/helpers.py
@@ -199,6 +199,7 @@ class _GetError(object):
if form_errors and field_name in form_errors:
return literal(tmpl % form_errors.get(field_name))
+
get_error = _GetError()
@@ -215,33 +216,30 @@ class _ToolTip(object):
tooltip_title = tooltip_title.replace('<', '<').replace('>', '>')
return tooltip_title
+
tooltip = _ToolTip()
-def files_breadcrumbs(repo_name, commit_id, file_path, at_ref=None):
+def files_breadcrumbs(repo_name, commit_id, file_path, at_ref=None, limit_items=False):
if isinstance(file_path, str):
file_path = safe_unicode(file_path)
+
route_qry = {'at': at_ref} if at_ref else None
- # TODO: johbo: Is this always a url like path, or is this operating
- # system dependent?
+ # first segment is a `..` link to repo files
+ root_name = literal(u'')
+ url_segments = [
+ link_to(
+ root_name,
+ route_path(
+ 'repo_files',
+ repo_name=repo_name,
+ commit_id=commit_id,
+ f_path='',
+ _query=route_qry),
+ )]
+
path_segments = file_path.split('/')
-
- repo_name_html = escape(repo_name)
- if len(path_segments) == 1 and path_segments[0] == '':
- url_segments = [repo_name_html]
- else:
- url_segments = [
- link_to(
- repo_name_html,
- route_path(
- 'repo_files',
- repo_name=repo_name,
- commit_id=commit_id,
- f_path='',
- _query=route_qry),
- )]
-
last_cnt = len(path_segments) - 1
for cnt, segment in enumerate(path_segments):
if not segment:
@@ -262,7 +260,16 @@ def files_breadcrumbs(repo_name, commit_id, file_path, at_ref=None):
else:
url_segments.append(segment_html)
- return literal('/'.join(url_segments))
+ limited_url_segments = url_segments[:1] + ['...'] + url_segments[-5:]
+ if limit_items and len(limited_url_segments) < len(url_segments):
+ url_segments = limited_url_segments
+
+ full_path = file_path
+ icon = ''.format(full_path)
+ if file_path == '':
+ return root_name
+ else:
+ return literal(' / '.join(url_segments) + icon)
def code_highlight(code, lexer, formatter, use_hl_filter=False):
diff --git a/rhodecode/public/css/main.less b/rhodecode/public/css/main.less
index 4029c981..3dbb7c74 100644
--- a/rhodecode/public/css/main.less
+++ b/rhodecode/public/css/main.less
@@ -2192,12 +2192,13 @@ h3.files_location{
}
}
- .select-index-number {
- margin: 0 0 0 20px;
- color: @grey3;
- }
}
+ .select-index-number {
+ margin: 0 0 0 20px;
+ color: @grey3;
+ }
+
.search_activate {
display: table-cell;
vertical-align: middle;
diff --git a/rhodecode/public/css/rcicons.less b/rhodecode/public/css/rcicons.less
index 9db9ecdc..21ca5f78 100644
--- a/rhodecode/public/css/rcicons.less
+++ b/rhodecode/public/css/rcicons.less
@@ -1,12 +1,12 @@
@font-face {
font-family: 'rcicons';
- src: url('../fonts/RCIcons/rcicons.eot?73199028');
- src: url('../fonts/RCIcons/rcicons.eot?73199028#iefix') format('embedded-opentype'),
- url('../fonts/RCIcons/rcicons.woff2?73199028') format('woff2'),
- url('../fonts/RCIcons/rcicons.woff?73199028') format('woff'),
- url('../fonts/RCIconst/rcicons.ttf?73199028') format('truetype'),
- url('../fonts/RCIcons/rcicons.svg?73199028#rcicons') format('svg');
+ src: url('../fonts/RCIcons/rcicons.eot?9641970');
+ src: url('../fonts/RCIcons/rcicons.eot?9641970#iefix') format('embedded-opentype'),
+ url('../fonts/RCIcons/rcicons.woff2?9641970') format('woff2'),
+ url('../fonts/RCIcons/rcicons.woff?9641970') format('woff'),
+ url('../fonts/RCIcons/rcicons.ttf?9641970') format('truetype'),
+ url('../fonts/RCIcons/rcicons.svg?9641970#rcicons') format('svg');
font-weight: normal;
font-style: normal;
@@ -186,6 +186,7 @@
.icon-minus:before { content: '\e820'; } /* '' */
.icon-info-circled:before { content: '\e821'; } /* '' */
.icon-upload:before { content: '\e822'; } /* '' */
+.icon-home:before { content: '\e823'; } /* '' */
.icon-git:before { content: '\e82a'; } /* '' */
.icon-hg:before { content: '\e82d'; } /* '' */
.icon-svn:before { content: '\e82e'; } /* '' */
diff --git a/rhodecode/public/css/summary.less b/rhodecode/public/css/summary.less
index 24d72e01..3f4210fb 100644
--- a/rhodecode/public/css/summary.less
+++ b/rhodecode/public/css/summary.less
@@ -425,7 +425,6 @@
}
.stats-info {
- margin-top: 5px;
color: @grey4;
}
@@ -434,7 +433,6 @@
text-align: right;
color: @grey4;
padding: 10px;
- margin-top: 15px;
}
.file-container {
diff --git a/rhodecode/public/fonts/RCIcons/config.json b/rhodecode/public/fonts/RCIcons/config.json
index e00ac419..7e1680db 100755
--- a/rhodecode/public/fonts/RCIcons/config.json
+++ b/rhodecode/public/fonts/RCIcons/config.json
@@ -551,6 +551,12 @@
"code": 59444,
"src": "fontelico"
},
+ {
+ "uid": "513ac180ff85bd275f2b736720cbbf5e",
+ "css": "home",
+ "code": 59427,
+ "src": "entypo"
+ },
{
"uid": "c43db6645e7515889fc2193294f50767",
"css": "plus",
diff --git a/rhodecode/public/fonts/RCIcons/rcicons.eot b/rhodecode/public/fonts/RCIcons/rcicons.eot
index f4bac9e6..2c776640 100755
Binary files a/rhodecode/public/fonts/RCIcons/rcicons.eot and b/rhodecode/public/fonts/RCIcons/rcicons.eot differ
diff --git a/rhodecode/public/fonts/RCIcons/rcicons.svg b/rhodecode/public/fonts/RCIcons/rcicons.svg
index eca0b1be..e64500b5 100755
--- a/rhodecode/public/fonts/RCIcons/rcicons.svg
+++ b/rhodecode/public/fonts/RCIcons/rcicons.svg
@@ -76,6 +76,8 @@
+
+
diff --git a/rhodecode/public/fonts/RCIcons/rcicons.ttf b/rhodecode/public/fonts/RCIcons/rcicons.ttf
index 4b5d46ef..8d27f5bf 100755
Binary files a/rhodecode/public/fonts/RCIcons/rcicons.ttf and b/rhodecode/public/fonts/RCIcons/rcicons.ttf differ
diff --git a/rhodecode/public/fonts/RCIcons/rcicons.woff b/rhodecode/public/fonts/RCIcons/rcicons.woff
index be082d71..648b7f0d 100755
Binary files a/rhodecode/public/fonts/RCIcons/rcicons.woff and b/rhodecode/public/fonts/RCIcons/rcicons.woff differ
diff --git a/rhodecode/public/fonts/RCIcons/rcicons.woff2 b/rhodecode/public/fonts/RCIcons/rcicons.woff2
index 97dda070..56a94eb8 100755
Binary files a/rhodecode/public/fonts/RCIcons/rcicons.woff2 and b/rhodecode/public/fonts/RCIcons/rcicons.woff2 differ
diff --git a/rhodecode/public/js/src/rhodecode/select2_widgets.js b/rhodecode/public/js/src/rhodecode/select2_widgets.js
index c2261dd1..381d5335 100644
--- a/rhodecode/public/js/src/rhodecode/select2_widgets.js
+++ b/rhodecode/public/js/src/rhodecode/select2_widgets.js
@@ -73,10 +73,3 @@ var select2RefSwitcher = function(targetElement, initialData) {
{'repo_name': templateContext.repo_name});
select2RefBaseSwitcher(targetElement, loadUrl, initialData);
};
-
-var select2FileHistorySwitcher = function(targetElement, initialData, state) {
- var loadUrl = pyroutes.url('repo_file_history',
- {'repo_name': templateContext.repo_name, 'commit_id': state.rev,
- 'f_path': state.f_path});
- select2RefBaseSwitcher(targetElement, loadUrl, initialData);
-};
diff --git a/rhodecode/templates/changelog/changelog_file_history.mako b/rhodecode/templates/changelog/changelog_file_history.mako
index 893aeb18..dd7c55f8 100644
--- a/rhodecode/templates/changelog/changelog_file_history.mako
+++ b/rhodecode/templates/changelog/changelog_file_history.mako
@@ -3,7 +3,7 @@
%for cnt,cs in enumerate(c.pagination):
-
+
|
${base.gravatar_with_user(cs.author, 16)}
|
@@ -33,7 +33,19 @@
${_('Show File')}
+
+
+ ${_('Diff File')}
+
+ |
%endfor
+
+ |
+
+ ${_('Show Full History')}
+
+ |
+
diff --git a/rhodecode/templates/files/file_authors_box.mako b/rhodecode/templates/files/file_authors_box.mako
index 2c664045..42732958 100644
--- a/rhodecode/templates/files/file_authors_box.mako
+++ b/rhodecode/templates/files/file_authors_box.mako
@@ -10,6 +10,7 @@
${h.link_to_user(user)}
% if c.file_author:
- ${h.age_component(c.file_last_commit.date)}
+ - ${_('Load All Authors')}
% elif c.file_last_commit.author_email==email:
(${_('last author')})
% endif
@@ -27,13 +28,7 @@
% endif
-
- |
- % if c.file_author:
- ${_('Show Authors')}
- % endif
- |
-
+
% endfor
% endif
diff --git a/rhodecode/templates/files/files.mako b/rhodecode/templates/files/files.mako
index 3d1960ea..dd110dd1 100644
--- a/rhodecode/templates/files/files.mako
+++ b/rhodecode/templates/files/files.mako
@@ -118,14 +118,322 @@
timeagoActivate();
});
metadataRequest.fail(function (data, textStatus, errorThrown) {
- console.log(data);
if (data.status != 0) {
alert("Error while fetching metadata.\nError code {0} ({1}).Please consider reloading the page".format(data.status,data.statusText));
}
});
};
- var callbacks = function() {
+ var initFileJS = function () {
+ var state = getState('callbacks');
+
+ // 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)
+ }
+
+ var loadUrl = pyroutes.url('repo_file_history', {'repo_name': templateContext.repo_name, 'commit_id': state.rev,'f_path': state.f_path});
+ 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(' ');
+ tmpl = tmpl.concat(escapeHtml(commit_ref.text));
+ } else if (commit_ref.type === 'tag') {
+ tmpl = tmpl.concat(' ');
+ tmpl = tmpl.concat(escapeHtml(commit_ref.text));
+ } else if (commit_ref.type === 'book') {
+ tmpl = tmpl.concat(' ');
+ tmpl = tmpl.concat(escapeHtml(commit_ref.text));
+ }
+ var idx = commit_ref.idx || 0;
+ tmpl = tmpl.concat('r{0}'.format(idx));
+ 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);
+
+ $('#file_refs_filter').on('change', function(e) {
+ var data = $('#file_refs_filter').select2('data');
+ var commit_id = data.id;
+
+ if ("${c.annotate}" === "True") {
+ var url = pyroutes.url('repo_files:annotated',
+ {'repo_name': templateContext.repo_name,
+ 'commit_id': commit_id, 'f_path': state.f_path});
+ } else {
+ var url = pyroutes.url('repo_files',
+ {'repo_name': templateContext.repo_name,
+ 'commit_id': commit_id, 'f_path': state.f_path});
+ }
+ window.location = url;
+
+ });
+
+ // show more authors
+ $('#show_authors').on('click', function(e) {
+ e.preventDefault();
+ var url = pyroutes.url('repo_file_authors',
+ {'repo_name': templateContext.repo_name,
+ 'commit_id': state.rev, 'f_path': state.f_path});
+
+ $.pjax({
+ url: url,
+ data: 'annotate=${("1" if c.annotate else "0")}',
+ container: '#file_authors',
+ push: false,
+ timeout: 5000
+ }).complete(function(){
+ $('#show_authors').hide();
+ $('#file_authors_title').html(_gettext('All Authors'))
+ })
+ });
+
+ // 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("#"));
+ }
+ var url = pyroutes.url('repo_changelog_file',
+ {'repo_name': templateContext.repo_name,
+ 'commit_id': state.rev, 'f_path': path, 'limit': 6});
+ $('#file_history_container').show();
+ $('#file_history_container').html('{0}
'.format(_gettext('Loading ...')));
+
+ $.pjax({
+ url: url,
+ container: '#file_history_container',
+ push: false,
+ timeout: 5000
+ });
+ });
+
+
+ };
+
+ var initTreeJS = function () {
+ var state = getState('callbacks');
+ 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(' ');
+ tmpl = tmpl.concat(escapeHtml(commit_ref.text));
+ } else if (commit_ref.type === 'tag') {
+ tmpl = tmpl.concat(' ');
+ tmpl = tmpl.concat(escapeHtml(commit_ref.text));
+ } else if (commit_ref.type === 'book') {
+ tmpl = tmpl.concat(' ');
+ tmpl = tmpl.concat(escapeHtml(commit_ref.text));
+ }
+
+ var idx = commit_ref.idx || 0;
+ tmpl = tmpl.concat('r{0}'.format(idx));
+ 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);
+
+ $('#refs_filter').on('change', function(e) {
+ var data = $('#refs_filter').select2('data');
+ window.location = data.files_url
+ });
+
+ };
+
+ $(document).ready(function() {
timeagoActivate();
if ($('#trimmed_message_box').height() < 50) {
@@ -137,250 +445,12 @@
$(this).hide();
});
- var state = getState('callbacks');
-
- // VIEW FOR FILE SOURCE
if (fileSourcePage) {
- // variants for with source code, not tree view
-
- // select code link event
- $("#hlcode").mouseup(getSelectionLink);
-
- // file history select2 used for history, and switch to
- var initialCommitData = {
- id: null,
- text: '${_("Pick Commit")}',
- type: 'sha',
- raw_id: null,
- files_url: null
- };
-
- select2FileHistorySwitcher('#diff1', initialCommitData, state);
-
- // show at, diff to actions handlers
- $('#diff1').on('change', function(e) {
- $('#diff_to_commit').removeClass('disabled').removeAttr("disabled");
- $('#diff_to_commit').val(_gettext('Diff to Commit ') + e.val.truncateAfter(8, '...'));
-
- $('#show_at_commit').removeClass('disabled').removeAttr("disabled");
- $('#show_at_commit').val(_gettext('Show at Commit ') + e.val.truncateAfter(8, '...'));
- });
-
- $('#diff_to_commit').on('click', function(e) {
- var diff1 = $('#diff1').val();
- var diff2 = $('#diff2').val();
-
- var url_data = {
- repo_name: templateContext.repo_name,
- source_ref: diff1,
- source_ref_type: 'rev',
- target_ref: diff2,
- target_ref_type: 'rev',
- merge: 1,
- f_path: state.f_path
- };
- window.location = pyroutes.url('repo_compare', url_data);
- });
-
- $('#show_at_commit').on('click', function(e) {
- var diff1 = $('#diff1').val();
-
- var annotate = $('#annotate').val();
- if (annotate === "True") {
- var url = pyroutes.url('repo_files:annotated',
- {'repo_name': templateContext.repo_name,
- 'commit_id': diff1, 'f_path': state.f_path});
- } else {
- var url = pyroutes.url('repo_files',
- {'repo_name': templateContext.repo_name,
- 'commit_id': diff1, 'f_path': state.f_path});
- }
- window.location = url;
-
- });
-
- // show more authors
- $('#show_authors').on('click', function(e) {
- e.preventDefault();
- var url = pyroutes.url('repo_file_authors',
- {'repo_name': templateContext.repo_name,
- 'commit_id': state.rev, 'f_path': state.f_path});
-
- $.pjax({
- url: url,
- data: 'annotate=${("1" if c.annotate else "0")}',
- container: '#file_authors',
- push: false,
- timeout: 5000
- }).complete(function(){
- $('#show_authors').hide();
- $('#file_authors_title').html(_gettext('All Authors'))
- })
- });
-
- // 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("#"));
- }
- var url = pyroutes.url('repo_changelog_file',
- {'repo_name': templateContext.repo_name,
- 'commit_id': state.rev, 'f_path': path, 'limit': 6});
- $('#file_history_container').show();
- $('#file_history_container').html('{0}
'.format(_gettext('Loading ...')));
-
- $.pjax({
- url: url,
- container: '#file_history_container',
- push: false,
- timeout: 5000
- })
- });
-
+ initFileJS()
+ } else {
+ initTreeJS()
}
- // VIEW FOR FILE TREE BROWSER
- else {
- 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(' ');
- tmpl = tmpl.concat(escapeHtml(commit_ref.text));
- } else if (commit_ref.type === 'tag') {
- tmpl = tmpl.concat(' ');
- tmpl = tmpl.concat(escapeHtml(commit_ref.text));
- } else if (commit_ref.type === 'book') {
- tmpl = tmpl.concat(' ');
- tmpl = tmpl.concat(escapeHtml(commit_ref.text));
- }
-
- tmpl = tmpl.concat('r{0}'.format(commit_ref.idx));
- 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);
-
- $('#refs_filter').on('change', function(e) {
- var data = $('#refs_filter').select2('data');
- window.location = data.files_url
- });
-
- }
- };
-
- $(document).ready(function() {
- callbacks();
var search_GET = "${request.GET.get('search','')}";
if (search_GET === "1") {
NodeFilter.initFilter();
diff --git a/rhodecode/templates/files/files_browser.mako b/rhodecode/templates/files/files_browser.mako
index e256ae77..f8d9b170 100644
--- a/rhodecode/templates/files/files_browser.mako
+++ b/rhodecode/templates/files/files_browser.mako
@@ -17,18 +17,28 @@
% if h.HasRepoPermissionAny('repository.write','repository.admin')(c.repo_name):
-
-
- ${_('Add File')}
+
% endif
% if c.enable_downloads:
<% at_path = '{}'.format(request.GET.get('at') or c.commit.raw_id[:6]) %>
% endif
@@ -45,6 +55,7 @@
+
## file tree is computed from caches, and filled in
${c.file_tree |n}
diff --git a/rhodecode/templates/files/files_browser_tree.mako b/rhodecode/templates/files/files_browser_tree.mako
index 5aa2e6e1..8506c0db 100644
--- a/rhodecode/templates/files/files_browser_tree.mako
+++ b/rhodecode/templates/files/files_browser_tree.mako
@@ -17,19 +17,13 @@
- %if c.file.parent:
-
- |
-
- ..
-
+ |
+ |
+
+ ${h.files_breadcrumbs(c.repo_name,c.commit.raw_id,c.file.path, request.GET.get('at'), limit_items=True)}
+
|
- |
- |
- |
- |
-
- %endif
+
%for cnt,node in enumerate(c.file):
diff --git a/rhodecode/templates/files/files_pjax.mako b/rhodecode/templates/files/files_pjax.mako
index 1e5ab768..43347c35 100644
--- a/rhodecode/templates/files/files_pjax.mako
+++ b/rhodecode/templates/files/files_pjax.mako
@@ -13,14 +13,7 @@
% if c.file.is_submodule():
diff --git a/rhodecode/templates/files/files_source.mako b/rhodecode/templates/files/files_source.mako
index c8056958..c37488c0 100644
--- a/rhodecode/templates/files/files_source.mako
+++ b/rhodecode/templates/files/files_source.mako
@@ -1,16 +1,61 @@
<%namespace name="sourceblock" file="/codeblocks/source.mako"/>
-
-
-
+
+
+ ${_('History')}
+
+ |
+ %if c.annotate:
+ ${h.link_to(_('Source'), h.route_path('repo_files', repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path))}
+ %else:
+ ${h.link_to(_('Annotation'), h.route_path('repo_files:annotated',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path))}
+ %endif
+ | ${h.link_to(_('Raw'), h.route_path('repo_file_raw',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path))}
+
+
+
%if c.file.is_binary:
<% rendered_binary = h.render_binary(c.repo_name, c.file)%>
diff --git a/rhodecode/templates/files/files_source_header.mako b/rhodecode/templates/files/files_source_header.mako
index 9850dca8..bbe59507 100644
--- a/rhodecode/templates/files/files_source_header.mako
+++ b/rhodecode/templates/files/files_source_header.mako
@@ -36,29 +36,6 @@
-
-
-
-
- ${_('Show/Diff file')}
-
- ${h.hidden('diff1')}
- ${h.hidden('diff2',c.commit.raw_id)}
- ${h.hidden('annotate', c.annotate)}
-
-
-
-
-
-
-
- ${_('Action')}
-
- ${h.submit('diff_to_commit',_('Diff to Commit'),class_="btn disabled",disabled="true")}
- ${h.submit('show_at_commit',_('Show at Commit'),class_="btn disabled",disabled="true")}
-
-
-
|