gravatars: reduce the size of fonts inside the initials gravatar

This commit is contained in:
Marcin Kuzminski 2019-05-07 12:56:57 +02:00
parent 290740c9b0
commit cd670577e5
5 changed files with 118 additions and 31 deletions

View file

@ -1196,7 +1196,7 @@ class InitialsGravatar(object):
</text>
</svg>""".format(
size=self.size,
f_size=self.size/1.85, # scale the text inside the box nicely
f_size=self.size/2.05, # scale the text inside the box nicely
background=self.background,
text_color=self.text_color,
text=initials.upper(),

View file

@ -2187,6 +2187,11 @@ h3.files_location{
margin-right: @padding;
}
}
.select-index-number {
margin: 0 0 0 20px;
color: @grey3;
}
}
.search_activate {

View file

@ -1,4 +1,11 @@
<%def name="refs(commit)">
## Build a cache of refs for selector
<script>
fileTreeRefs = {
}
</script>
%if commit.merge:
<span class="mergetag tag">
<i class="icon-merge">${_('merge')}</i>
@ -10,6 +17,9 @@
<span class="booktag tag" title="${h.tooltip(_('Bookmark %s') % book)}">
<a href="${h.route_path('repo_files:default_path',repo_name=c.repo_name,commit_id=commit.raw_id,_query=dict(at=book))}"><i class="icon-bookmark"></i>${h.shorter(book)}</a>
</span>
<script>
fileTreeRefs["${book}"] = {raw_id: "${commit.raw_id}", type:"book"};
</script>
%endfor
%endif
@ -17,12 +27,18 @@
<span class="tagtag tag" title="${h.tooltip(_('Tag %s') % tag)}">
<a href="${h.route_path('repo_files:default_path',repo_name=c.repo_name,commit_id=commit.raw_id,_query=dict(at=tag))}"><i class="icon-tag"></i>${tag}</a>
</span>
<script>
fileTreeRefs["${tag}"] = {raw_id: "${commit.raw_id}", type:"tag"};
</script>
%endfor
%if commit.branch:
<span class="branchtag tag" title="${h.tooltip(_('Branch %s') % commit.branch)}">
<a href="${h.route_path('repo_files:default_path',repo_name=c.repo_name,commit_id=commit.raw_id,_query=dict(at=commit.branch))}"><i class="icon-code-fork"></i>${h.shorter(commit.branch)}</a>
</span>
<script>
fileTreeRefs["${commit.branch}"] = {raw_id: "${commit.raw_id}", type:"branch"};
</script>
%endif
</%def>

View file

@ -33,6 +33,8 @@
</div>
</div>
<script>
var pjaxTimeout = 5000;
var curState = {
commit_id: "${c.commit.raw_id}"
};
@ -121,15 +123,6 @@
var state = getState('callbacks');
timeagoActivate();
// used for history, and switch to
var initialCommitData = {
id: null,
text: '${_("Pick Commit")}',
type: 'sha',
raw_id: null,
files_url: null
};
if ($('#trimmed_message_box').height() < 50) {
$('#message_expand').hide();
}
@ -139,13 +132,21 @@
$(this).hide();
});
// VIEW FOR FILE SOURCE
if (fileSourcePage) {
// variants for with source code, not tree view
// select code link event
$("#hlcode").mouseup(getSelectionLink);
// file history select2
// 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
@ -231,6 +232,7 @@
});
}
// VIEW FOR FILE TREE BROWSER
else {
getFilesMetadata();
@ -238,7 +240,83 @@
fileBrowserListeners(state.node_list_url, state.url_base);
// switch to widget
select2RefSwitcher('#refs_filter', initialCommitData);
console.log(state)
var initialCommitData = {
at_ref: '${request.GET.get('at')}',
id: null,
text: '${c.commit.raw_id}',
type: 'sha',
raw_id: '${c.commit.raw_id}',
idx: ${c.commit.idx},
files_url: null,
};
var loadUrl = pyroutes.url('repo_refs_data', {'repo_name': templateContext.repo_name});
var select2RefFileSwitcher = function (targetElement, loadUrl, initialData) {
var formatResult = function (result, container, query) {
return formatSelect2SelectionRefs(result);
};
var formatSelection = function (data, container) {
var commit_ref = data;
console.log(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));
}
tmpl = tmpl.concat('<span class="select-index-number">{0}</span>'.format(commit_ref.idx));
return tmpl
};
$(targetElement).select2({
cachedDataSource: {},
dropdownAutoWidth: true,
width: "resolve",
containerCssClass: "drop-menu",
dropdownCssClass: "drop-menu-dropdown",
query: function(query) {
var self = this;
var cacheKey = '__ALL_FILE_REFS__';
var cachedData = self.cachedDataSource[cacheKey];
if (cachedData) {
var data = select2RefFilterResults(query.term, cachedData);
query.callback({results: data.results});
} else {
$.ajax({
url: loadUrl,
data: {},
dataType: 'json',
type: 'GET',
success: function(data) {
self.cachedDataSource[cacheKey] = data;
query.callback({results: data.results});
}
});
}
},
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');
curState.commit_id = data.raw_id;
@ -255,22 +333,9 @@
curState.commit_id = data.commitId;
});
$('#at_rev').on("keypress", function(e) {
/* ENTER PRESSED */
if (e.keyCode === 13) {
var rev = $('#at_rev').val();
// explicit reload page here. with pjax entering bad input
// produces not so nice results
window.location = pyroutes.url('repo_files',
{'repo_name': templateContext.repo_name,
'commit_id': rev, 'f_path': state.f_path});
}
});
}
};
var pjaxTimeout = 5000;
$(document).pjax(".pjax-link", "#pjax-container", {
"fragment": "#pjax-content",
"maxCacheLength": 1000,

View file

@ -2,18 +2,19 @@
<div id="codeblock" class="browserblock">
<div class="browser-header">
<div class="browser-nav">
${h.form(h.current_route_path(request), method='GET', id='at_rev_form')}
<div class="info_box">
${h.hidden('refs_filter')}
<div class="info_box_elem previous">
<a id="prev_commit_link" data-commit-id="${c.prev_commit.raw_id}" class="pjax-link ${'disabled' if c.url_prev == '#' else ''}" href="${c.url_prev}" title="${_('Previous commit')}"><i class="icon-left"></i></a>
<a id="prev_commit_link" data-commit-id="${c.prev_commit.raw_id}" class="pjax-link ${'disabled' if c.url_prev == '#' else ''}" href="${c.url_prev}" title="${_('Previous commit')}"><i class="icon-left"></i></a>
</div>
<div class="info_box_elem">${h.text('at_rev',value=c.commit.idx)}</div>
${h.hidden('refs_filter')}
<div class="info_box_elem next">
<a id="next_commit_link" data-commit-id="${c.next_commit.raw_id}" class="pjax-link ${'disabled' if c.url_next == '#' else ''}" href="${c.url_next}" title="${_('Next commit')}"><i class="icon-right"></i></a>
<a id="next_commit_link" data-commit-id="${c.next_commit.raw_id}" class="pjax-link ${'disabled' if c.url_next == '#' else ''}" href="${c.url_next}" title="${_('Next commit')}"><i class="icon-right"></i></a>
</div>
</div>
${h.end_form()}
<div id="search_activate_id" class="search_activate">
<a class="btn btn-default" id="filter_activate" href="javascript:void(0)">${_('Search File List')}</a>