From 5ccf2b593f5deebb219cc36f1a089c3238ba82fe Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Sat, 23 Mar 2024 21:57:17 +0000 Subject: Dates --- model.py | 6 +++++- static/wiki.css | 4 ++++ views/history.tpl | 2 +- views/page.tpl | 12 ++++++------ wiki.py | 4 ++-- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/model.py b/model.py index b4147e1..b4e0b1c 100644 --- a/model.py +++ b/model.py @@ -17,6 +17,10 @@ def bootstrap_db(db): class Page(object): + @classmethod + def now(cls): + return datetime.utcnow().isoformat(sep=" ", timespec="seconds") + def __init__( self, name="WikiHome", @@ -26,7 +30,7 @@ class Page(object): updated_at=None, history=False, ): - now = datetime.utcnow() + now = Page.now() if updated_at is None: updated_at = now diff --git a/static/wiki.css b/static/wiki.css index cca58c8..68af565 100644 --- a/static/wiki.css +++ b/static/wiki.css @@ -2,6 +2,10 @@ body { min-width: 1024px; } +nav a { + margin-right: 0.5em; +} + #content { background-color: var(--background-alt); padding: 1em; diff --git a/views/history.tpl b/views/history.tpl index 5e0d42a..2fb2019 100644 --- a/views/history.tpl +++ b/views/history.tpl @@ -9,7 +9,7 @@ % else: (no changelog) % end -
Updated on {{h.updated_at}} +
Edited on {{h.updated_at}} % end diff --git a/views/page.tpl b/views/page.tpl index 67b73aa..c577886 100644 --- a/views/page.tpl +++ b/views/page.tpl @@ -5,17 +5,17 @@ % else: {{!page.render()}}
-

+

Last edited {{page.updated_at}}

+ % end % include('footer.tpl') diff --git a/wiki.py b/wiki.py index 6c1cf04..c629953 100644 --- a/wiki.py +++ b/wiki.py @@ -31,7 +31,7 @@ if DEV: # check two words pascal case -app.router.add_filter('pc', lambda conf: (r'[A-Z][a-z]+[A-Z][a-z]*', None, None)) +app.router.add_filter("pc", lambda conf: (r"[A-Z][a-z]+[A-Z][a-z]*", None, None)) @app.route("/") @@ -75,7 +75,7 @@ def edit_save(db, name): page = model.get_page(db, name) if page.version is not None: - page.updated_at = datetime.utcnow() + page.updated_at = model.Page.now() page.content = request.forms.get("content") page.changelog = request.forms.get("changelog") page.version = md5(str(page.updated_at).encode()).hexdigest() -- cgit v1.2.3