Skip to content

feat: add category support for RSS articles#11

Open
weronikakombat wants to merge 1 commit intoHyaxia:mainfrom
weronikakombat:main
Open

feat: add category support for RSS articles#11
weronikakombat wants to merge 1 commit intoHyaxia:mainfrom
weronikakombat:main

Conversation

@weronikakombat
Copy link
Copy Markdown

Closes #10

This PR adds support for storing and filtering articles by categories/tags from RSS/Atom feeds.

Changes

Model (internal/model/model.go)

  • Added Categories []string field to Article struct

RSS Parser (internal/rss/rss.go)

  • Added Categories []string to FeedArticle struct
  • Capture item.Categories from gofeed when parsing feeds

Storage (internal/storage/database.go)

  • Added categories column to articles table in schema
  • Added migrate() function to handle existing databases (backward compatible)
  • Added categoriesToString() and categoriesFromString() helpers
  • Updated all article queries to include categories
  • ListArticles() now accepts optional category filter parameter

Scanner (internal/scanner/scanner.go)

  • Pass categories from RSS to model articles in convertFeedArticles()

Controller (internal/controller/controller.go)

  • Updated GetArticles() to accept category parameter
  • Pass category filter to storage layer

CLI (internal/cli/commands.go)

  • Added --category / -c flag to articles command
  • Display categories in article list output when present

Usage Examples

# Show all articles
blogwatcher articles --all

# Filter by category
blogwatcher articles --category "AI"

# Combined with other filters
blogwatcher articles --blog "TechCrunch" --category "Security"

Backward Compatibility

  • Existing databases will be automatically migrated via migrate() function
  • If categories column doesn't exist, it will be added on next database open
  • Empty categories are handled gracefully (nil/empty slice)

Testing

All existing tests pass. The PR touches:

  • internal/model/model.go
  • internal/rss/rss.go
  • internal/storage/database.go + tests
  • internal/scanner/scanner.go + tests
  • internal/controller/controller.go + tests
  • internal/cli/commands.go

I'm happy to address any feedback!

- Add Categories field to Article model
- Extract categories from RSS/Atom feeds using gofeed
- Store categories as comma-separated in database
- Add migration for existing databases
- Add --category flag to articles command
- Display categories in article list output
JulienTant added a commit to JulienTant/blogwatcher-cli that referenced this pull request Apr 3, 2026
Parse and store categories/tags from RSS and Atom feeds, with a new
--category flag on the articles command to filter by category.

Inspired by Hyaxia/blogwatcher#11 (by @weronikakombat).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
JulienTant added a commit to JulienTant/blogwatcher-cli that referenced this pull request Apr 4, 2026
* Add SSRF-safe HTTP client with --unsafe-client escape hatch

- Use DataDog go-secure-sdk for SSRF protection (blocks private IPs,
  loopback, link-local, cloud metadata endpoints)
- Refactor rss.Fetcher and scraper.Scraper as structs holding *http.Client
- Scanner accepts Fetcher + Scraper as dependencies (no global state)
- Add --unsafe-client / BLOGWATCHER_UNSAFE_CLIENT flag for local dev
- ScanBlog now returns error (hard fail, not soft error string)
- E2e test verifies safe client blocks loopback requests
- Tests use plain http.Client (no SSRF check needed for httptest)
- Update AGENTS.md: ground claims in evidence, not guesses

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

* Add category support for RSS/Atom feed articles

Parse and store categories/tags from RSS and Atom feeds, with a new
--category flag on the articles command to filter by category.

Inspired by Hyaxia/blogwatcher#11 (by @weronikakombat).

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

* Fix review findings and add category e2e tests

- Only persist discovered feed URL after ParseFeed succeeds
- Fix category LIKE query to use delimited matching (prevents "AI"
  matching "FAIR")
- Replace scanner worker pool with errgroup to prevent deadlock
- Add categories to GitHub RSS fixture and e2e test for --category filter

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

* Fix test compatibility with Fetcher struct API

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

* Store categories as JSON array instead of comma-separated string

- Use json.Marshal/Unmarshal for categories serialization
- Query with json_each() for exact element matching instead of LIKE

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

* Case-insensitive category filtering with LOWER() + test

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

* Propagate JSON serialization errors in category helpers

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

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Store and filter by article categories/tags from RSS/Atom feeds

1 participant