Redesign UI and fix several bugs

- Add navbar with login/logout, search form, and Find Link branding
- Clean up index page: search-only, examples behind ?debug=1
- Improve article page: remove debug clutter, named Wikipedia links, collapsible candidates
- Add SVG favicon (🔗 emoji)
- Fix diff CSS: compact layout, auto table layout to eliminate wide marker column gap
- Catch TokenRequestDenied in OAuth start and show error page
- Store username in session at login; clear bad session on API failure
- Raise NoMatch when diff is empty (edit already applied)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Edward Betts 2026-05-11 11:30:12 +01:00
parent 7867122326
commit bc6265d4cd
11 changed files with 167 additions and 90 deletions

View file

@ -1,5 +1,6 @@
"""Wikipedia OAuth."""
import sys
import typing
import urllib
from typing import cast
@ -73,9 +74,8 @@ def api_request(params: typing.Mapping[str, str | int]) -> dict[str, typing.Any]
try:
return cast(dict[str, typing.Any], r.json())
except Exception:
print("text")
print(r.text)
print("---")
print(f"API request failed: HTTP {r.status_code}", file=sys.stderr)
print(f"Response body: {r.text!r}", file=sys.stderr)
raise
@ -105,7 +105,13 @@ def get_username() -> None | str:
return None # not authorized
if "username" not in session:
reply = userinfo_call()
try:
reply = userinfo_call()
except Exception as e:
print(f"get_username failed, clearing session: {e}", file=sys.stderr)
session.pop("owner_key", None)
session.pop("owner_secret", None)
return None
if "query" not in reply:
return None
session["username"] = reply["query"]["userinfo"]["name"]