webui:cosmetic+crop_middle

This commit is contained in:
Martijn Voncken 2008-03-04 21:02:37 +00:00
parent 49ec8766ca
commit faa5b69db4
4 changed files with 7 additions and 17 deletions

View File

@ -207,7 +207,6 @@ class index:
setcookie("order", vars.order)
setcookie("sort", vars.sort)
log.debug("filters=%s,plugins=%s" % (organize_filters, proxy.get_enabled_plugins()))
return render.index(torrent_list, organize_filters)
class torrent_info:

View File

@ -100,18 +100,11 @@ def category_tabs(torrent_list):
return render.part_categories(filter_tabs, category_tabs)
"""
def template_crop(text, end):
try:
if len(text) > end:
return text[0:end - 3] + '...'
except:
return "[ERROR NOT A STRING:(%s)]" % text
return text
def template_crop_left(text, maxlen):
def template_crop_middle(text, maxlen):
try:
if len(text) > maxlen:
return "..." + text[-(maxlen + 3):]
half = (maxlen / 2) - 2
return text[0:half ] + '...' + text[-half:]
except:
return "[ERROR NOT A STRING:(%s)]" % text
return text
@ -162,8 +155,8 @@ def ftime(val):
template.Template.globals.update({
'sort_head': template_sort_head,
'part_stats':template_part_stats,
'crop': template_crop,
'crop_left': template_crop_left,
'crop': template_crop_middle,
'crop_left': template_crop_middle,
'_': _ , #gettext/translations
'str': str, #because % in templetor is broken.
'int':int,

View File

@ -15,7 +15,7 @@ $for state, num in filters.state:
</select>
<select name='tracker' id='tracker'
onchange="document.getElementById('category_form').submit()"
title="$_('Filter on Tracker')"
title="$_('Filter on tracker')"
style="width:150px"
>
<option value="">$_('Trackers')</option>

View File

@ -56,6 +56,4 @@ class torrent_options:
def POST(self, torrent):
pass
template.Template.globals["forms"].torrent_options = lambda torrent : TorrentOptionsForm(torrent)
template.Template.globals["forms"].torrent_options = lambda torrent : TorrentOptionsForm(torrent)