Skip to content

Commit d01afe8

Browse files
Add pagination to admin source list pages (#103)
* Add pagination to admin source list pages - Add pagination controls (Prev/Next) to all admin source list pages - Show 20 sources per page with "Showing X-Y of Z sources" info - Pagination appears at both top and bottom of long lists - Controls only appear when there's more than one page - Works for Active, Disabled, Needs Configuration, and Robots Blocked pages - Uses HTMX for seamless page navigation without full page reload 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Fix pagination in mutation endpoints and template page size Code review fixes: - Create _get_paginated_sources() helper to share pagination logic - Update mutation endpoints (delete, toggle, mark-disabled, recheck-robots, create) to return paginated results instead of unpaginated lists - Replace hard-coded page size (20) in template with page_size variable - Add page_size to all GET list endpoint responses This ensures pagination controls persist after actions like delete/toggle, and the template will automatically reflect any changes to SOURCES_PER_PAGE. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Fix pagination edge cases and consolidate GET list endpoints Address code review feedback on PR #103: - Thread current page from HX-Current-URL header through mutation endpoints (delete, toggle, mark-disabled, recheck-robots) so users don't lose their place after actions - Refactor all four GET list endpoints to use _get_paginated_sources helper, ensuring consistent page clamping to prevent invalid ranges like "Showing 21-10 of 10" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Fix pagination: pass current page via hx-vals instead of HX-Current-URL The HX-Current-URL header contains the browser URL (e.g., /admin) which never has a page param since pagination doesn't push to browser URL. Fix by: - Adding hx-vals='{"page": "{{ page }}"}' to all mutation buttons (recheck-robots, delete, mark-disabled, toggle) - Update _get_current_page_from_request to read from query params (DELETE) or form data (POST) where htmx sends hx-vals - Make mutation endpoints async to await form parsing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Docs: Add admin source list pagination to status 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 0c33989 commit d01afe8

File tree

3 files changed

+198
-99
lines changed

3 files changed

+198
-99
lines changed

CLAUDE_STATUS.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,23 @@ Default State: AK
924924
- **SitemapScraper:** Shows when `sitemap_url` is configured
925925
- **DynamicScraper:** Shows when `custom_scraper_code` exists
926926

927+
### Admin Source List Pagination ✅
928+
- [x] Paginated source lists (20 per page) across all admin pages
929+
- [x] Pagination controls (Prev/Next) with page info ("Showing 1-20 of 45 sources")
930+
- [x] Page clamping to prevent invalid ranges (e.g., page 3 of 2 clamps to page 2)
931+
- [x] Mutation actions (Delete, Toggle, Mark Disabled, Recheck) preserve current page
932+
- [x] Consolidated `_get_paginated_sources` helper for consistent pagination logic
933+
934+
**Key Files:**
935+
- `backend/app/routers/admin.py` - Pagination helper and endpoint updates
936+
- `backend/app/templates/admin/partials/source_list.html` - Pagination controls with `hx-vals`
937+
938+
**Technical Details:**
939+
- `SOURCES_PER_PAGE = 20` constant for page size
940+
- `_get_paginated_sources()` returns paginated sources with context flags
941+
- `_get_current_page_from_request()` extracts page from htmx `hx-vals` (form data for POST, query params for DELETE)
942+
- All mutation buttons include `hx-vals='{"page": "{{ page }}"}'` to preserve position
943+
927944
## CSS Selector Troubleshooting
928945

929946
Common issues when configuring GenericScraper:

0 commit comments

Comments
 (0)