Files
@ 4babc6e047d0
Branch filter:
Location: kallithea/kallithea/templates/admin/settings/settings_system.html - annotation
4babc6e047d0
1.3 KiB
text/html
templates/files: narrow down scope of webhelpers.html.literal
In the 'Show Authors' functionality on a file of a repository, the following
construct:
h.literal(ungettext('..A..') % (..B..))
can be simplified. Here, literal was used to cater for explicit HTML tags in
the (..B..) part only. There is no need to apply literal on the '..A..'
part.
A better structure of this code is:
h.HTML(ungettext('..A..')) % h.literal(..B..)
Note that we still need to wrap the '..A..' part in webhelpers.html.HTML to
make sure the '%' operator will preserve the 'literal' property.
See also the documentation: (the text below for 'literal' also applies to
'HTML')
https://docs.pylonsproject.org/projects/webhelpers/en/latest/modules/html/builder.html
"
When literal is used in a mixed expression containing both literals and
ordinary strings, it tries hard to escape the strings and return a
literal. However, this depends on which value has “control” of the
expression. literal seems to be able to take control with all
combinations of the + operator, but with % and join it must be on the
left side of the expression. So these all work:
"A" + literal("B")
literal(", ").join(["A", literal("B")])
literal("%s %s") % (16, literal("kg"))
But these return an ordinary string which is prone to double-escaping later:
"\n".join([literal('<span class="foo">Foo!</span>'), literal('Bar!')])
"%s %s" % (literal("16"), literal("<em>kg</em>"))
"
In the 'Show Authors' functionality on a file of a repository, the following
construct:
h.literal(ungettext('..A..') % (..B..))
can be simplified. Here, literal was used to cater for explicit HTML tags in
the (..B..) part only. There is no need to apply literal on the '..A..'
part.
A better structure of this code is:
h.HTML(ungettext('..A..')) % h.literal(..B..)
Note that we still need to wrap the '..A..' part in webhelpers.html.HTML to
make sure the '%' operator will preserve the 'literal' property.
See also the documentation: (the text below for 'literal' also applies to
'HTML')
https://docs.pylonsproject.org/projects/webhelpers/en/latest/modules/html/builder.html
"
When literal is used in a mixed expression containing both literals and
ordinary strings, it tries hard to escape the strings and return a
literal. However, this depends on which value has “control” of the
expression. literal seems to be able to take control with all
combinations of the + operator, but with % and join it must be on the
left side of the expression. So these all work:
"A" + literal("B")
literal(", ").join(["A", literal("B")])
literal("%s %s") % (16, literal("kg"))
But these return an ordinary string which is prone to double-escaping later:
"\n".join([literal('<span class="foo">Foo!</span>'), literal('Bar!')])
"%s %s" % (literal("16"), literal("<em>kg</em>"))
"
2c1c03581874 88ce09daea37 2c1c03581874 2c1c03581874 d1addaf7a91e d1addaf7a91e 88ce09daea37 3fa7b86b483e d1addaf7a91e d1addaf7a91e dacdea9fda2a dacdea9fda2a a810db90098e d1addaf7a91e d1addaf7a91e 2c1c03581874 d1addaf7a91e 99f7ec293293 88ce09daea37 d1addaf7a91e d1addaf7a91e d1addaf7a91e dacdea9fda2a 88ce09daea37 d1addaf7a91e d1addaf7a91e d1addaf7a91e 88ce09daea37 d1addaf7a91e d1addaf7a91e d1addaf7a91e d1addaf7a91e d1addaf7a91e d1addaf7a91e d1addaf7a91e d1addaf7a91e 0253b8e7d76c 0253b8e7d76c 33b71a130b16 155f281be5f8 d1addaf7a91e | <div id="update_notice" style="display: none">
<div>${_('Checking for updates...')}</div>
</div>
<%
elems = [
(_('Kallithea version'), h.literal('%s <b><span id="check_for_update" style="display:none">%s</span></b>' % (c.kallithea_version, _('Check for updates'))), ''),
(_('Kallithea configuration file'), c.ini['__file__'], ''),
(_('Python version'), c.py_version, ''),
(_('Platform'), c.platform, ''),
(_('Git version'), c.git_version, ''),
(_('Git path'), c.ini.get('git_path'), ''),
(_('Upgrade info endpoint'), h.literal('%s <br/><span class="text-muted">%s.</span>' % (c.update_url, _('Note: please make sure this server can access this URL'))), ''),
]
%>
<dl class="dl-horizontal">
%for dt, dd, tt in elems:
<dt title="${dt}">${dt}:</dt>
<dd title="${tt}">${dd}</dd>
%endfor
</dl>
<h4>${_('Python Packages')}</h4>
<table class="table">
<tbody>
%for key, value in c.modules:
<tr>
<td>${key}</td>
<td>${value}</td>
</tr>
%endfor
</tbody>
</table>
<script>
$('#check_for_update').click(function(e){
var $update_notice = $('#update_notice');
$update_notice.show();
asynchtml(${h.js(h.url('admin_settings_system_update'))}, $update_notice);
});
</script>
|