json/atom/rss feed
This commit is contained in:
parent
97921fae8d
commit
7f419a9904
2 changed files with 31 additions and 5 deletions
|
@ -523,8 +523,8 @@ def gen_feed():
|
|||
fg.logo(ME.get("icon", {}).get("url"))
|
||||
fg.language("en")
|
||||
for item in DB.activities.find(
|
||||
{"box": Box.OUTBOX.value, "type": "Create"}, limit=50
|
||||
):
|
||||
{"box": Box.OUTBOX.value, "type": "Create", "meta.deleted": False}, limit=10
|
||||
).sort("_id", -1):
|
||||
fe = fg.add_entry()
|
||||
fe.id(item["activity"]["object"].get("url"))
|
||||
fe.link(href=item["activity"]["object"].get("url"))
|
||||
|
@ -537,11 +537,11 @@ def json_feed(path: str) -> Dict[str, Any]:
|
|||
"""JSON Feed (https://jsonfeed.org/) document."""
|
||||
data = []
|
||||
for item in DB.activities.find(
|
||||
{"box": Box.OUTBOX.value, "type": "Create"}, limit=50
|
||||
):
|
||||
{"box": Box.OUTBOX.value, "type": "Create", "meta.deleted": False}, limit=10
|
||||
).sort("_id", -1):
|
||||
data.append(
|
||||
{
|
||||
"id": item["id"],
|
||||
"id": item["activity"]["id"],
|
||||
"url": item["activity"]["object"].get("url"),
|
||||
"content_html": item["activity"]["object"]["content"],
|
||||
"content_text": html2text(item["activity"]["object"]["content"]),
|
||||
|
|
26
app.py
26
app.py
|
@ -2167,3 +2167,29 @@ def token_endpoint():
|
|||
"client_id": payload["client_id"],
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@app.route("/feed.json")
|
||||
def json_feed():
|
||||
return Response(
|
||||
response=json.dumps(
|
||||
activitypub.json_feed("/feed.json")
|
||||
),
|
||||
headers={"Content-Type": "application/json"},
|
||||
)
|
||||
|
||||
|
||||
@app.route("/feed.atom")
|
||||
def atom_feed():
|
||||
return Response(
|
||||
response=activitypub.gen_feed().atom_str(),
|
||||
headers={"Content-Type": "application/atom+xml"},
|
||||
)
|
||||
|
||||
|
||||
@app.route("/feed.rss")
|
||||
def rss_feed():
|
||||
return Response(
|
||||
response=activitypub.gen_feed().rss_str(),
|
||||
headers={"Content-Type": "application/rss+xml"},
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue