[Feature] RSS Feeds
Proposal: RSS Feed Integration for Camphouse
Objective:
Provide RSS feed support for Camphouse, enabling users to subscribe to updates from specific communities or users through a standardized feed format. This feature will allow users to retrieve updates in different formats like XML, JSON, etc., and will integrate with both the API and a dedicated RSS subdomain.
Notes:
We in theory can use the logic for /api/posts?sort=latest&communityId=17c56f3990263037e4d9f7ab
and then just convert that to any of the supported structs.
API Endpoints
-
Community Feeds
RSS feeds for individual communities, supporting various content types like new posts or activities within the community.Endpoint:
GET /rss/c/<community_name>.<ext>?type=<type>
Parameters:
-
community_name
: Name of the local community (e.g., "golang", "tech"). -
ext
: The return type, such as.xml
,.json
,.atom
. -
type
: (optional) Content type, such asnew
,hot
, ortop
. Default isnew
.
Example:
GET /rss/c/golang.xml?type=new
Returned Data (XML Format Example):
<rss version="2.0"> <channel> <title>Golang Community</title> <link>https://camphouse.org/c/golang</link> <description>Latest posts in the Golang community</description> <item> <title>Understanding Goroutines</title> <link>https://camphouse.org/c/golang/123</link> <description>An in-depth look at concurrency in Go</description> <pubDate>Tue, 24 Sep 2024 10:00:00 GMT</pubDate> <author>johnDoe</author> </item> </channel> </rss>
-
-
User Feeds
Allow users to subscribe to individual users' posts, comments, or all activity.Endpoint:
GET /rss/u/<username>.<ext>?type=<type>
Parameters:
-
username
: The local username of the user (e.g., "johndoe"). -
ext
: The return type, such as.xml
,.json
,.atom
. -
type
: The content type (all
,posts
, orcomments
).
Example:
GET /rss/u/johndoe.xml?type=posts
Returned Data (JSON Format Example):
{ "username": "johndoe", "profile": "https://camphouse.org/u/johndoe", "activity_type": "posts", "posts": [ { "title": "New insights into Go channels", "link": "https://camphouse.org/u/johndoe/posts/456", "description": "A detailed guide to channels in Go.", "pubDate": "2024-09-20T08:30:00Z" } ] }
-
Subdomain Support
Redirects:
Support accessing RSS feeds via a subdomain for ease of use:
-
Example:
rss.camphouse.org/c/golang.xml
should internally redirect toapi.camphouse.org/rss/c/golang.xml
. -
Path Rewrite Rules:
Use a rewrite to internally route traffic:-
rss.camphouse.org
→api.camphouse.org/rss/
.
-
Additional Features:
-
Customizable Return Types:
The.ext
parameter allows flexibility for developers to request content in different formats (e.g.,.xml
for RSS readers,.json
for web applications). -
Pagination Support:
For large feeds, add pagination support using apage
query parameter to return a limited number of items per request.
Example:/rss/c/golang.xml?type=new&page=2
-
Caching and Rate-Limiting:
Implement caching on the server side to reduce load and rate-limit requests to prevent abuse.