diff options
| author | Alon Levy <alon@pobox.com> | 2015-01-21 17:29:31 +0200 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2015-01-21 17:36:59 +0200 |
| commit | f7932d4ded03ee98092882541f1fad4c055935f4 (patch) | |
| tree | e20c4baeb3febcf7c02278e315bf4027708666ee /src/server/rz_api.py | |
| parent | 0f3649984c5dc29ef1909511bca5b9a2744fb192 (diff) | |
templates/index: move username and initials setting to server. Fixes #286
Diffstat (limited to 'src/server/rz_api.py')
| -rw-r--r-- | src/server/rz_api.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/server/rz_api.py b/src/server/rz_api.py index 98d46136..8b7ac825 100644 --- a/src/server/rz_api.py +++ b/src/server/rz_api.py @@ -150,10 +150,23 @@ def monitor__server_info(): "time: " + dt.strftime("%H:%M:%S") + "<br>" + \ "</p></body></html>" +def username_initials(username): + """ + return two letter (always) initials of username. + we do it here rather then on the client side to avoid rendering twice, once + 'annonymous' and later the real name, because of loading delays + """ + words = username.split(' ') + first_initial = words[0][0] if len(words) >= 1 and len(words[0]) >= 1 else ' ' + second_initial = (words[1][0] if len(words) >= 2 and len(words[1]) >= 1 else + (words[0][1] if len(words) >= 1 and len(words[0]) > 1 else '_')) + return (first_initial + second_initial).upper() + def index(): session_username = session.get('username') username = escape(session_username if session_username != None else "Anonymous Stranger") - return render_template('index.html', username=username) + profileinitials = username_initials(username) + return render_template('index.html', username=username, profileinitials=profileinitials) def login(): |
