Remove Jinja2 frontend (dead code after SvelteKit migration) #151

Merged
forgejo_admin merged 1 commit from 150-remove-jinja2-frontend into main 2026-03-14 13:23:32 +00:00
Contributor

Summary

Removes the entire Jinja2 frontend (/browse/* routes, HTML templates, rendering pipeline) now that SvelteKit (pal-e-app) serves all frontend routes. Cleans up 4,595 lines of dead code across 29 files.

Changes

  • Deleted src/pal_e_docs/routes/frontend.py -- all /browse/* routes (323 lines)
  • Deleted src/pal_e_docs/templates/ -- 9 HTML template files (base, landing, login, note, projects, project_notes, repos, tags, tag_notes)
  • Deleted src/pal_e_docs/autolink.py -- slug auto-linking, only used by frontend rendering pipeline
  • Deleted src/pal_e_docs/sanitize.py -- HTML sanitization via nh3, only used by frontend rendering pipeline
  • Deleted src/pal_e_docs/wrap_tables.py -- table scroll wrapper, only used by frontend rendering pipeline
  • Deleted 13 test files -- all tests for /browse/* routes (unit, integration, Playwright browser tests)
  • Modified src/pal_e_docs/main.py -- removed frontend_router import/include and SessionMiddleware (only used by frontend session auth)
  • Modified pyproject.toml -- removed itsdangerous (SessionMiddleware), nh3 (sanitize.py), pytest-playwright (browser tests) dependencies
  • Modified tests/conftest.py -- removed reset_slug_cache import, live_server fixture, and unused imports
  • Modified tests/test_project_schema.py -- kept API tests (page_note FK, is_public), removed /browse/ frontend tests

Not removed (verified still in use)

  • auth.py -- hash_password still used by main.py _seed_user()
  • jinja2 dep -- still used by services/template_renderer.py (create_note_from_template)
  • beautifulsoup4 dep -- still used by block parser and embedding worker

Test Plan

  • ruff check src/ tests/ -- all checks passed
  • pytest tests/ -v -- 497 tests passed
  • No broken imports (app module loads cleanly)
  • API routes (/notes/*, /blocks/*, /boards/*, /projects/*, /tags/*, /repos/*, /links/*) unaffected

Review Checklist

  • No unrelated changes
  • Verified autolink.py, sanitize.py, wrap_tables.py only imported by frontend.py before deletion
  • Verified jinja2 dep kept (used by services/template_renderer.py)
  • Verified beautifulsoup4 dep kept (used by block parser + embedding worker)
  • Verified SessionMiddleware only used by frontend session auth (no API routes use sessions)
  • Verified auth.py kept (hash_password used by _seed_user)
  • html_content column NOT removed (still used for search and revisions)
  • Plan: plan-pal-e-docs Phase 4b
  • Forgejo issue: #150

Closes #150

## Summary Removes the entire Jinja2 frontend (`/browse/*` routes, HTML templates, rendering pipeline) now that SvelteKit (pal-e-app) serves all frontend routes. Cleans up 4,595 lines of dead code across 29 files. ## Changes - **Deleted `src/pal_e_docs/routes/frontend.py`** -- all `/browse/*` routes (323 lines) - **Deleted `src/pal_e_docs/templates/`** -- 9 HTML template files (base, landing, login, note, projects, project_notes, repos, tags, tag_notes) - **Deleted `src/pal_e_docs/autolink.py`** -- slug auto-linking, only used by frontend rendering pipeline - **Deleted `src/pal_e_docs/sanitize.py`** -- HTML sanitization via nh3, only used by frontend rendering pipeline - **Deleted `src/pal_e_docs/wrap_tables.py`** -- table scroll wrapper, only used by frontend rendering pipeline - **Deleted 13 test files** -- all tests for `/browse/*` routes (unit, integration, Playwright browser tests) - **Modified `src/pal_e_docs/main.py`** -- removed `frontend_router` import/include and `SessionMiddleware` (only used by frontend session auth) - **Modified `pyproject.toml`** -- removed `itsdangerous` (SessionMiddleware), `nh3` (sanitize.py), `pytest-playwright` (browser tests) dependencies - **Modified `tests/conftest.py`** -- removed `reset_slug_cache` import, `live_server` fixture, and unused imports - **Modified `tests/test_project_schema.py`** -- kept API tests (page_note FK, is_public), removed `/browse/` frontend tests ### Not removed (verified still in use) - `auth.py` -- `hash_password` still used by `main.py` `_seed_user()` - `jinja2` dep -- still used by `services/template_renderer.py` (create_note_from_template) - `beautifulsoup4` dep -- still used by block parser and embedding worker ## Test Plan - [x] `ruff check src/ tests/` -- all checks passed - [x] `pytest tests/ -v` -- 497 tests passed - [x] No broken imports (app module loads cleanly) - [x] API routes (`/notes/*`, `/blocks/*`, `/boards/*`, `/projects/*`, `/tags/*`, `/repos/*`, `/links/*`) unaffected ## Review Checklist - [x] No unrelated changes - [x] Verified `autolink.py`, `sanitize.py`, `wrap_tables.py` only imported by `frontend.py` before deletion - [x] Verified `jinja2` dep kept (used by `services/template_renderer.py`) - [x] Verified `beautifulsoup4` dep kept (used by block parser + embedding worker) - [x] Verified `SessionMiddleware` only used by frontend session auth (no API routes use sessions) - [x] Verified `auth.py` kept (`hash_password` used by `_seed_user`) - [x] `html_content` column NOT removed (still used for search and revisions) ## Related - Plan: `plan-pal-e-docs` Phase 4b - Forgejo issue: #150 Closes #150
Remove Jinja2 frontend -- dead code after SvelteKit migration (#150)
Some checks failed
ci/woodpecker/pr/woodpecker Pipeline failed
ff868c79c1
SvelteKit (pal-e-app) now serves all frontend routes. The Jinja2
/browse/* routes, HTML templates, and rendering pipeline are no longer
needed.

Deleted:
- routes/frontend.py (323 lines), templates/ (9 HTML files, 850 lines)
- autolink.py, sanitize.py, wrap_tables.py (only used by frontend)
- 13 test files testing /browse/* routes (unit, integration, Playwright)

Modified:
- main.py: removed frontend_router include and SessionMiddleware
- pyproject.toml: removed itsdangerous, nh3, pytest-playwright deps
- conftest.py: removed autolink cache reset and live_server fixture
- test_project_schema.py: kept API tests, removed /browse/ tests

Closes #150

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
Contributor

Self-Review

Reviewed all 4 modified files and verified the 25 deleted files are frontend-only.

Modified files (no issues found)

  • pyproject.toml -- Correctly removes itsdangerous, nh3, pytest-playwright, and browser marker. Keeps jinja2 (used by services/template_renderer.py), beautifulsoup4 (used by block parser + embedding worker), bcrypt (used by auth.py).
  • main.py -- Correctly removes SessionMiddleware and frontend_router. All 8 API routers remain.
  • conftest.py -- Correctly removes reset_slug_cache (autolink.py deleted), live_server fixture (browser tests deleted), unused imports (socket, threading, time, httpx, uvicorn), and browser-test teardown skip. Keeps create_test_note helper (still used by test_blocks_api.py and test_compiled_page_api.py).
  • test_project_schema.py -- Correctly removes 13 browse-specific tests while keeping all 13 API tests (page_note FK constraints, is_public API behavior).

Deleted files (25 total, all frontend-only)

  • 3 rendering utilities: autolink.py, sanitize.py, wrap_tables.py -- verified only imported by frontend.py
  • 1 route module: routes/frontend.py
  • 9 HTML templates: entire templates/ directory
  • 13 test files: all tested /browse/* routes exclusively

Verification

  • ruff check src/ tests/ -- all checks passed
  • pytest tests/ -v -- 497 passed in 7.03s
  • No broken imports

No issues found. PR is ready for human review.

## Self-Review Reviewed all 4 modified files and verified the 25 deleted files are frontend-only. ### Modified files (no issues found) - **pyproject.toml** -- Correctly removes `itsdangerous`, `nh3`, `pytest-playwright`, and `browser` marker. Keeps `jinja2` (used by `services/template_renderer.py`), `beautifulsoup4` (used by block parser + embedding worker), `bcrypt` (used by `auth.py`). - **main.py** -- Correctly removes `SessionMiddleware` and `frontend_router`. All 8 API routers remain. - **conftest.py** -- Correctly removes `reset_slug_cache` (autolink.py deleted), `live_server` fixture (browser tests deleted), unused imports (`socket`, `threading`, `time`, `httpx`, `uvicorn`), and browser-test teardown skip. Keeps `create_test_note` helper (still used by `test_blocks_api.py` and `test_compiled_page_api.py`). - **test_project_schema.py** -- Correctly removes 13 browse-specific tests while keeping all 13 API tests (page_note FK constraints, is_public API behavior). ### Deleted files (25 total, all frontend-only) - 3 rendering utilities: `autolink.py`, `sanitize.py`, `wrap_tables.py` -- verified only imported by `frontend.py` - 1 route module: `routes/frontend.py` - 9 HTML templates: entire `templates/` directory - 13 test files: all tested `/browse/*` routes exclusively ### Verification - `ruff check src/ tests/` -- all checks passed - `pytest tests/ -v` -- 497 passed in 7.03s - No broken imports No issues found. PR is ready for human review.
Author
Contributor

PR #151 Review

BLOCKERS

None. This is a clean removal of dead frontend code. All API routes, models, and remaining services are unaffected.

NITS

  1. Stale docstring in blocks/compiler.py -- The module docstring still reads: "downstream transforms (sanitize, autolink, wrap_tables) run separately." Those three modules no longer exist. Should be updated or removed to avoid confusion.

  2. Dead code in auth.py -- Three of the four functions are now unreachable: verify_password(), authenticate_user(), and get_current_user(). Only hash_password() is still called (by _seed_user() in main.py). The starlette.requests.Request import is also unused. Consider trimming auth.py to just hash_password(), or file a follow-up issue.

  3. Orphan config field secret_key in config.py -- settings.secret_key was consumed only by SessionMiddleware, which is now removed. The field and its env-var binding (PALDOCS_SECRET_KEY) are dead. Low priority but worth cleaning up.

SOP COMPLIANCE

  • Branch named after issue (150-remove-jinja2-frontend references #150)
  • PR body follows template (Summary, Changes, Test Plan, Related all present)
  • Related references plan slug (plan-pal-e-docs Phase 4b)
  • Closes #150 present in PR body
  • No secrets committed
  • No scope creep -- every deletion is frontend-related dead code
  • CI inconclusive -- Pipeline #194 test step failed but logs are empty (known Woodpecker K8s backend bug). PR claims 497 tests passing locally. Cannot independently verify via CI.

Detailed Verification

Check Result
API routers intact in main.py All 8 routers present (health, projects, notes, tags, links, repos, boards, blocks)
frontend_router removed Confirmed -- import and include_router both gone
SessionMiddleware removed Confirmed -- import and add_middleware both gone
jinja2 dependency retained Confirmed -- still used by services/template_renderer.py
beautifulsoup4 retained Confirmed -- still used by block parser and embedding worker
itsdangerous safe to remove Confirmed -- only consumer was SessionMiddleware
nh3 safe to remove Confirmed -- only consumer was deleted sanitize.py
pytest-playwright safe to remove Confirmed -- only consumers were deleted browser test files
No remaining imports of deleted modules Confirmed via code search (autolink, sanitize, wrap_tables, frontend)
template_renderer.py unaffected Confirmed -- imports only jinja2, sqlalchemy, pal_e_docs.models
notes.py search/from-template unaffected Confirmed -- no references to deleted modules
conftest.py clean reset_slug_cache, live_server, Playwright fixtures all removed
test_project_schema.py correct All /browse/* tests removed, all API tests retained
13 deleted test files all frontend-only Confirmed -- auth, autolink, browse_ux, frontend_browser, mobile_responsive, sanitize, wrap_tables (unit + integration), composition_rendering, repo_public_filter

VERDICT: APPROVED

Clean, well-scoped removal of 4,595 lines of dead frontend code. No import breakage, no accidental API deletions, dependencies correctly triaged. The three nits (stale docstring, dead auth functions, orphan config field) are non-blocking and should be filed as a follow-up issue.

## PR #151 Review ### BLOCKERS None. This is a clean removal of dead frontend code. All API routes, models, and remaining services are unaffected. ### NITS 1. **Stale docstring in `blocks/compiler.py`** -- The module docstring still reads: *"downstream transforms (sanitize, autolink, wrap_tables) run separately."* Those three modules no longer exist. Should be updated or removed to avoid confusion. 2. **Dead code in `auth.py`** -- Three of the four functions are now unreachable: `verify_password()`, `authenticate_user()`, and `get_current_user()`. Only `hash_password()` is still called (by `_seed_user()` in `main.py`). The `starlette.requests.Request` import is also unused. Consider trimming `auth.py` to just `hash_password()`, or file a follow-up issue. 3. **Orphan config field `secret_key` in `config.py`** -- `settings.secret_key` was consumed only by `SessionMiddleware`, which is now removed. The field and its env-var binding (`PALDOCS_SECRET_KEY`) are dead. Low priority but worth cleaning up. ### SOP COMPLIANCE - [x] Branch named after issue (`150-remove-jinja2-frontend` references #150) - [x] PR body follows template (Summary, Changes, Test Plan, Related all present) - [x] Related references plan slug (`plan-pal-e-docs` Phase 4b) - [x] `Closes #150` present in PR body - [x] No secrets committed - [x] No scope creep -- every deletion is frontend-related dead code - [ ] CI inconclusive -- Pipeline #194 test step failed but logs are empty (known Woodpecker K8s backend bug). PR claims 497 tests passing locally. Cannot independently verify via CI. ### Detailed Verification | Check | Result | |-------|--------| | API routers intact in `main.py` | All 8 routers present (health, projects, notes, tags, links, repos, boards, blocks) | | `frontend_router` removed | Confirmed -- import and `include_router` both gone | | `SessionMiddleware` removed | Confirmed -- import and `add_middleware` both gone | | `jinja2` dependency retained | Confirmed -- still used by `services/template_renderer.py` | | `beautifulsoup4` retained | Confirmed -- still used by block parser and embedding worker | | `itsdangerous` safe to remove | Confirmed -- only consumer was `SessionMiddleware` | | `nh3` safe to remove | Confirmed -- only consumer was deleted `sanitize.py` | | `pytest-playwright` safe to remove | Confirmed -- only consumers were deleted browser test files | | No remaining imports of deleted modules | Confirmed via code search (autolink, sanitize, wrap_tables, frontend) | | `template_renderer.py` unaffected | Confirmed -- imports only `jinja2`, `sqlalchemy`, `pal_e_docs.models` | | `notes.py` search/from-template unaffected | Confirmed -- no references to deleted modules | | `conftest.py` clean | `reset_slug_cache`, `live_server`, Playwright fixtures all removed | | `test_project_schema.py` correct | All `/browse/*` tests removed, all API tests retained | | 13 deleted test files all frontend-only | Confirmed -- auth, autolink, browse_ux, frontend_browser, mobile_responsive, sanitize, wrap_tables (unit + integration), composition_rendering, repo_public_filter | ### VERDICT: APPROVED Clean, well-scoped removal of 4,595 lines of dead frontend code. No import breakage, no accidental API deletions, dependencies correctly triaged. The three nits (stale docstring, dead auth functions, orphan config field) are non-blocking and should be filed as a follow-up issue.
forgejo_admin deleted branch 150-remove-jinja2-frontend 2026-03-14 13:23:32 +00:00
Commenting is not possible because the repository is archived.
No description provided.