add timestamp macro
This commit is contained in:
		@@ -7,6 +7,7 @@ from .constants import (
 | 
			
		||||
    PermissionLevel,
 | 
			
		||||
    InfoboxKind, InfoboxIcons, InfoboxHTMLClass
 | 
			
		||||
    )
 | 
			
		||||
from datetime import datetime
 | 
			
		||||
import os
 | 
			
		||||
import time
 | 
			
		||||
import secrets
 | 
			
		||||
@@ -92,4 +93,8 @@ def create_app():
 | 
			
		||||
    def inject_auth():
 | 
			
		||||
        return {"is_logged_in": is_logged_in, "get_active_user": get_active_user, "active_user": get_active_user()}
 | 
			
		||||
 | 
			
		||||
    @app.template_filter("ts_datetime")
 | 
			
		||||
    def ts_datetime(ts, format):
 | 
			
		||||
        return datetime.utcfromtimestamp(ts).strftime(format)
 | 
			
		||||
 | 
			
		||||
    return app
 | 
			
		||||
 
 | 
			
		||||
@@ -25,4 +25,5 @@
 | 
			
		||||
  </footer>
 | 
			
		||||
  <script src="/static/js/copy-code.js"></script>
 | 
			
		||||
  <script src="/static/js/ui.js"></script>
 | 
			
		||||
  <script src="/static/js/date-fmt.js"></script>
 | 
			
		||||
</body>
 | 
			
		||||
 
 | 
			
		||||
@@ -38,3 +38,7 @@
 | 
			
		||||
  </span>
 | 
			
		||||
</div>
 | 
			
		||||
{% endmacro %}
 | 
			
		||||
 | 
			
		||||
{% macro timestamp(unix_ts) %}
 | 
			
		||||
<span class="timestamp" data-utc="{{ unix_ts }}">{{ unix_ts | ts_datetime('%Y-%m-%d %H:%M')}} ST</span>
 | 
			
		||||
{% endmacro %}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
{% from 'common/macros.html' import pager %}
 | 
			
		||||
{% from 'common/macros.html' import pager, timestamp %}
 | 
			
		||||
{% extends "base.html" %}
 | 
			
		||||
{% block title %}browsing topic {{ topic['name'] }}{% endblock %}
 | 
			
		||||
{% block content %}
 | 
			
		||||
@@ -30,11 +30,11 @@
 | 
			
		||||
        <span>
 | 
			
		||||
          <span class="thread-title"><a href="{{ url_for("threads.thread", slug=thread['slug']) }}">{{thread['title']}}</a></span>
 | 
			
		||||
          •
 | 
			
		||||
          Started by <a href="{{ url_for("users.page", username=thread['started_by']) }}">{{ thread['started_by'] }}</a> on ...
 | 
			
		||||
          Started by <a href="{{ url_for("users.page", username=thread['started_by']) }}">{{ thread['started_by'] }}</a> on {{ timestamp(thread['created_at'])}}
 | 
			
		||||
        </span>
 | 
			
		||||
        <span>
 | 
			
		||||
          Latest post by <a href="{{ url_for("users.page", username=thread['latest_post_username']) }}">{{ thread['latest_post_username'] }}</a>
 | 
			
		||||
          on ...
 | 
			
		||||
          on <a href="{{ url_for("threads.thread", slug=thread['slug']) }}">on {{ timestamp(thread['latest_post_created_at'] )}}</a>:
 | 
			
		||||
        </span>
 | 
			
		||||
        <span class="thread-info-post-preview">
 | 
			
		||||
          {{ thread['latest_post_content'] }}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,4 @@
 | 
			
		||||
{% from 'common/macros.html' import timestamp %}
 | 
			
		||||
{% extends 'base.html' %}
 | 
			
		||||
{% block title %}{{ target_user.username }}'s profile{% endblock %}
 | 
			
		||||
{% block content %}
 | 
			
		||||
@@ -17,9 +18,9 @@
 | 
			
		||||
  {% if active_user and active_user.is_mod() and not target_user.is_system() %}
 | 
			
		||||
    <h1 class="thread-title">Moderation controls</h1>
 | 
			
		||||
    {% if target_user.is_guest() %}
 | 
			
		||||
      <p>This user is a guest. They signed up on ... </p>
 | 
			
		||||
      <p>This user is a guest. They signed up on {{ timestamp(target_user['created_at']) }}</p>
 | 
			
		||||
    {% else %}
 | 
			
		||||
      <p>This user signed up on ... and was confirmed on ...</p>
 | 
			
		||||
      <p>This user signed up on {{ timestamp(target_user['created_at']) }} and was confirmed on {{ timestamp(target_user['confirmed_on']) }}</p>
 | 
			
		||||
    {% endif %}
 | 
			
		||||
  {% endif %}
 | 
			
		||||
</div>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user