From a362f3bb454ef6f43557ca0337268c55086252d9 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Thu, 31 Jul 2025 17:37:42 +0000
Subject: [PATCH 1/5] Initial plan
From d9a94f2b442bf16df56a272fe231565a5a6156c3 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Thu, 31 Jul 2025 17:51:10 +0000
Subject: [PATCH 2/5] Fix tech report pagination: Hide next/prev links based on
actual data, reset to page 1 on filter changes
Co-authored-by: max-ostapenko <1611259+max-ostapenko@users.noreply.github.com>
---
server/tests/routes_test.py | 26 ++++++++++++++++++++++++++
src/js/components/filters.js | 4 ++++
src/js/techreport/utils/data.js | 23 ++++++++++++++++++++++-
templates/techreport/category.html | 12 ++++--------
4 files changed, 56 insertions(+), 9 deletions(-)
diff --git a/server/tests/routes_test.py b/server/tests/routes_test.py
index 51c2303d..22f36c7e 100644
--- a/server/tests/routes_test.py
+++ b/server/tests/routes_test.py
@@ -257,6 +257,32 @@ def test_tech_report_category_pages_fallback(client):
assert response.status_code == 200
+def test_tech_report_category_pagination_links_initially_hidden(client):
+ """Test that pagination links are initially hidden and controlled by JavaScript."""
+ response = client.get("/reports/techreport/category?geo=ALL&rank=ALL&category=CMS")
+ assert response.status_code == 200
+ content = response.get_data(as_text=True)
+
+ # Check that pagination links exist but are initially hidden
+ assert 'data-pagination="next"' in content
+ assert 'data-pagination="previous"' in content
+ assert 'style="display: none;"' in content
+
+
+def test_tech_report_category_filters_reset_page_parameter(client):
+ """Test that the template doesn't rely on last_page parameter for pagination control."""
+ response = client.get(
+ "/reports/techreport/category?geo=ALL&rank=ALL&category=CMS&page=2"
+ )
+ assert response.status_code == 200
+ content = response.get_data(as_text=True)
+
+ # The Next page link should exist regardless of last_page parameter
+ assert 'data-pagination="next"' in content
+ # And should initially be hidden (JavaScript will control visibility)
+ assert 'style="display: none;"' in content
+
+
def test_well_known_atproto_did(client):
response = client.get("/.well-known/atproto-did")
assert response.status_code == 200
diff --git a/src/js/components/filters.js b/src/js/components/filters.js
index cfd02fcc..d66879ec 100644
--- a/src/js/components/filters.js
+++ b/src/js/components/filters.js
@@ -71,6 +71,10 @@ class Filters {
url.searchParams.append('category', categories);
}
+ // Reset to page 1 when filters change
+ url.searchParams.delete('page');
+ url.searchParams.append('page', '1');
+
// /* Scroll to the report content */
// url.hash = '#report-content';
diff --git a/src/js/techreport/utils/data.js b/src/js/techreport/utils/data.js
index b044d4a5..bab16828 100644
--- a/src/js/techreport/utils/data.js
+++ b/src/js/techreport/utils/data.js
@@ -239,8 +239,29 @@ const fetchCategoryData = (rows, filters, callback) => {
/* Update the pagination info */
const current = document.querySelectorAll('[data-page="current"]');
const total = document.querySelectorAll('[data-page="total"]');
+ const totalPages = Math.ceil(category?.technologies?.length / rows);
current.forEach(c => c.textContent = pageNr);
- total.forEach(t => t.textContent = Math.ceil(category?.technologies?.length / rows));
+ total.forEach(t => t.textContent = totalPages);
+
+ /* Update pagination links visibility */
+ const nextPageLink = document.querySelector('[data-pagination="next"]');
+ const prevPageLink = document.querySelector('[data-pagination="previous"]');
+
+ if (nextPageLink) {
+ if (pageNr >= totalPages) {
+ nextPageLink.style.display = 'none';
+ } else {
+ nextPageLink.style.display = 'block';
+ }
+ }
+
+ if (prevPageLink) {
+ if (pageNr <= 1) {
+ prevPageLink.style.display = 'none';
+ } else {
+ prevPageLink.style.display = 'block';
+ }
+ }
/* Update components */
callback(category);
diff --git a/templates/techreport/category.html b/templates/techreport/category.html
index 8b35ceaf..49d597e9 100644
--- a/templates/techreport/category.html
+++ b/templates/techreport/category.html
@@ -135,10 +135,8 @@
From 8188f5a90c63070328f9801f82422ff207099c25 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Thu, 31 Jul 2025 18:18:11 +0000
Subject: [PATCH 3/5] Fix linting errors: Remove whitespace from blank lines in
test file
Co-authored-by: max-ostapenko <1611259+max-ostapenko@users.noreply.github.com>
---
server/tests/routes_test.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/server/tests/routes_test.py b/server/tests/routes_test.py
index 22f36c7e..be55278e 100644
--- a/server/tests/routes_test.py
+++ b/server/tests/routes_test.py
@@ -262,7 +262,7 @@ def test_tech_report_category_pagination_links_initially_hidden(client):
response = client.get("/reports/techreport/category?geo=ALL&rank=ALL&category=CMS")
assert response.status_code == 200
content = response.get_data(as_text=True)
-
+
# Check that pagination links exist but are initially hidden
assert 'data-pagination="next"' in content
assert 'data-pagination="previous"' in content
@@ -276,7 +276,7 @@ def test_tech_report_category_filters_reset_page_parameter(client):
)
assert response.status_code == 200
content = response.get_data(as_text=True)
-
+
# The Next page link should exist regardless of last_page parameter
assert 'data-pagination="next"' in content
# And should initially be hidden (JavaScript will control visibility)
From 5ce059b4bbb2ec24f310976d207bda44bc399f1a Mon Sep 17 00:00:00 2001
From: Max Ostapenko <1611259+max-ostapenko@users.noreply.github.com>
Date: Thu, 31 Jul 2025 22:24:44 +0200
Subject: [PATCH 4/5] fix positioning
---
static/css/techreport/techreport.css | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/static/css/techreport/techreport.css b/static/css/techreport/techreport.css
index 22fc1ebe..5cb9a83f 100644
--- a/static/css/techreport/techreport.css
+++ b/static/css/techreport/techreport.css
@@ -1458,6 +1458,11 @@ select {
border-top: 1px solid var(--color-separator);
}
+.table-page-info {
+ margin-left: auto;
+ margin-right: auto;
+}
+
.table-page-info p {
text-align: center;
}
From 7b73466678fd5c5a0b26366a7fe873ff5a3eeb39 Mon Sep 17 00:00:00 2001
From: Max Ostapenko <1611259+max-ostapenko@users.noreply.github.com>
Date: Thu, 31 Jul 2025 22:25:09 +0200
Subject: [PATCH 5/5] cleanup
---
server/tests/routes_test.py | 26 --------------------------
src/js/techreport/utils/data.js | 16 +++++++---------
templates/techreport/category.html | 8 ++++++--
3 files changed, 13 insertions(+), 37 deletions(-)
diff --git a/server/tests/routes_test.py b/server/tests/routes_test.py
index be55278e..51c2303d 100644
--- a/server/tests/routes_test.py
+++ b/server/tests/routes_test.py
@@ -257,32 +257,6 @@ def test_tech_report_category_pages_fallback(client):
assert response.status_code == 200
-def test_tech_report_category_pagination_links_initially_hidden(client):
- """Test that pagination links are initially hidden and controlled by JavaScript."""
- response = client.get("/reports/techreport/category?geo=ALL&rank=ALL&category=CMS")
- assert response.status_code == 200
- content = response.get_data(as_text=True)
-
- # Check that pagination links exist but are initially hidden
- assert 'data-pagination="next"' in content
- assert 'data-pagination="previous"' in content
- assert 'style="display: none;"' in content
-
-
-def test_tech_report_category_filters_reset_page_parameter(client):
- """Test that the template doesn't rely on last_page parameter for pagination control."""
- response = client.get(
- "/reports/techreport/category?geo=ALL&rank=ALL&category=CMS&page=2"
- )
- assert response.status_code == 200
- content = response.get_data(as_text=True)
-
- # The Next page link should exist regardless of last_page parameter
- assert 'data-pagination="next"' in content
- # And should initially be hidden (JavaScript will control visibility)
- assert 'style="display: none;"' in content
-
-
def test_well_known_atproto_did(client):
response = client.get("/.well-known/atproto-did")
assert response.status_code == 200
diff --git a/src/js/techreport/utils/data.js b/src/js/techreport/utils/data.js
index bab16828..d9ce8311 100644
--- a/src/js/techreport/utils/data.js
+++ b/src/js/techreport/utils/data.js
@@ -246,15 +246,6 @@ const fetchCategoryData = (rows, filters, callback) => {
/* Update pagination links visibility */
const nextPageLink = document.querySelector('[data-pagination="next"]');
const prevPageLink = document.querySelector('[data-pagination="previous"]');
-
- if (nextPageLink) {
- if (pageNr >= totalPages) {
- nextPageLink.style.display = 'none';
- } else {
- nextPageLink.style.display = 'block';
- }
- }
-
if (prevPageLink) {
if (pageNr <= 1) {
prevPageLink.style.display = 'none';
@@ -262,6 +253,13 @@ const fetchCategoryData = (rows, filters, callback) => {
prevPageLink.style.display = 'block';
}
}
+ if (nextPageLink) {
+ if (pageNr >= totalPages) {
+ nextPageLink.style.display = 'none';
+ } else {
+ nextPageLink.style.display = 'block';
+ }
+ }
/* Update components */
callback(category);
diff --git a/templates/techreport/category.html b/templates/techreport/category.html
index 49d597e9..31331f03 100644
--- a/templates/techreport/category.html
+++ b/templates/techreport/category.html
@@ -136,7 +136,9 @@