Remove the MOVED redirects

MOVED and _moved answered 301 for twelve paths the settings cog moved
off of a few days ago. A browser caches a 301 indefinitely, so a path
reused later would be unreachable through no fault of that page, and
a one-person app has no outstanding bookmark to protect. Drop the
table, the routes, its export from app.web, and the tests that pinned
it; the old paths now answer plain 404. Keep the test that every
section of the Sources page exists, rewritten without MOVED.

Co-Authored-By: Claude Sonnet <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Sonnet committed 2026-09-29 14:50:18 +02:00
1 parent 706b127bc0
commit 92ff2bc069
5 files changed
+24 -78

No files matched your search

+2 -2
View File
@@ -208,8 +208,8 @@
// Sources shows one section: the one the fragment names or contains, or the
// first when there is none or it names none, so `/settings/sources#runs` (a
// rail link, an old path's 301, the Search agents page's "follow it under
// Runs") opens Runs, and so does `#messages`, the log at its end. The rest
// rail link, or the Search agents page's "follow it under Runs") opens
// Runs, and so does `#messages`, the log at its end. The rest
// are hidden, not removed, so their scripts still find their roots. It runs
// as the script loads rather than on DOMContentLoaded, so the page never
// paints all three first.
+2 -2
View File
@@ -7,8 +7,8 @@ from __future__ import annotations
from app.web.api import router as api_router
from app.web.pages import (
MOVED, SETTINGS, STATIC_DIR, TABS, router as pages_router, templates,
SETTINGS, STATIC_DIR, TABS, router as pages_router, templates,
)
__all__ = ["MOVED", "SETTINGS", "STATIC_DIR", "TABS", "api_router", "pages_router",
__all__ = ["SETTINGS", "STATIC_DIR", "TABS", "api_router", "pages_router",
"templates"]
-44
View File
@@ -23,13 +23,6 @@ contains; the others stay in the page, hidden, so each section's script (the
ones they had as pages of their own, each guarding on its own root element)
keeps working.
Every path a page has had before (`/agents`, `/companies`, `/sources`,
`/jobs`, `/schedules`, `/messages`, `/account`, and the six sub-tabs the
settings shell started with) answers 301 to its place now, query string
kept, so a bookmark still lands. A merged page's old path lands on its
section's anchor; the old Messages paths land on `#messages`, the log's
block at the end of Runs.
`FUNCTIONS` and `HOSTS` are `plugins.ats`'s, not `app`'s: the nine job
functions are the classifier's vocabulary and the hosts are what it parses,
and this reaches `plugins/` the same way `app.cli` does, since a plugin is
@@ -41,7 +34,6 @@ Jobindex areas and Adzuna countries on the Sources page come from
from __future__ import annotations
import sys
from collections.abc import Callable
from dataclasses import dataclass
from pathlib import Path
@@ -94,24 +86,6 @@ SECTIONS: dict[str, tuple[tuple[str, str], ...]] = {
),
}
#: Where each page that used to be a tab or a sub-tab lives now. The fragment
#: is the section on the merged page, or an element in one (`#messages`, in
#: Runs); a browser keeps it across the 301.
MOVED: dict[str, str] = {
"/agents": "/settings/agents",
"/settings/ranking": "/settings/agents",
"/companies": "/settings/sources#company-boards",
"/settings/companies": "/settings/sources#company-boards",
"/sources": "/settings/sources#job-boards",
"/settings/searches": "/settings/sources#job-boards",
"/jobs": "/settings/sources#runs",
"/schedules": "/settings/sources#runs",
"/settings/pulls": "/settings/sources#runs",
"/messages": "/settings/sources#messages",
"/settings/messages": "/settings/sources#messages",
"/account": "/settings/account",
}
#: `value, label` for each select option. `FUNCTIONS` is already the value a
#: role's `function` column holds; only the label is dressed up.
FUNCTION_OPTIONS = [(f, f.replace("/", " / ").capitalize()) for f in FUNCTIONS]
@@ -192,21 +166,3 @@ def sources(request: Request) -> HTMLResponse:
@router.get("/settings/account", response_class=HTMLResponse)
def account(request: Request) -> HTMLResponse:
return page(request, "settings/account.html")
def _moved(to: str) -> Callable[[Request], RedirectResponse]:
"""A 301 to `to`, carrying the query string, so `/agents?x=1` keeps it.
The query goes before `to`'s fragment, if it has one, or the browser
would read `#runs?x=1` as one fragment."""
path, _, fragment = to.partition("#")
def redirect(request: Request) -> RedirectResponse:
query = request.url.query
target = f"{path}?{query}" if query else path
return RedirectResponse(f"{target}#{fragment}" if fragment else target,
status_code=301)
return redirect
for _old, _new in MOVED.items():
router.add_api_route(_old, _moved(_new), methods=["GET"],
response_class=RedirectResponse)