Download:
child 40:1b7cd7e7ee7b
parent 38:c3db41612b8c
39:f435e3c69f4e
Anton Shestakov <av6@dwimlabs.net>, Sun, 27 Sep 2015 02:55:48 +0800
viewer: shorten usernames/emails by replacing domain part after @

2 файлов изменено, 10 вставок(+), 2 удалений(-) [+]
templates/results.html file | annotate | diff | comparison | revisions
viewer.py file | annotate | diff | comparison | revisions
--- a/templates/results.html Mon Aug 24 01:24:08 2015 +0800
+++ b/templates/results.html Sun Sep 27 02:55:48 2015 +0800
@@ -84,7 +84,7 @@
<td>{{ 'M' if len(cset['parents']) > 1 else '' }}</td>
<td>{{ cset['branch'] }}</td>
<td>{{ ', '.join(cset['tags']) }}</td>
- <td title="{{ cset['user'] }}">{{ cset['user'].partition(' <')[0] }}</td>
+ <td title="{{ showuser(cset['user']) }}">{{ showuser(cset['user'], short=True) }}</td>
<td class="hint"><div title="{{ cset['desc'] }}">{{ cset['desc'].partition('\n')[0] }}</div></td>
{% for mark in marks %}
{% set result = results.get(cset['node'], {}) %}
--- a/viewer.py Mon Aug 24 01:24:08 2015 +0800
+++ b/viewer.py Sun Sep 27 02:55:48 2015 +0800
@@ -27,6 +27,13 @@
return json.loads(output)
+def showuser(user, short=False, domainre=re.compile(r'@[^ >]+')):
+ user = domainre.sub('@...', user)
+ if short:
+ return user.partition(' <')[0]
+ return user
+
+
class BaseHandler(RequestHandler):
def prepare(self):
self.conn = sqlite3.connect(DBPATH)
@@ -207,7 +214,8 @@
'local': local,
'setlocal': self.setlocal,
'setrev': self.setrev,
- 'setmarks': self.setmarks(marks)
+ 'setmarks': self.setmarks(marks),
+ 'showuser': showuser
}
self.render('results.html', **context)