diff options
| author | Dennis Fink | 2026-11-19 18:15:34 +0100 |
|---|---|---|
| committer | Dennis Fink | 2026-11-19 18:15:34 +0100 |
| commit | 8ec35babe87ff8139ec23cc10b858b7481f132db (patch) | |
| tree | b1e2b2507abba25b570a32e7274b6c0158eac653 /webmentions_ssg | |
| parent | 45d3d3fde75173dfbf27e08aae8501842a9511dd (diff) | |
| download | webmentions-ssg-8ec35babe87ff8139ec23cc10b858b7481f132db.tar.gz webmentions-ssg-8ec35babe87ff8139ec23cc10b858b7481f132db.zip | |
refactor(sender)!: align sent Webmention terminology
Rename source-list forms, views, helpers, and tests around the Sent
Webmentions UI while keeping source documents as the grouping model.
BREAKING CHANGE: authenticated outgoing routes move from `/sources` to
`/sent`, with corresponding blueprint endpoint and Python module
renames.
Diffstat (limited to 'webmentions_ssg')
| -rw-r--r-- | webmentions_ssg/forms/sent.py (renamed from webmentions_ssg/forms/sources.py) | 20 | ||||
| -rw-r--r-- | webmentions_ssg/templates/base.html | 4 | ||||
| -rw-r--r-- | webmentions_ssg/templates/dashboard.html | 2 | ||||
| -rw-r--r-- | webmentions_ssg/templates/sent.html | 14 | ||||
| -rw-r--r-- | webmentions_ssg/templates/sent_source.html | 4 | ||||
| -rw-r--r-- | webmentions_ssg/views/__init__.py | 4 | ||||
| -rw-r--r-- | webmentions_ssg/views/sent.py (renamed from webmentions_ssg/views/sources.py) | 62 |
7 files changed, 55 insertions, 55 deletions
diff --git a/webmentions_ssg/forms/sources.py b/webmentions_ssg/forms/sent.py index 04afe77..65a2708 100644 --- a/webmentions_ssg/forms/sources.py +++ b/webmentions_ssg/forms/sent.py @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: BSD-3-Clause -"""Source document filtering form.""" +"""Filters for the sent Webmentions page.""" from flask import current_app from flask_wtf import FlaskForm @@ -18,23 +18,23 @@ from wtforms.validators import AnyOf, NumberRange, Optional from .validators import CanonicalDate -SOURCE_STATUS_CHOICES = { - "": "All sources", +SENT_STATUS_CHOICES = { + "": "All source documents", "failing": "Failing sends", "retrying": "Awaiting retry", - "deleted": "Deleted sources", + "deleted": "Deleted source documents", } -def default_source_page_size() -> int: +def default_sent_page_size() -> int: """Use 25 rows unless the configured maximum is lower.""" return min(25, current_app.config["SOURCES_MAX_PAGE_SIZE"]) -class SourceFilterForm(FlaskForm): - """GET filters for the source document list.""" +class SentFilterForm(FlaskForm): + """GET filters for sent Webmentions grouped by source document.""" - status = SelectField("Status", choices=SOURCE_STATUS_CHOICES, default="") + status = SelectField("Status", choices=SENT_STATUS_CHOICES, default="") q = SearchField("Path or URL") date_from = DateField( "Last seen from (UTC)", validators=[Optional(), CanonicalDate()] @@ -59,12 +59,12 @@ class SourceFilterForm(FlaskForm): order = HiddenField(default="desc", validators=[AnyOf(("asc", "desc"))]) per_page = IntegerField( "Rows per page", - default=default_source_page_size, + default=default_sent_page_size, validators=[NumberRange(min=1)], ) def validate_per_page(self, field: IntegerField) -> None: - """Enforce the deployment's maximum source-list page size.""" + """Enforce the deployment's maximum source-document page size.""" if ( field.data is not None and field.data > current_app.config["SOURCES_MAX_PAGE_SIZE"] diff --git a/webmentions_ssg/templates/base.html b/webmentions_ssg/templates/base.html index 17c06d2..e21c663 100644 --- a/webmentions_ssg/templates/base.html +++ b/webmentions_ssg/templates/base.html @@ -49,8 +49,8 @@ SPDX-License-Identifier: BSD-3-Clause href='{{ url_for("webmentions.received_list") }}'>Received</a> <a class="nav-link{% if request.endpoint and request.endpoint.startswith('webmentions.moderation') %} active{% endif %}" href="{{ url_for('webmentions.moderation') }}">Moderation</a> - <a class="nav-link{% if request.endpoint == 'webmentions.source_list' %} active{% endif %}" - href='{{ url_for("webmentions.source_list") }}'>Sent</a> + <a class="nav-link{% if request.endpoint in ('webmentions.sent_list', 'webmentions.sent_source_detail') %} active{% endif %}" + href='{{ url_for("webmentions.sent_list") }}'>Sent</a> <a class="nav-link{% if request.endpoint == 'webmentions.user_page' %} active{% endif %}" href="{{ url_for('webmentions.user_page') }}">User</a> <form action="{{ url_for('webmentions.logout') }}" diff --git a/webmentions_ssg/templates/dashboard.html b/webmentions_ssg/templates/dashboard.html index b020d46..4fa1e90 100644 --- a/webmentions_ssg/templates/dashboard.html +++ b/webmentions_ssg/templates/dashboard.html @@ -46,7 +46,7 @@ SPDX-License-Identifier: BSD-3-Clause <div class="card-body"> <div class="d-flex justify-content-between align-items-center mb-3"> <h2 class="h4 mb-0" id="sent-summary">Outgoing</h2> - <a href="{{ url_for('webmentions.source_list') }}">View sources</a> + <a href="{{ url_for('webmentions.sent_list') }}">View sent Webmentions</a> </div> <p class="display-6 mb-3">{{ sent_total }} <span class="fs-6 text-body-secondary">total</span></p> <div class="row row-cols-2 g-3"> diff --git a/webmentions_ssg/templates/sent.html b/webmentions_ssg/templates/sent.html index 46296b8..9db0156 100644 --- a/webmentions_ssg/templates/sent.html +++ b/webmentions_ssg/templates/sent.html @@ -22,9 +22,9 @@ SPDX-License-Identifier: BSD-3-Clause {% block content %} <div class="d-flex justify-content-between align-items-center mb-3"> - <h1 class="mb-0">Sources</h1> + <h1 class="mb-0">Sent Webmentions</h1> <div class="d-flex flex-column justify-content-between"> - <span class="text-body-secondary mb-1">{{ sources.total }} sources</span> + <span class="text-body-secondary mb-1">{{ sources.total }} source document{{ "s" if sources.total != 1 else "" }}</span> <button type="button" class="btn btn-sm btn-primary" data-bs-toggle="modal" @@ -36,7 +36,7 @@ SPDX-License-Identifier: BSD-3-Clause data-confirm-class="btn-primary">Rescan</button> </div> </div> - <form action="{{ url_for('webmentions.source_list') }}" + <form action="{{ url_for('webmentions.sent_list') }}" method="get" class="row g-2 align-items-end mb-4" role="search"> @@ -64,7 +64,7 @@ SPDX-License-Identifier: BSD-3-Clause </div> <div class="col-auto d-flex gap-2 ms-auto"> <button type="submit" class="btn btn-primary">Filter</button> - <a href="{{ url_for('webmentions.source_list') }}" + <a href="{{ url_for('webmentions.sent_list') }}" class="btn btn-outline-secondary">Clear</a> </div> </form> @@ -99,7 +99,7 @@ SPDX-License-Identifier: BSD-3-Clause <span class="badge {{ badge_class }}">{{ status_text }}</span> </td> <td class="text-break"> - <a href="{{ url_for('webmentions.source_detail', source_uuid=source.uuid, source_page=sources.page, **filters) }}">{{ source.path }}</a> + <a href="{{ url_for('webmentions.sent_source_detail', source_uuid=source.uuid, source_page=sources.page, **filters) }}">{{ source.path }}</a> </td> <td class="text-break d-none d-md-table-cell"> <a href="{{ source.url }}">{{ source.url }}</a> @@ -142,9 +142,9 @@ SPDX-License-Identifier: BSD-3-Clause {% endif %} {% else %} {% if filters %} - <p class="text-body-secondary">No sources match these filters.</p> + <p class="text-body-secondary">No source documents match these filters.</p> {% else %} - <p class="text-body-secondary">No Webmention sources have been discovered yet.</p> + <p class="text-body-secondary">No source documents with outgoing Webmentions have been discovered yet.</p> {% endif %} {% endif %} {% include "includes/confirmation_modal.html" %} diff --git a/webmentions_ssg/templates/sent_source.html b/webmentions_ssg/templates/sent_source.html index 04f9d07..a24bde3 100644 --- a/webmentions_ssg/templates/sent_source.html +++ b/webmentions_ssg/templates/sent_source.html @@ -26,10 +26,10 @@ SPDX-License-Identifier: BSD-3-Clause {% block content %} <div class="mb-3"> - <a href="{{ url_for('webmentions.source_list', page=source_page, **filters) }}">← Back to sources</a> + <a href="{{ url_for('webmentions.sent_list', page=source_page, **filters) }}">← Back to Sent Webmentions</a> </div> <div class="d-flex justify-content-between align-items-start mb-3"> - <h1 class="mb-0">Source Details</h1> + <h1 class="mb-0">Sent Webmention Source</h1> </div> <div class="d-flex justify-content-between align-items-start mb-3"> <dl class="row"> diff --git a/webmentions_ssg/views/__init__.py b/webmentions_ssg/views/__init__.py index 5abaa14..1701838 100644 --- a/webmentions_ssg/views/__init__.py +++ b/webmentions_ssg/views/__init__.py @@ -4,7 +4,7 @@ """Collect and expose the routes for the blueprint.""" -from . import dashboard, endpoint, moderation, received, session, sources, user +from . import dashboard, endpoint, moderation, received, session, sent, user from .blueprint import webmentions_bp __all__ = [ @@ -13,7 +13,7 @@ __all__ = [ "moderation", "received", "session", - "sources", + "sent", "user", "webmentions_bp", ] diff --git a/webmentions_ssg/views/sources.py b/webmentions_ssg/views/sent.py index 22cabb6..27dffb3 100644 --- a/webmentions_ssg/views/sources.py +++ b/webmentions_ssg/views/sent.py @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: BSD-3-Clause -"""Authenticated source document and sent Webmention views.""" +"""Authenticated sent Webmention views, grouped by source document.""" import uuid from datetime import UTC, date, datetime, time @@ -16,10 +16,10 @@ from flask_login import login_required from ..extensions import db from ..forms.admin import ConfirmActionForm -from ..forms.sources import ( - SOURCE_STATUS_CHOICES, - SourceFilterForm, - default_source_page_size, +from ..forms.sent import ( + SENT_STATUS_CHOICES, + SentFilterForm, + default_sent_page_size, ) from ..models.sources import SentWebmention, SentWebmentionStatus, SourceDocument from ..tasks.scanner import manual_scan_sources @@ -27,8 +27,8 @@ from ..tasks.sender import send_webmention from .blueprint import webmentions_bp -class SourceFilterArgs(TypedDict, total=False): - """Validated source-list query parameters; keys match GET form fields.""" +class SentFilterArgs(TypedDict, total=False): + """Validated sent-page query parameters; keys match GET form fields.""" status: str q: str @@ -39,34 +39,34 @@ class SourceFilterArgs(TypedDict, total=False): per_page: str -def source_filter_form() -> SourceFilterForm: +def sent_filter_form() -> SentFilterForm: """Validate GET filters without requiring CSRF on the search form.""" - form = SourceFilterForm(formdata=request.args, meta={"csrf": False}) + form = SentFilterForm(formdata=request.args, meta={"csrf": False}) if not form.validate(): abort(HTTPStatus.BAD_REQUEST) form.q.data = (form.q.data or "").strip() return form -def source_filter_args(form: SourceFilterForm) -> SourceFilterArgs: +def sent_filter_args(form: SentFilterForm) -> SentFilterArgs: """Serialize non-default values for pagination, sorting, and navigation.""" values: dict[str, str] = {} - for name in SourceFilterArgs.__annotations__: + for name in SentFilterArgs.__annotations__: field = form[name] value = field.data default = field.default() if callable(field.default) else field.default if value is None or value == "" or value == default: continue values[name] = value.isoformat() if isinstance(value, date) else str(value) - return cast(SourceFilterArgs, values) + return cast(SentFilterArgs, values) -@webmentions_bp.route("/sources") +@webmentions_bp.route("/sent") @login_required -def source_list() -> ResponseReturnValue: - """Display source documents with filters for outgoing delivery problems.""" - filter_form = source_filter_form() - filters = source_filter_args(filter_form) +def sent_list() -> ResponseReturnValue: + """Display sent Webmentions grouped by source document.""" + filter_form = sent_filter_form() + filters = sent_filter_args(filter_form) query = sa.select(SourceDocument) # EXISTS avoids duplicate source rows when several Webmentions match. @@ -134,7 +134,7 @@ def source_list() -> ResponseReturnValue: if sort_key != "created": query = query.order_by(SourceDocument.uuid.desc()) - page_size = int(filters.get("per_page", default_source_page_size())) + page_size = int(filters.get("per_page", default_sent_page_size())) sources = db.paginate( query, per_page=page_size, @@ -158,8 +158,8 @@ def source_list() -> ResponseReturnValue: next_order = "asc" if sort_order == "desc" else "desc" else: next_order = "asc" if key in ("path", "url", "status") else "desc" - sort_filters: SourceFilterArgs = {**filters, "sort": key, "order": next_order} - sort_urls[key] = url_for("webmentions.source_list", **sort_filters) + sort_filters: SentFilterArgs = {**filters, "sort": key, "order": next_order} + sort_urls[key] = url_for("webmentions.sent_list", **sort_filters) return render_template( "sent.html", @@ -170,7 +170,7 @@ def source_list() -> ResponseReturnValue: sort_key=sort_key, sort_order=sort_order, sort_urls=sort_urls, - status_choices=SOURCE_STATUS_CHOICES, + status_choices=SENT_STATUS_CHOICES, page_size=page_size, max_source_page_size=current_app.config["SOURCES_MAX_PAGE_SIZE"], filter_form=filter_form, @@ -178,7 +178,7 @@ def source_list() -> ResponseReturnValue: ) -@webmentions_bp.post("/sources/rescan") +@webmentions_bp.post("/sent/rescan") @login_required def rescan_sources() -> ResponseReturnValue: """Queue a manual scan of sent Webmention sources. @@ -188,25 +188,25 @@ def rescan_sources() -> ResponseReturnValue: if not ConfirmActionForm().validate_on_submit(): abort(HTTPStatus.BAD_REQUEST) - filters = source_filter_args(source_filter_form()) + filters = sent_filter_args(sent_filter_form()) manual_scan_sources() flash("Source rescan queued.", "success") page = request.args.get("page", 1, type=int) return redirect( - url_for("webmentions.source_list", page=page if page > 1 else None, **filters) + url_for("webmentions.sent_list", page=page if page > 1 else None, **filters) ) -@webmentions_bp.route("/sources/<uuid:source_uuid>") +@webmentions_bp.route("/sent/<uuid:source_uuid>") @login_required -def source_detail(source_uuid: uuid.UUID) -> ResponseReturnValue: +def sent_source_detail(source_uuid: uuid.UUID) -> ResponseReturnValue: """Display the sent Webmentions associated with a source. :param source_uuid: UUID of the source to display. :returns: Rendered source details page. """ - filters = source_filter_args(source_filter_form()) + filters = sent_filter_args(sent_filter_form()) source_page = request.args.get("source_page", 1, type=int) source = db.get_or_404(SourceDocument, source_uuid) @@ -219,7 +219,7 @@ def source_detail(source_uuid: uuid.UUID) -> ResponseReturnValue: return render_template( "sent_source.html", - title="Sent Webmentions", + title="Sent Webmention Source", source=source, webmentions=webmentions, filters=filters, @@ -228,7 +228,7 @@ def source_detail(source_uuid: uuid.UUID) -> ResponseReturnValue: ) -@webmentions_bp.post("/sources/<uuid:source_uuid>/<uuid:webmention_uuid>/resend") +@webmentions_bp.post("/sent/<uuid:source_uuid>/<uuid:webmention_uuid>/resend") @login_required def resend_webmention( source_uuid: uuid.UUID, webmention_uuid: uuid.UUID @@ -247,7 +247,7 @@ def resend_webmention( if not ConfirmActionForm().validate_on_submit(): abort(HTTPStatus.BAD_REQUEST) - filters = source_filter_args(source_filter_form()) + filters = sent_filter_args(sent_filter_form()) webmention = db.get_or_404(SentWebmention, webmention_uuid) if webmention.source_uuid != source_uuid: @@ -268,7 +268,7 @@ def resend_webmention( source_page = request.args.get("source_page", 1, type=int) return redirect( url_for( - "webmentions.source_detail", + "webmentions.sent_source_detail", source_uuid=source_uuid, page=page if page > 1 else None, source_page=source_page if source_page > 1 else None, |
