diff --git a/forum/main.py b/forum/main.py index c9dabf6..aa8568e 100644 --- a/forum/main.py +++ b/forum/main.py @@ -848,40 +848,30 @@ def utility_processor(): # Try the sane thing first dt = (n - t) // 10**9 if dt < 1: - return "less than a second" + return "less than a second ago" if dt < 2: - return f"1 second" + return f"1 second ago" if dt < 60: - return f"{dt} seconds" + return f"{dt} seconds ago" if dt < 119: - return f"1 minute" + return f"1 minute ago" if dt < 3600: - return f"{dt // 60} minutes" - if dt < 3600 * 2: - return f"1 hour" + return f"{dt // 60} minutes ago" if dt < 3600 * 24: - return f"{dt // 3600} hours" + return f"{dt // 3600} hours ago" + if dt < 3600 * 24 * 7: + return f"{dt // (3600 * 24)} days ago" if dt < 3600 * 24 * 31: - return f"{dt // (3600 * 24)} days" + return f"{dt // (3600 * 24 * 7)} weeks ago" - # Try some very rough estimate, whatever - f = lambda x: datetime.utcfromtimestamp(x // 10**9) - n, t = f(n), f(t) - - def f(x, y, s): - return f'{y - x} {s}{"s" if y - x > 1 else ""}' - - if t.year < n.year: - return f(t.year, n.year, "year") - if t.month < n.month: - return f(t.month, n.month, "month") - assert False, "unreachable" + as_datetime = datetime.fromtimestamp(t // 10**9) + return as_datetime.strftime("%Y-%m-%d %H:%M") def format_since(t): n = time.time_ns() if n < t: return "in a distant future" - return _format_time_delta(n, t) + " ago" + return _format_time_delta(n, t) def format_until(t): n = time.time_ns() @@ -890,7 +880,7 @@ def utility_processor(): return _format_time_delta(t, n) def format_time(t): - return datetime.utcfromtimestamp(t / 10**9).replace(microsecond=0) + return datetime.fromtimestamp(t / 10**9).replace(microsecond=0) def rand_password(): """ diff --git a/forum/static/theme.css b/forum/static/theme.css index 56a4ce6..949a219 100644 --- a/forum/static/theme.css +++ b/forum/static/theme.css @@ -57,10 +57,11 @@ th, td { textarea { width: min(100%, 500px); - height: 15em; + height: 25em; font-size: 1em; } + input[type=text], input[type=password] { width: min(100%, 20em); font-family: monospace; @@ -211,8 +212,21 @@ table.form > * > tr > td, th { display: block; } - /* Admin */ .admin_h2 { background-color: rgba(0,0,0,0.15); } + +main.admin { + width: 95%; + margin: auto; +} + +main.admin textarea { + height: 5em; +} +.config_label { + max-width: 15em; + width: 15em; +} + diff --git a/forum/templates/admin/base.html b/forum/templates/admin/base.html index 97560be..e765677 100644 --- a/forum/templates/admin/base.html +++ b/forum/templates/admin/base.html @@ -11,13 +11,18 @@ {%- endif -%} + +

{{ title }}

-

- « Forum Home - | Admin panel -

+ {%- for category, msg in get_flashed_messages(True) -%}

{{ msg }}

{%- endfor %} {%- block content %}{% endblock -%} +
diff --git a/forum/templates/admin/index.html b/forum/templates/admin/index.html index b369cb7..6fb9337 100644 --- a/forum/templates/admin/index.html +++ b/forum/templates/admin/index.html @@ -44,8 +44,8 @@

Add user

- - + +
Name
Password
Name
Password
@@ -82,11 +82,11 @@
- + - +
NameName
DescriptionDescription
@@ -99,27 +99,27 @@ - + - + - + - + - + - +
Server nameServer name
Server descriptionServer description
Registration enabledRegistration enabled
Login requiredLogin required
Number of threads per pageNumber of threads per page
User defined CSS file in static/ folderUser defined CSS file in static/ folder