Implements HTTP content negotiation for feed format selection. Phase 2.4 Deliverables: - Content negotiation via Accept header parsing - Quality factor support (q= parameter) - 5 feed endpoints with format routing - 406 Not Acceptable responses with helpful errors - Comprehensive test coverage (63 tests) Endpoints: - /feed - Content negotiation based on Accept header - /feed.rss - Explicit RSS 2.0 - /feed.atom - Explicit ATOM 1.0 - /feed.json - Explicit JSON Feed 1.1 - /feed.xml - Backward compatibility (→ RSS) MIME Type Mapping: - application/rss+xml → RSS 2.0 - application/atom+xml → ATOM 1.0 - application/feed+json or application/json → JSON Feed 1.1 - */* → RSS 2.0 (default) Implementation: - Simple quality factor parsing (StarPunk philosophy) - Not full RFC 7231 compliance (minimal approach) - Reuses existing feed generators - No breaking changes Quality Metrics: - 132/132 tests passing (100%) - Zero breaking changes - Full backward compatibility - Standards compliant negotiation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
58 lines
1.4 KiB
Python
58 lines
1.4 KiB
Python
"""
|
|
Feed generation module for StarPunk
|
|
|
|
This module provides feed generation in multiple formats (RSS, ATOM, JSON Feed)
|
|
with content negotiation and caching support.
|
|
|
|
Exports:
|
|
generate_rss: Generate RSS 2.0 feed
|
|
generate_rss_streaming: Generate RSS 2.0 feed with streaming
|
|
generate_atom: Generate ATOM 1.0 feed
|
|
generate_atom_streaming: Generate ATOM 1.0 feed with streaming
|
|
generate_json_feed: Generate JSON Feed 1.1
|
|
generate_json_feed_streaming: Generate JSON Feed 1.1 with streaming
|
|
negotiate_feed_format: Content negotiation for feed formats
|
|
get_mime_type: Get MIME type for a format name
|
|
"""
|
|
|
|
from .rss import (
|
|
generate_rss,
|
|
generate_rss_streaming,
|
|
format_rfc822_date,
|
|
get_note_title,
|
|
clean_html_for_rss,
|
|
)
|
|
|
|
from .atom import (
|
|
generate_atom,
|
|
generate_atom_streaming,
|
|
)
|
|
|
|
from .json_feed import (
|
|
generate_json_feed,
|
|
generate_json_feed_streaming,
|
|
)
|
|
|
|
from .negotiation import (
|
|
negotiate_feed_format,
|
|
get_mime_type,
|
|
)
|
|
|
|
__all__ = [
|
|
# RSS functions
|
|
"generate_rss",
|
|
"generate_rss_streaming",
|
|
"format_rfc822_date",
|
|
"get_note_title",
|
|
"clean_html_for_rss",
|
|
# ATOM functions
|
|
"generate_atom",
|
|
"generate_atom_streaming",
|
|
# JSON Feed functions
|
|
"generate_json_feed",
|
|
"generate_json_feed_streaming",
|
|
# Content negotiation
|
|
"negotiate_feed_format",
|
|
"get_mime_type",
|
|
]
|