mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-11-15 03:04:28 +00:00
Add support for the featured collection
This commit is contained in:
parent
d26d6ba70e
commit
f23dbcaf05
3 changed files with 20 additions and 1 deletions
|
@ -638,6 +638,16 @@ def embed_collection(total_items, first_page_id):
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def simple_build_ordered_collection(col_name, data):
|
||||||
|
return {
|
||||||
|
"@context": ap.COLLECTION_CTX,
|
||||||
|
"id": BASE_URL + "/" + col_name,
|
||||||
|
"totalItems": len(data),
|
||||||
|
"type": ap.ActivityType.ORDERED_COLLECTION.value,
|
||||||
|
"orederedItems": data,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def build_ordered_collection(
|
def build_ordered_collection(
|
||||||
col, q=None, cursor=None, map_func=None, limit=50, col_name=None, first_page=False
|
col, q=None, cursor=None, map_func=None, limit=50, col_name=None, first_page=False
|
||||||
):
|
):
|
||||||
|
@ -652,6 +662,7 @@ def build_ordered_collection(
|
||||||
|
|
||||||
if not data:
|
if not data:
|
||||||
return {
|
return {
|
||||||
|
"@context": ap.COLLECTION_CTX,
|
||||||
"id": BASE_URL + "/" + col_name,
|
"id": BASE_URL + "/" + col_name,
|
||||||
"totalItems": 0,
|
"totalItems": 0,
|
||||||
"type": ap.ActivityType.ORDERED_COLLECTION.value,
|
"type": ap.ActivityType.ORDERED_COLLECTION.value,
|
||||||
|
|
9
app.py
9
app.py
|
@ -23,10 +23,10 @@ import timeago
|
||||||
from bson.objectid import ObjectId
|
from bson.objectid import ObjectId
|
||||||
from dateutil import parser
|
from dateutil import parser
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
|
from flask import make_response
|
||||||
from flask import Response
|
from flask import Response
|
||||||
from flask import abort
|
from flask import abort
|
||||||
from flask import jsonify as flask_jsonify
|
from flask import jsonify as flask_jsonify
|
||||||
from flask import make_response
|
|
||||||
from flask import redirect
|
from flask import redirect
|
||||||
from flask import render_template
|
from flask import render_template
|
||||||
from flask import request
|
from flask import request
|
||||||
|
@ -1779,6 +1779,13 @@ def tags(tag):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/featured")
|
||||||
|
def featured():
|
||||||
|
if not is_api_request():
|
||||||
|
abort(404)
|
||||||
|
return jsonify(**activitypub.simple_build_ordered_collection("featured", []))
|
||||||
|
|
||||||
|
|
||||||
@app.route("/liked")
|
@app.route("/liked")
|
||||||
def liked():
|
def liked():
|
||||||
if not is_api_request():
|
if not is_api_request():
|
||||||
|
|
|
@ -131,6 +131,7 @@ ME = {
|
||||||
"id": ID,
|
"id": ID,
|
||||||
"following": ID + "/following",
|
"following": ID + "/following",
|
||||||
"followers": ID + "/followers",
|
"followers": ID + "/followers",
|
||||||
|
"featured": ID + "/featured",
|
||||||
"liked": ID + "/liked",
|
"liked": ID + "/liked",
|
||||||
"inbox": ID + "/inbox",
|
"inbox": ID + "/inbox",
|
||||||
"outbox": ID + "/outbox",
|
"outbox": ID + "/outbox",
|
||||||
|
|
Loading…
Reference in a new issue