feat: implement article search with PostgreSQL full-text search #42

Merged
mark merged 2 commits from feature/article-search into main 2026-03-03 21:58:08 +00:00
Owner

Summary

Implements article search using Wagtail's built-in PostgreSQL full-text search backend. Replaces the nav Subscribe CTA with a search box on both desktop and mobile.

Closes #41

Changes

Backend

  • Search backend: Configured WAGTAILSEARCH_BACKENDS with database backend and english search config
  • django.contrib.postgres: Added to INSTALLED_APPS for full PG FTS support
  • Search fields: Expanded ArticlePage.search_fields with body_text (excludes code blocks), AutocompleteField(title), RelatedFields(tags), FilterField(category), FilterField(published_date)
  • Search view: /search/?q= with query guards (strip/normalize, 200-char max, empty/whitespace handling), pagination preserving ?q= param
  • Deploy: Added update_index to entrypoint.prod.sh for automated reindexing on every deploy

Frontend

  • Desktop nav: Replaced Subscribe CTA with compact search box (w-48, mono font, cyan focus ring)
  • Mobile nav: Added search form above newsletter form
  • Article index: Added search box alongside category/tag filters (matching wireframe)
  • Search results page: Reuses article_card.html, shows query + result count, no-results state, pagination

Tests

  • Updated test_newsletter_forms_render_in_nav_and_footer and test_nav_subscribe_cta_present for nav change
  • Added 12 new tests: search view (empty query, whitespace, max length, matching, no match, URL resolution), search fields validation, body text code block exclusion, nav/article-index integration
## Summary Implements article search using Wagtail's built-in PostgreSQL full-text search backend. Replaces the nav Subscribe CTA with a search box on both desktop and mobile. **Closes #41** ## Changes ### Backend - **Search backend**: Configured `WAGTAILSEARCH_BACKENDS` with `database` backend and `english` search config - **`django.contrib.postgres`**: Added to `INSTALLED_APPS` for full PG FTS support - **Search fields**: Expanded `ArticlePage.search_fields` with `body_text` (excludes code blocks), `AutocompleteField(title)`, `RelatedFields(tags)`, `FilterField(category)`, `FilterField(published_date)` - **Search view**: `/search/?q=` with query guards (strip/normalize, 200-char max, empty/whitespace handling), pagination preserving `?q=` param - **Deploy**: Added `update_index` to `entrypoint.prod.sh` for automated reindexing on every deploy ### Frontend - **Desktop nav**: Replaced Subscribe CTA with compact search box (`w-48`, mono font, cyan focus ring) - **Mobile nav**: Added search form above newsletter form - **Article index**: Added search box alongside category/tag filters (matching wireframe) - **Search results page**: Reuses `article_card.html`, shows query + result count, no-results state, pagination ### Tests - Updated `test_newsletter_forms_render_in_nav_and_footer` and `test_nav_subscribe_cta_present` for nav change - Added 12 new tests: search view (empty query, whitespace, max length, matching, no match, URL resolution), search fields validation, body text code block exclusion, nav/article-index integration
mark added 1 commit 2026-03-03 21:25:35 +00:00
feat: implement article search with PostgreSQL full-text search
Some checks failed
CI / nightly-e2e (pull_request) Has been skipped
CI / deploy (pull_request) Has been skipped
CI / ci (pull_request) Failing after 1m21s
CI / pr-e2e (pull_request) Successful in 1m33s
906206d4cd
- Configure Wagtail database search backend with English search config
- Add django.contrib.postgres to INSTALLED_APPS for full PG FTS support
- Expand ArticlePage.search_fields: body_text (excl. code blocks),
  AutocompleteField(title), RelatedFields(tags), FilterFields
- Add search view at /search/?q= with query guards (strip, max 200 chars,
  empty/whitespace handling) and pagination preserving query param
- Replace nav Subscribe CTA with compact search box (desktop + mobile)
- Add search box to article index page alongside category/tag filters
- Create search results template reusing article_card component
- Add update_index to deploy entrypoint for automated reindexing
- Update existing tests for nav change, add comprehensive search tests

Closes #41

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
mark added 1 commit 2026-03-03 21:30:29 +00:00
chore: rebuild Tailwind CSS for search template classes
All checks were successful
CI / nightly-e2e (pull_request) Has been skipped
CI / deploy (pull_request) Has been skipped
CI / ci (pull_request) Successful in 1m21s
CI / pr-e2e (pull_request) Successful in 1m34s
99b06d1f3b
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
codex_a approved these changes 2026-03-03 21:52:15 +00:00
codex_a left a comment
Owner

Strict QA review complete: implementation matches Issue #41 scope and acceptance criteria. Verified search backend config, article-only query path, empty/whitespace/max-length guards, navigation + article index search UX updates, pagination query preservation, and deploy reindex hook. Full pytest suite passes in Docker (96.03% coverage) and update_index runs cleanly.

Strict QA review complete: implementation matches Issue #41 scope and acceptance criteria. Verified search backend config, article-only query path, empty/whitespace/max-length guards, navigation + article index search UX updates, pagination query preservation, and deploy reindex hook. Full pytest suite passes in Docker (96.03% coverage) and update_index runs cleanly.
mark merged commit cc25d2ad2e into main 2026-03-03 21:58:08 +00:00
mark deleted branch feature/article-search 2026-03-03 21:58:08 +00:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: nohype/main-site#42