date in index #9
All checks were successful
Publish latest version / build (push) Successful in 50s
All checks were successful
Publish latest version / build (push) Successful in 50s
this could lead to a offset of one day max since we don't use the tz
This commit is contained in:
parent
ad7922c68f
commit
608e85bc93
3 changed files with 19 additions and 3 deletions
|
@ -13,7 +13,18 @@ def index() -> str:
|
||||||
"""index page"""
|
"""index page"""
|
||||||
posts = []
|
posts = []
|
||||||
if not Config.private or (Config.private and Config.is_logged()):
|
if not Config.private or (Config.private and Config.is_logged()):
|
||||||
posts = [p.split("/")[-1][:-4] for p in get_posts()]
|
for p in get_posts():
|
||||||
|
|
||||||
|
def titleify(s):
|
||||||
|
return s.split("/")[-1]
|
||||||
|
|
||||||
|
def linkify(s):
|
||||||
|
return ".".join(titleify(s).split(".")[:-1])
|
||||||
|
|
||||||
|
def datify(s):
|
||||||
|
return s[:-14] + " " + s[-4:]
|
||||||
|
|
||||||
|
posts.append((linkify(p), titleify(p), datify(get_post_cdate(p))))
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
"index.html",
|
"index.html",
|
||||||
|
|
|
@ -19,7 +19,8 @@
|
||||||
<ul>
|
<ul>
|
||||||
{% for p in posts: %}
|
{% for p in posts: %}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ config.sanitized_base() }}/read/{{ p }}">{{ p }}.txt</a>
|
<a href="{{ config.sanitized_base() }}/read/{{ p[0] }}">{{ p[1] }}</a>
|
||||||
|
({{ p[2] }})
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -51,7 +51,11 @@ def get_post(filename: str) -> File | None:
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
with open(filename, "r") as reader:
|
with open(filename, "r") as reader:
|
||||||
return File(reader.read(), ctime(os_path.getmtime(filename)))
|
return File(reader.read(), get_post_cdate(filename))
|
||||||
|
|
||||||
|
|
||||||
|
def get_post_cdate(filename: str) -> str:
|
||||||
|
return ctime(os_path.getmtime(filename))
|
||||||
|
|
||||||
|
|
||||||
def delete_post(filename: str) -> bool:
|
def delete_post(filename: str) -> bool:
|
||||||
|
|
Loading…
Reference in a new issue