From ad55fc510c6dc093d74657e5c8bef4e6da485dc8 Mon Sep 17 00:00:00 2001 From: freamon Date: Tue, 17 Dec 2024 12:50:29 +0000 Subject: [PATCH 01/14] Move code to hide duplicate cross-posts into PR #386 --- app/main/routes.py | 36 +++--------------------------------- 1 file changed, 3 insertions(+), 33 deletions(-) diff --git a/app/main/routes.py b/app/main/routes.py index ba64cf6e..aebf502c 100644 --- a/app/main/routes.py +++ b/app/main/routes.py @@ -116,39 +116,9 @@ def home_page(sort, view_filter): posts = posts.order_by(desc(Post.last_active)) # Pagination - if view_filter == 'subscribed' and current_user.is_authenticated and sort == 'new': - # use python list instead of DB query - posts = posts.all() - - # exclude extra cross-posts from feed - already_seen = [] - limit = 100 if not low_bandwidth else 50 - #i = -1 # option 1: don't exclude cross-posts - #i = min(limit - 1, len(posts) - 1) # option 2: exclude cross-posts from the first page only - i = min((limit * 10) - 1, len(posts) - 1) # option 3: exclude cross-posts across a 'magic number' of pages - #i = len(posts) - 1 # option 4: exclude all cross-posts ever - while i >= 0: - if not posts[i].cross_posts: - i -= 1 - continue - if posts[i].id in already_seen: - posts.pop(i) - else: - already_seen.extend(posts[i].cross_posts) - i -= 1 - - # paginate manually (can't use paginate()) - start = (page - 1) * limit - end = start + limit - posts = posts[start:end] - next_page = page + 1 if len(posts) == limit else None - previous_page = page - 1 if page != 1 else None - next_url = url_for('main.index', page=next_page, sort=sort, view_filter=view_filter) if next_page else None - prev_url = url_for('main.index', page=previous_page, sort=sort, view_filter=view_filter) if previous_page else None - else: - posts = posts.paginate(page=page, per_page=100 if current_user.is_authenticated and not low_bandwidth else 50, error_out=False) - next_url = url_for('main.index', page=posts.next_num, sort=sort, view_filter=view_filter) if posts.has_next else None - prev_url = url_for('main.index', page=posts.prev_num, sort=sort, view_filter=view_filter) if posts.has_prev and page != 1 else None + posts = posts.paginate(page=page, per_page=100 if current_user.is_authenticated and not low_bandwidth else 50, error_out=False) + next_url = url_for('main.index', page=posts.next_num, sort=sort, view_filter=view_filter) if posts.has_next else None + prev_url = url_for('main.index', page=posts.prev_num, sort=sort, view_filter=view_filter) if posts.has_prev and page != 1 else None # Active Communities active_communities = Community.query.filter_by(banned=False) From b8178b650c781d8a4450c88564ef6e0164660e6a Mon Sep 17 00:00:00 2001 From: hono4kami Date: Tue, 17 Dec 2024 18:15:36 +0700 Subject: [PATCH 02/14] fix: make community search page retain fields Make community search page retain `topic_id`, `language_id`, and `search` Refs: #362 --- app/templates/list_communities.html | 60 +++++++++++++++++++---------- 1 file changed, 39 insertions(+), 21 deletions(-) diff --git a/app/templates/list_communities.html b/app/templates/list_communities.html index 98416594..edf0675a 100644 --- a/app/templates/list_communities.html +++ b/app/templates/list_communities.html @@ -27,27 +27,45 @@
- {% if topics -%} -
Topic: - -
- {% endif -%} - {% if languages -%} -
Language: - -
- {% endif -%} -
+
+ {% if topics -%} +
+ Topic: + +
+ {% endif -%} + {% if languages -%} +
+ Language: + +
+ {% endif -%} +
+ +
+
From 3e91ee34f791c3973b735aa8913def73b1e3dee6 Mon Sep 17 00:00:00 2001 From: hono4kami Date: Tue, 17 Dec 2024 19:58:37 +0700 Subject: [PATCH 03/14] feat: make community search community name sort Refs: #362 --- app/templates/list_communities.html | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/templates/list_communities.html b/app/templates/list_communities.html index edf0675a..8f2b50f5 100644 --- a/app/templates/list_communities.html +++ b/app/templates/list_communities.html @@ -85,9 +85,18 @@ - {{ _('Community') }} + {{ _('Posts') }} From 61963a43dc354de9362a54b480e48a3484477bf3 Mon Sep 17 00:00:00 2001 From: hono4kami Date: Tue, 17 Dec 2024 20:03:13 +0700 Subject: [PATCH 04/14] feat: make community search retain post_count sort Refs: #362 --- app/templates/list_communities.html | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/templates/list_communities.html b/app/templates/list_communities.html index 8f2b50f5..919edbb4 100644 --- a/app/templates/list_communities.html +++ b/app/templates/list_communities.html @@ -99,9 +99,18 @@ - {{ _('Posts') }} + {{ _('Comments') }} From 8dd3d3de9330fdf3edf41725803e5219ab1b7905 Mon Sep 17 00:00:00 2001 From: hono4kami Date: Tue, 17 Dec 2024 20:06:52 +0700 Subject: [PATCH 05/14] feat: make community search retain sort method Make community search retain post_reply_count sort method. Refs: #362 --- app/templates/list_communities.html | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/templates/list_communities.html b/app/templates/list_communities.html index 919edbb4..d56119f9 100644 --- a/app/templates/list_communities.html +++ b/app/templates/list_communities.html @@ -116,6 +116,18 @@ {{ _('Comments') }} + {{ _('Active') }} From 8ffd02651ceed261f3716f12fd02918172e31781 Mon Sep 17 00:00:00 2001 From: hono4kami Date: Tue, 17 Dec 2024 20:08:40 +0700 Subject: [PATCH 06/14] chore: remove unused link on table header Refs: #362 --- app/templates/list_communities.html | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/templates/list_communities.html b/app/templates/list_communities.html index d56119f9..193bb3e0 100644 --- a/app/templates/list_communities.html +++ b/app/templates/list_communities.html @@ -113,9 +113,6 @@ - {{ _('Comments') }} - - - {{ _('Active') }} + From bad1839c148c0ac9fb1d42b3ca42e5b00dc3bb4a Mon Sep 17 00:00:00 2001 From: hono4kami Date: Tue, 17 Dec 2024 20:13:52 +0700 Subject: [PATCH 08/14] fix: fix title attribute Fix title attribute for the button on post count table column header. Refs: #362 --- app/templates/list_communities.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/list_communities.html b/app/templates/list_communities.html index 65659530..235d06c3 100644 --- a/app/templates/list_communities.html +++ b/app/templates/list_communities.html @@ -105,7 +105,7 @@ hx-include="form[action='/communities']" hx-target="body" hx-push-url="true" - title="{{ _('Sort by name') }}" + title="{{ _('Sort by post count') }}" class="btn" > {{ _('Posts') }} From 2d2e18abf753ad7ba4c287cdbb1e88283f7c3609 Mon Sep 17 00:00:00 2001 From: hono4kami Date: Tue, 17 Dec 2024 20:28:10 +0700 Subject: [PATCH 09/14] fix: fix can only search by All communities Refs: #362 --- app/templates/list_communities.html | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/templates/list_communities.html b/app/templates/list_communities.html index 235d06c3..cf945314 100644 --- a/app/templates/list_communities.html +++ b/app/templates/list_communities.html @@ -27,7 +27,8 @@
-
@@ -86,7 +87,7 @@