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() and search_work() to accept offset parameter and return pagination metadata (continue offset)
  • squeries.py: Updated query_for_works_by_an_author SPARQL query to support LIMIT and OFFSET clauses
  • pdclasses.py: Enhanced Author.getWorks() method with pagination parameters (limit=50, offset=0)
  • app.py:
    • Updated /results route to handle page parameter and pass pagination data to templates
    • Updated /works-list route with pagination support
    • Cache automatically includes page parameter via request.args

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=N parameter 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

image

Search Results Pagination - Page 2

image


Closes T399974

Merge request reports

Loading