summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Glüpker <git@wgmd.de>2021-02-16 17:55:14 +0100
committerAndré Glüpker <git@wgmd.de>2021-02-16 17:55:14 +0100
commitc4db6130dcf2c78b3b0e05bc98d9a830a51dbfe3 (patch)
tree0bdecf78293e3eac8bd8d91adfdd7b573f3c8755
parent35cbe04e67ca59a657bc685f0764a7737115333d (diff)
downloadsteam-c4db6130dcf2c78b3b0e05bc98d9a830a51dbfe3.tar.gz
steam-c4db6130dcf2c78b3b0e05bc98d9a830a51dbfe3.tar.bz2
steam-c4db6130dcf2c78b3b0e05bc98d9a830a51dbfe3.zip
Change format_datetime to be a Jinja2 filter
-rwxr-xr-xmain.py5
-rw-r--r--templates/lobby_html.jinja2
-rw-r--r--templates/premades_html.jinja2
3 files changed, 4 insertions, 5 deletions
diff --git a/main.py b/main.py
index ae15acf..f5def41 100755
--- a/main.py
+++ b/main.py
@@ -53,6 +53,8 @@ def display_time(seconds, granularity=2):
result.append("{}{}".format(int(value), name))
return ' '.join(result[:granularity])
+app.jinja_env.filters['display_time'] = display_time
+
def grepSteamids(text):
steamids = []
SteamIDfromText = re.findall(r'STEAM_\d:(\d):(\d+)', text)
@@ -131,7 +133,6 @@ def lobby():
serverinfo = serverinfo,
gamelist = gamelist,
states = ['Offline', 'Online', 'Busy', 'Away', 'Snooze', 'Looking to trade', 'Looking to play'],
- display_time = display_time,
current_time = time.time())
@app.route("/premadefinder", methods=['GET', 'POST'])
@@ -166,7 +167,6 @@ def premades():
return render_template('premades_html.jinja',
steamids=steamids,
profiles=premadedata,
- display_time=display_time,
current_time = time.time(),
connections=connections
)
@@ -204,7 +204,6 @@ def server():
return render_template('server_html.jinja',
servers=servers,
- display_time = display_time
)
if __name__ == '__main__':
diff --git a/templates/lobby_html.jinja b/templates/lobby_html.jinja
index ae0000e..468a2fa 100644
--- a/templates/lobby_html.jinja
+++ b/templates/lobby_html.jinja
@@ -78,7 +78,7 @@
<span class="info">(non-steam)</span>
{% else %}
{% if profile['personastate'] == 0 %}
- <span class="{{ state }}">Offline since {{ display_time(current_time - profile['lastlogoff']) }}</span>
+ <span class="{{ state }}">Offline since {{ (current_time - profile['lastlogoff']) | display_time }}</span>
{% else %}
<span class="{{ state }}">{{ states[profile['personastate']] }}</span>
{% endif %}
diff --git a/templates/premades_html.jinja b/templates/premades_html.jinja
index c9ad464..7a45492 100644
--- a/templates/premades_html.jinja
+++ b/templates/premades_html.jinja
@@ -138,7 +138,7 @@
<img src="{{ profiles[steamid]['avatarmedium'] }}"><br />
{{ profiles[steamid]['personaname']|e }}
{% if 'timecreated' in profiles[steamid] %}
- <br />{{ display_time(current_time - profiles[steamid]['timecreated']) }}
+ <br />{{ (current_time - profiles[steamid]['timecreated']) | display_time }}
{% endif %}
</a>
</div>