new inbox view

This commit is contained in:
2025-08-04 02:57:51 +03:00
parent 6e86832211
commit 2e8fd9a22e
7 changed files with 74 additions and 60 deletions

View File

@ -117,11 +117,11 @@ def create_app():
return datetime.utcfromtimestamp(ts or int(time.time())).strftime(format) return datetime.utcfromtimestamp(ts or int(time.time())).strftime(format)
@app.template_filter("pluralize") @app.template_filter("pluralize")
def pluralize(number, singular = "", plural = "s"): def pluralize(subject, num=1, singular = "", plural = "s"):
if number == 1: if int(num) == 1:
return singular return subject + singular
return plural return subject + plural
@app.template_filter("permission_string") @app.template_filter("permission_string")
def permission_string(term): def permission_string(term):

View File

@ -178,7 +178,7 @@
{% endif %} {% endif %}
<div class="accordion {{ "hidden" if hidden else ""}}" style="{{style}}"> <div class="accordion {{ "hidden" if hidden else ""}}" style="{{style}}">
<div class="accordion-header"> <div class="accordion-header">
<button type="button" class="accordion-toggle" {{"disabled" if disabled else ""}}>{{ "" if hidden else "" }}</button> <button type="button" class="accordion-toggle" {{"disabled" if disabled else ""}}>{{ "+" if hidden else "-" }}</button>
{{ caller('header') }} {{ caller('header') }}
</div> </div>
<div class="accordion-content {{ "hidden" if hidden else "" }}"> <div class="accordion-content {{ "hidden" if hidden else "" }}">

View File

@ -8,7 +8,7 @@
{% if section == "header" %} {% if section == "header" %}
<span>Unconfirmed guests</span> <span>Unconfirmed guests</span>
{% elif section == "content" %} {% elif section == "content" %}
<table class="users-table"> <table class="colorful-table">
<thead> <thead>
<th>Username</th> <th>Username</th>
<th class="small">Signed up on</th> <th class="small">Signed up on</th>
@ -32,7 +32,7 @@
{% if section == "header" %} {% if section == "header" %}
<span>Other users</span> <span>Other users</span>
{% elif section == "content" %} {% elif section == "content" %}
<table class="users-table"> <table class="colorful-table">
<thead> <thead>
<th>Username</th> <th>Username</th>
<th class="small">Permission</th> <th class="small">Permission</th>

View File

@ -1,34 +1,48 @@
{% from "common/macros.html" import timestamp, full_post %} {% from "common/macros.html" import timestamp, full_post, accordion %}
{% extends "base.html" %} {% extends "base.html" %}
{% block title %}inbox{% endblock %} {% block title %}inbox{% endblock %}
{% block content %} {% block content %}
<div class="inbox-container"> <div class="darkbg inbox-container">
{% if all_subscriptions is none %} {% set has_subscriptions = all_subscriptions is not none %}
You have no subscriptions.<br> {% call(section) accordion(disabled=not has_subscriptions) %}
{% if section == "header" %}
{% if not has_subscriptions %}
(You have no subscriptions)
{% else %} {% else %}
Your subscriptions: Your subscriptions
<ul> {% endif %}
{% elif section == "content" and has_subscriptions %}
<table class="colorful-table">
<thead>
<th>Thread</th>
<th class="small">Unsubscribe</th>
</thead>
{% for sub in all_subscriptions %} {% for sub in all_subscriptions %}
<li> <tr>
<td>
<a href=" {{ url_for("threads.thread", slug=sub.thread_slug) }} ">{{ sub.thread_title }}</a> <a href=" {{ url_for("threads.thread", slug=sub.thread_slug) }} ">{{ sub.thread_title }}</a>
</td>
<td>
<form class="modform" method="post" action="{{ url_for("threads.subscribe", slug = sub.thread_slug) }}"> <form class="modform" method="post" action="{{ url_for("threads.subscribe", slug = sub.thread_slug) }}">
<input type="hidden" name="subscribe" value="unsubscribe"> <input type="hidden" name="subscribe" value="unsubscribe">
<input class="warn" type="submit" value="Unsubscribe"> <input class="warn" type="submit" value="Unsubscribe">
</form> </form>
</li> </td>
</tr>
{% endfor %} {% endfor %}
</ul> </table>
{% endif %} {% endif %}
{% endcall %}
{% if has_subscriptions %}
{% if not new_posts %} {% if not new_posts %}
You have no unread posts. You have no unread posts.
{% else %} {% else %}
You have {{ total_unreads_count }} unread post{{(total_unreads_count | int) | pluralize }}: You have {{ total_unreads_count }} total unread {{("post" | pluralize(num=total_unreads_count))}}:
{% for thread in new_posts %} {% for thread in new_posts %}
<div class="accordion"> {% call(section) accordion() %}
<div class="accordion-header"> {% if section == "header" %}
<button type="button" class="accordion-toggle"></button>
{% set latest_post_id = thread.posts[-1].id %} {% set latest_post_id = thread.posts[-1].id %}
{% set unread_posts_text = " (" + (thread.unread_count | string) + (" unread post" | pluralize) %} {% set unread_posts_text = " (" + (thread.unread_count | string) + (" unread post" | pluralize(num=thread.unread_count)) %}
<a class="accordion-title" href="{{ url_for("threads.thread", slug=latest_post_slug, after=latest_post_id, _anchor="post-" + (latest_post_id | string)) }}" title="Jump to latest post">{{thread.thread_title + unread_posts_text}}, latest at {{ timestamp(thread.newest_post_time) }})</a> <a class="accordion-title" href="{{ url_for("threads.thread", slug=latest_post_slug, after=latest_post_id, _anchor="post-" + (latest_post_id | string)) }}" title="Jump to latest post">{{thread.thread_title + unread_posts_text}}, latest at {{ timestamp(thread.newest_post_time) }})</a>
<form class="modform" method="post" action="{{ url_for("threads.subscribe", slug = thread.thread_slug) }}"> <form class="modform" method="post" action="{{ url_for("threads.subscribe", slug = thread.thread_slug) }}">
<input type="hidden" name="subscribe" value="read"> <input type="hidden" name="subscribe" value="read">
@ -38,14 +52,14 @@
<input type="hidden" name="subscribe" value="unsubscribe"> <input type="hidden" name="subscribe" value="unsubscribe">
<input class="warn" type="submit" value="Unsubscribe"> <input class="warn" type="submit" value="Unsubscribe">
</form> </form>
</div> {% elif section == "content" %}
<div class="accordion-content">
{% for post in thread.posts %} {% for post in thread.posts %}
{{ full_post(post, no_reply = true) }} {{ full_post(post, no_reply = true) }}
{% endfor %} {% endfor %}
</div> {% endif %}
</div> {% endcall %}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% endif %}
</div> </div>
{% endblock %} {% endblock %}

View File

@ -120,7 +120,7 @@ document.addEventListener("DOMContentLoaded", () => {
e.stopPropagation(); e.stopPropagation();
accordion.classList.toggle("hidden"); accordion.classList.toggle("hidden");
content.classList.toggle("hidden"); content.classList.toggle("hidden");
toggleButton.textContent = content.classList.contains("hidden") ? "" : "" toggleButton.textContent = content.classList.contains("hidden") ? "+" : "-"
} }
toggleButton.addEventListener("click", toggle); toggleButton.addEventListener("click", toggle);

View File

@ -570,25 +570,25 @@ input[type=text]:focus, input[type=password]:focus, textarea:focus, select:focus
border-collapse: collapse; border-collapse: collapse;
} }
.users-table { .colorful-table {
border-collapse: collapse; border-collapse: collapse;
width: 100%; width: 100%;
margin: 10px 0; margin: 10px 0;
overflow: hidden; overflow: hidden;
} }
.users-table tr th { .colorful-table tr th {
background-color: #beb1ce; background-color: #beb1ce;
padding: 5px 0; padding: 5px 0;
} }
.users-table tr td { .colorful-table tr td {
background-color: rgb(177, 206, 204.5); background-color: rgb(177, 206, 204.5);
padding: 5px 0; padding: 5px 0;
text-align: center; text-align: center;
} }
.users-table .small { .colorful-table .small {
width: 250px; width: 250px;
} }

View File

@ -567,25 +567,25 @@ input[type="text"], input[type="password"], textarea, select {
border-collapse: collapse; border-collapse: collapse;
} }
.users-table { .colorful-table {
border-collapse: collapse; border-collapse: collapse;
width: 100%; width: 100%;
margin: 10px 0; margin: 10px 0;
overflow: hidden; overflow: hidden;
} }
.users-table tr th { .colorful-table tr th {
background-color: $button_color2; background-color: $button_color2;
padding: 5px 0; padding: 5px 0;
} }
.users-table tr td { .colorful-table tr td {
background-color: $button_color; background-color: $button_color;
padding: 5px 0; padding: 5px 0;
text-align: center; text-align: center;
} }
.users-table .small { .colorful-table .small {
width: 250px; width: 250px;
} }