Feat: Add pagination to search results and author works list
Add Pagination to Search Results and Author Works List
Summary
This PR implements pagination for both search results pages (authors and works) and individual author works lists. Previously, searches would return up to 200 results on a single page with no way to access additional results. Now, results are paginated with 50 items per page and users can navigate between pages.
Changes Made
Backend
-
search.py: Modified
search_author()andsearch_work()to acceptoffsetparameter and return pagination metadata (continue offset) -
squeries.py: Updated
query_for_works_by_an_authorSPARQL query to support LIMIT and OFFSET clauses -
pdclasses.py: Enhanced
Author.getWorks()method with pagination parameters (limit=50, offset=0) -
app.py:
- Updated
/resultsroute to handle page parameter and pass pagination data to templates - Updated
/works-listroute with pagination support - Cache automatically includes page parameter via
request.args
- Updated
Frontend
- templates/results.html: Added Bootstrap pagination controls with Previous/Next buttons
- templates/works-list.html: Added pagination controls for author works lists
Internationalization
-
messages.pot: Added 4 new translatable strings:
- "Pagination" (aria-label)
- "Previous"
- "Next"
- "Page %(page)s"
Technical Details
- Page size: 50 items per page (reduced from 200)
-
URL structure: Adds
?page=Nparameter to existing query strings - Caching: Properly cached per page via existing cache key mechanism
- Accessibility: Pagination nav includes proper ARIA labels
Testing
-
Search for authors with many results (e.g., "paulina") -
Navigate between pages using Previous/Next buttons -
Search for works with many results -
View author works list with pagination -
Verify cache includes page parameter
Screenshots
Search Results Pagination - Page 1
Search Results Pagination - Page 2
Closes T399974

