Add sort by newest option.

Signed-off-by: Ari Archer <ari@ari.lt>
This commit is contained in:
Arija A. 2025-02-01 21:01:24 +02:00
parent 5e4fd963c3
commit d47ba255f1
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: A50D5B4B599AF8A2
2 changed files with 13 additions and 5 deletions

View file

@ -79,13 +79,20 @@ def set_status() -> Response:
def index() -> str: def index() -> str:
"""Home page""" """Home page"""
return flask.render_template( if "newest" in flask.request.args:
"index.j2", comments = models.Comment.query.filter_by(confirmed=True).order_by(
visitor=models.Counter.first().inc().count, models.Comment.posted.desc(), # type: ignore
)
else:
comments = models.Comment.query.filter_by(confirmed=True).order_by( comments = models.Comment.query.filter_by(confirmed=True).order_by(
models.Comment.score.desc(), # type: ignore models.Comment.score.desc(), # type: ignore
models.Comment.posted.desc(), # type: ignore models.Comment.posted.desc(), # type: ignore
), )
return flask.render_template(
"index.j2",
visitor=models.Counter.first().inc().count,
comments=comments,
status=status, status=status,
comment=flask.request.args.get("gb"), comment=flask.request.args.get("gb"),
) )

View file

@ -516,7 +516,8 @@
</form> </form>
<div align="center"> <div align="center">
<i>Report any impersonation, illegal/graphic content, and/or anything disturbing to the owner of this website: Ari Archer.</i> <p><i>Report any impersonation, illegal/graphic content, and/or anything disturbing to the owner of this website: Ari Archer.</i></p>
<p><a href="/#gb">Sort by score</a> | <a href="/?newest#gb">Sort by newest</a></p>
</div> </div>
<div id="comments"> <div id="comments">