From 9760fc88e47dae2fd5a2bb33dbcf6988e7ba122c Mon Sep 17 00:00:00 2001 From: Alfie King Date: Tue, 22 Apr 2025 14:50:55 +0100 Subject: [PATCH] better formatting --- src/database.py | 4 +++- src/html/board.html | 13 ++++++++++--- src/html/index.html | 13 ++++++++++--- src/html/post.html | 11 +++++++++-- src/html/posts.html | 13 ++++++++++--- 5 files changed, 42 insertions(+), 12 deletions(-) diff --git a/src/database.py b/src/database.py index 94c9093..715c00d 100644 --- a/src/database.py +++ b/src/database.py @@ -327,6 +327,7 @@ class Database: data = { 'id': post[0], 'content': post[3], + 'short_content': post[3][:40] + '...' if len(post[3]) > 40 else post[3], 'created_at': post[4], 'url': f"/post/{post[0]}", } @@ -389,6 +390,7 @@ class Database: data['reference'] = { 'id': reference_post[0], 'content': reference_post[3], + 'short_content': reference_post[3][:20] + '...' if len(reference_post[3]) > 20 else reference_post[3], 'created_at': reference_post[4] } logger.info(f"Reference post information found for post {post[0]}.") @@ -538,7 +540,7 @@ class Database: if boards: logger.info(f"Boards found.") # Convert boards to dictionary - boards = [{"id": board[0], "name": board[1]} for board in boards] + boards = [{"id": board[0], "name": board[1]} for board in boards].sort(key=lambda x: x['name']) return boards logger.warning(f"No boards found.") return None \ No newline at end of file diff --git a/src/html/board.html b/src/html/board.html index b6050c9..d39d345 100644 --- a/src/html/board.html +++ b/src/html/board.html @@ -12,10 +12,17 @@

From {{ post.user.name }}

posted at {{ post.created_at }}
{% if post.reference %} -
ref post: {{ post.reference.content }}
+
ref post: {{ post.reference.short_content }}
{% endif %} -

{{ post.content }}

-
View Post
+

{{ post.short_content }}

+
View Post + {% if post.replies|length > 0 %} + | ({{ post.replies|length }} replies) + {% endif %} + {% if session.name == "SYSTEM" %} + | Delete + {% endif %} +
{% endfor %} {% if board.posts|length == 0 %} diff --git a/src/html/index.html b/src/html/index.html index 42c1bfd..e9e3335 100644 --- a/src/html/index.html +++ b/src/html/index.html @@ -11,10 +11,17 @@

From {{ post.user.name }} in /{{ post.board.name }}/

posted at {{ post.created_at }}
{% if post.reference %} -
ref post: {{ post.reference.content }}
+
ref post: {{ post.reference.short_content }}
{% endif %} -

{{ post.content }}

-
View Post
+

{{ post.short_content }}

+
View Post + {% if post.replies|length > 0 %} + | ({{ post.replies|length }} replies) + {% endif %} + {% if session.name == "SYSTEM" %} + | Delete + {% endif %} +
{% endfor %} {% if posts|length == 0 %} diff --git a/src/html/post.html b/src/html/post.html index 7d2dd41..21559ca 100644 --- a/src/html/post.html +++ b/src/html/post.html @@ -14,8 +14,15 @@
  • From {{ reply.user.name }} in /{{ reply.board.name }}/

    posted at {{ reply.created_at }}
    -

    {{ reply.content }}

    -
    View Reply
    +

    {{ reply.short_content }}

    +
    View Reply + {% if post.replies|length > 0 %} + | ({{ post.replies|length }} replies) + {% endif %} + {% if session.name == "SYSTEM" %} + | Delete + {% endif %} +
  • {% endfor %} {% if post.replies|length == 0 %} diff --git a/src/html/posts.html b/src/html/posts.html index 68b435a..ccc57dd 100644 --- a/src/html/posts.html +++ b/src/html/posts.html @@ -10,10 +10,17 @@

    From {{ post.user.name }} in /{{ post.board.name }}/

    posted at {{ post.created_at }}
    {% if post.reference %} -
    ref post: {{ post.reference.content }}
    +
    ref post: {{ post.reference.short_content }}
    {% endif %} -

    {{ post.content }}

    -
    View post
    +

    {{ post.short_content }}

    +
    View post + {% if post.replies|length > 0 %} + | ({{ post.replies|length }} replies) + {% endif %} + {% if session.name == "SYSTEM" %} + | Delete + {% endif %} +
    {% endfor %} {% if posts|length == 0 %}