From e3e195ea07fd57288d32c842689ebed7fba636f0 Mon Sep 17 00:00:00 2001 From: Dennis Fink Date: Wed, 18 Nov 2026 17:41:44 +0100 Subject: style(core): improve mobile table layouts Hide secondary received and sent table columns below the `md` breakpoint while keeping status, primary identifiers, details, and actions accessible. Add responsive wrappers, mobile received timestamps, and wrapping for long paths and URLs to improve small-screen readability. --- tests/forms/test_validators.py | 7 +- tests/views/test_received.py | 51 ++++--- tests/views/test_sources.py | 47 +++++++ webmentions_ssg/templates/dashboard.html | 4 - webmentions_ssg/templates/received.html | 35 +++-- webmentions_ssg/templates/sent.html | 98 ++++++------- webmentions_ssg/templates/sent_source.html | 215 +++++++++++++++-------------- 7 files changed, 262 insertions(+), 195 deletions(-) diff --git a/tests/forms/test_validators.py b/tests/forms/test_validators.py index 8822310..2c427d3 100644 --- a/tests/forms/test_validators.py +++ b/tests/forms/test_validators.py @@ -28,8 +28,11 @@ def test_allowed_hostname_accepts_configured_hostname(app: Flask) -> None: def test_allowed_hostname_rejects_unconfigured_hostname(app: Flask) -> None: app.config["ALLOWED_TARGET_HOSTNAMES"] = ["dennisfink.me"] form = URLForm(MultiDict({"url": "https://example.com/post"})) - with app.app_context(), pytest.raises( - ValidationError, match="Target hostname is not in ALLOWED_TARGET_HOSTNAMES" + with ( + app.app_context(), + pytest.raises( + ValidationError, match="Target hostname is not in ALLOWED_TARGET_HOSTNAMES" + ), ): AllowedTargetHostname()(form, form.url) diff --git a/tests/views/test_received.py b/tests/views/test_received.py index 5ae42f7..1a291ae 100644 --- a/tests/views/test_received.py +++ b/tests/views/test_received.py @@ -56,6 +56,32 @@ def test_received_lists_webmentions(app: Flask, client: FlaskClient) -> None: assert TARGET_URL in html +def test_received_table_hides_secondary_columns_on_mobile( + app: Flask, client: FlaskClient +) -> None: + log_in(app, client) + create_received_webmention(app) + + response = client.get("/received") + + assert response.status_code == HTTPStatus.OK + html = BeautifulSoup(response.get_data(as_text=True), "html.parser") + table = html.select_one(".table-responsive > table") + assert table is not None + headers = table.select("thead th") + cells = table.select("tbody tr:first-child td") + assert len(headers) == len(cells) == 7 + for index in (0, 3, 4, 5): # Select, target, received, updated + for cell in (headers[index], cells[index]): + assert {"d-none", "d-md-table-cell"} <= set(cell.get("class", [])) + for index in (1, 2, 6): # Status, source, details stay visible + assert "d-none" not in cells[index].get("class", []) + assert cells[2].select_one(".d-md-none time") is not None + assert "text-break" in cells[2].get("class", []) + for button in html.select("[data-received-bulk-action]"): + assert {"d-none", "d-md-inline-block"} <= set(button.get("class", [])) + + @pytest.mark.parametrize( ("filter_status", "expected_statuses"), [ @@ -1125,31 +1151,15 @@ def test_received_detail_shows_full_reason_timestamps_and_public_status( @pytest.mark.parametrize( ("reason", "explanation", "next_step"), [ - ( - "Source does not mention target", - "does not contain a recognized link", - None, - ), - ( - "Source returned HTTP 404", - "source page was not found", - None, - ), - ( - "Source returned HTTP 503", - "source server returned a server error", - None, - ), + ("Source does not mention target", "does not contain a recognized link", None), + ("Source returned HTTP 404", "source page was not found", None), + ("Source returned HTTP 503", "source server returned a server error", None), ( "Source hostname could not be resolved", "could not be resolved through DNS", None, ), - ( - "Source document is too large", - "configured maximum response size", - None, - ), + ("Source document is too large", "configured maximum response size", None), ( "Source domain is blocked", "receiver's blocklist", @@ -1197,7 +1207,6 @@ def test_received_detail_only_suggests_receiver_controlled_steps( assert reason in details.get_text() - def test_received_detail_explains_historical_failure_and_escapes_raw_text( app: Flask, client: FlaskClient ) -> None: diff --git a/tests/views/test_sources.py b/tests/views/test_sources.py index 012347e..673fc9f 100644 --- a/tests/views/test_sources.py +++ b/tests/views/test_sources.py @@ -9,6 +9,7 @@ from types import ModuleType from unittest.mock import Mock import pytest +from bs4 import BeautifulSoup from flask import Flask from flask.testing import FlaskClient @@ -56,6 +57,29 @@ def test_sent_lists_sources(app: Flask, client: FlaskClient) -> None: assert f"/sources/{identifier}" in html +def test_sent_sources_table_hides_secondary_columns_on_mobile( + app: Flask, client: FlaskClient +) -> None: + log_in(app, client) + create_sent_source(app) + + response = client.get("/sources") + + assert response.status_code == HTTPStatus.OK + html = BeautifulSoup(response.get_data(as_text=True), "html.parser") + table = html.select_one(".table-responsive > table") + assert table is not None + headers = table.select("thead th") + cells = table.select("tbody tr:first-child td") + assert len(headers) == len(cells) == 7 + for index in (1, 3, 4, 5): # URL, revision, created, last seen + for cell in (headers[index], cells[index]): + assert {"d-none", "d-md-table-cell"} <= set(cell.get("class", [])) + for index in (0, 2, 6): # Path, count, status stay visible + assert "d-none" not in cells[index].get("class", []) + assert "text-break" in cells[0].get("class", []) + + def test_sent_source_lists_webmentions(app: Flask, client: FlaskClient) -> None: log_in(app, client) identifier = create_sent_source(app) @@ -80,6 +104,29 @@ def test_sent_source_lists_webmentions(app: Flask, client: FlaskClient) -> None: assert "https://example.com/webmention" in html +def test_sent_webmentions_table_keeps_status_and_actions_on_mobile( + app: Flask, client: FlaskClient +) -> None: + log_in(app, client) + identifier = create_sent_source(app) + + response = client.get(f"/sources/{identifier}") + + assert response.status_code == HTTPStatus.OK + html = BeautifulSoup(response.get_data(as_text=True), "html.parser") + table = html.select_one(".table-responsive > table") + assert table is not None + headers = table.select("thead th") + cells = table.select("tbody tr:first-child td") + assert len(headers) == len(cells) == 7 + for index in (2, 3, 4, 5): # Active, revisions, delivery, activity + for cell in (headers[index], cells[index]): + assert {"d-none", "d-md-table-cell"} <= set(cell.get("class", [])) + for index in (0, 1, 6): # Target, status, resend action stay visible + assert "d-none" not in cells[index].get("class", []) + assert cells[6].select_one("button[data-action]") is not None + + def test_sent_source_returns_404_for_unknown_source( app: Flask, client: FlaskClient ) -> None: diff --git a/webmentions_ssg/templates/dashboard.html b/webmentions_ssg/templates/dashboard.html index a7f968e..70e2bf0 100644 --- a/webmentions_ssg/templates/dashboard.html +++ b/webmentions_ssg/templates/dashboard.html @@ -10,7 +10,6 @@ SPDX-License-Identifier: BSD-3-Clause

Dashboard

Single-site overview -
@@ -42,7 +41,6 @@ SPDX-License-Identifier: BSD-3-Clause
-
@@ -78,7 +76,6 @@ SPDX-License-Identifier: BSD-3-Clause
-

Recent activity

@@ -105,7 +102,6 @@ SPDX-License-Identifier: BSD-3-Clause
-

Operations

diff --git a/webmentions_ssg/templates/received.html b/webmentions_ssg/templates/received.html index b8099aa..2edf881 100644 --- a/webmentions_ssg/templates/received.html +++ b/webmentions_ssg/templates/received.html @@ -34,9 +34,10 @@ SPDX-License-Identifier: BSD-3-Clause } } %} -{% macro sortable_header(label, column) %} +{% macro sortable_header(label, column, responsive_class="") %} {% set active = sort_key == column %} @@ -112,11 +113,11 @@ SPDX-License-Identifier: BSD-3-Clause aria-label="Received Webmention actions"> {% if webmentions.items %} 0 selected
{% if sources.items %} - - - - - - - - - - - - - - {% for source in sources %} - {% if source.deleted_at is none %} - {% set row_class = "table-success" %} - {% set badge_class = "text-bg-success" %} - {% set status_text = "Active" %} - {% else %} - {% set row_class = "table-danger" %} - {% set badge_class = "text-bg-danger" %} - {% set status_text = "Deleted" %} - {% endif %} - - - - - - - - +
+
PathURLWebmentionsRevisionCreatedLast seenStatus
- {{ source.path }} - - {{ source.url }} - {{ source.sent_webmentions | length }}{{ source.revision }} - - - - - {{ status_text }} -
+ + + + + + + + + - {% endfor %} - -
PathURLWebmentionsRevisionCreatedLast seenStatus
+ + + {% for source in sources %} + {% if source.deleted_at is none %} + {% set row_class = "table-success" %} + {% set badge_class = "text-bg-success" %} + {% set status_text = "Active" %} + {% else %} + {% set row_class = "table-danger" %} + {% set badge_class = "text-bg-danger" %} + {% set status_text = "Deleted" %} + {% endif %} + + + {{ source.path }} + + + {{ source.url }} + + {{ source.sent_webmentions | length }} + {{ source.revision }} + + + + + + + + {{ status_text }} + + + {% endfor %} + + + {% if sources.pages > 1 %}
{{ render_pagination(sources) }}
{% endif %} diff --git a/webmentions_ssg/templates/sent_source.html b/webmentions_ssg/templates/sent_source.html index 2b7a377..6e34458 100644 --- a/webmentions_ssg/templates/sent_source.html +++ b/webmentions_ssg/templates/sent_source.html @@ -88,119 +88,122 @@ SPDX-License-Identifier: BSD-3-Clause {{ webmentions.total }} webmentions {% if webmentions.items %} - - - - - - - - - - - - - - {% for webmention in webmentions %} - {% set style = sent_status_presentation.get(webmention.status, {"row_class": "table-info", "badge_class": "text-bg-info", "label": "Pending" }) %} - - - - - - + + + {% endfor %} + +
TargetStatusActiveRevisionsDeliveryLast activityActions
- {{ webmention.target }} - - {{ style.label }} - {% if webmention.failure_reason is not none %} -
{{ webmention.failure_reason }}
- {% endif %} -
- {% if webmention.linked %} - Active - {% else %} - Removed - {% endif %} - -
- Desired: - {{ webmention.desired_revision }} -
-
- Processed: - {{ webmention.processed_revision - if webmention.processed_revision is not none - else "—" }} -
-
- Sent: - {{ webmention.sent_revision - if webmention.sent_revision is not none - else "—" }} -
-
- {% if webmention.webmention_endpoint is not none %} -
- Endpoint: - {{ webmention.webmention_endpoint }} +
+ + + + + + + + + + + + + + {% for webmention in webmentions %} + {% set style = sent_status_presentation.get(webmention.status, {"row_class": "table-info", "badge_class": "text-bg-info", "label": "Pending" }) %} + + + + + + + - - - - {% endfor %} - -
TargetStatusActiveRevisionsDeliveryLast activityActions
+ {{ webmention.target }} + + {{ style.label }} + {% if webmention.failure_reason is not none %} +
{{ webmention.failure_reason }}
+ {% endif %} +
+ {% if webmention.linked %} + Active + {% else %} + Removed + {% endif %} + +
+ Desired: + {{ webmention.desired_revision }} +
+
+ Processed: + {{ webmention.processed_revision + if webmention.processed_revision is not none + else "—" }} +
+
+ Sent: + {{ webmention.sent_revision + if webmention.sent_revision is not none + else "—" }}
- {% endif %} - {% if webmention.endpoint_response_status is not none %} +
+ {% if webmention.webmention_endpoint is not none %} + + {% endif %} + {% if webmention.endpoint_response_status is not none %} +
+ HTTP: + {{ webmention.endpoint_response_status }} +
+ {% endif %} + {% if webmention.status_url is not none %} +
+ Status: + {% if webmention.status_url | is_http_url %} + {{ webmention.status_url }} + {% else %} + {{ webmention.status_url }} + {% endif %} +
+ {% endif %} +
- HTTP: - {{ webmention.endpoint_response_status }} + Attempted: +
+ {% if webmention.last_attempted_at is not none %} + + {% else %} + — + {% endif %}
- {% endif %} - {% if webmention.status_url is not none %}
- Status: - {% if webmention.status_url | is_http_url %} - {{ webmention.status_url }} + Sent: +
+ {% if webmention.last_sent_at is not none %} + {% else %} - {{ webmention.status_url }} + — {% endif %}
- {% endif %} -
-
- Attempted: -
- {% if webmention.last_attempted_at is not none %} - - {% else %} - — - {% endif %} -
-
- Sent: -
- {% if webmention.last_sent_at is not none %} - - {% else %} - — - {% endif %} -
-
- -
+
+ +
+ {% if webmentions.pages > 1 %}
{{ render_pagination(webmentions) }}
{% endif %} -- cgit v1.3.1