mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-11-15 03:04:28 +00:00
Use the toot namespace/AP extension
This commit is contained in:
parent
fcf9524ac0
commit
e2d814a456
2 changed files with 10 additions and 15 deletions
18
app.py
18
app.py
|
@ -276,9 +276,9 @@ def domain(url):
|
||||||
|
|
||||||
@app.template_filter()
|
@app.template_filter()
|
||||||
def url_or_id(d):
|
def url_or_id(d):
|
||||||
if 'url' in d:
|
if "url" in d:
|
||||||
return d['url']
|
return d["url"]
|
||||||
return d['id']
|
return d["id"]
|
||||||
|
|
||||||
|
|
||||||
@app.template_filter()
|
@app.template_filter()
|
||||||
|
@ -355,6 +355,7 @@ def is_img(filename):
|
||||||
|
|
||||||
def add_response_headers(headers={}):
|
def add_response_headers(headers={}):
|
||||||
"""This decorator adds the headers passed in to the response"""
|
"""This decorator adds the headers passed in to the response"""
|
||||||
|
|
||||||
def decorator(f):
|
def decorator(f):
|
||||||
@wraps(f)
|
@wraps(f)
|
||||||
def decorated_function(*args, **kwargs):
|
def decorated_function(*args, **kwargs):
|
||||||
|
@ -363,13 +364,15 @@ def add_response_headers(headers={}):
|
||||||
for header, value in headers.items():
|
for header, value in headers.items():
|
||||||
h[header] = value
|
h[header] = value
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
return decorated_function
|
return decorated_function
|
||||||
|
|
||||||
return decorator
|
return decorator
|
||||||
|
|
||||||
|
|
||||||
def noindex(f):
|
def noindex(f):
|
||||||
"""This decorator passes X-Robots-Tag: noindex, nofollow"""
|
"""This decorator passes X-Robots-Tag: noindex, nofollow"""
|
||||||
return add_response_headers({'X-Robots-Tag': 'noindex, nofollow'})(f)
|
return add_response_headers({"X-Robots-Tag": "noindex, nofollow"})(f)
|
||||||
|
|
||||||
|
|
||||||
def login_required(f):
|
def login_required(f):
|
||||||
|
@ -415,7 +418,7 @@ def api_required(f):
|
||||||
|
|
||||||
def jsonify(**data):
|
def jsonify(**data):
|
||||||
if "@context" not in data:
|
if "@context" not in data:
|
||||||
data["@context"] = config.CTX_AS
|
data["@context"] = config.DEFAULT_CTX
|
||||||
return Response(
|
return Response(
|
||||||
response=json.dumps(data),
|
response=json.dumps(data),
|
||||||
headers={
|
headers={
|
||||||
|
@ -978,11 +981,6 @@ def wellknown_nodeinfo():
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# @app.route('/fake_feed')
|
|
||||||
# def fake_feed():
|
|
||||||
# return '<?xml version="1.0"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:activity="http://activitystrea.ms/spec/1.0/" xmlns:poco="http://portablecontacts.net/spec/1.0" xmlns:ostatus="http://ostatus.org/schema/1.0"><id>https://lol3.tun.a4.io/fake_feed</id><author><id>https://lol3.tun.a4.io/fake</id></author><entry></entry></feed>'
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/.well-known/webfinger")
|
@app.route("/.well-known/webfinger")
|
||||||
def wellknown_webfinger():
|
def wellknown_webfinger():
|
||||||
"""Enable WebFinger support, required for Mastodon interopability."""
|
"""Enable WebFinger support, required for Mastodon interopability."""
|
||||||
|
|
|
@ -9,6 +9,7 @@ import sass
|
||||||
import yaml
|
import yaml
|
||||||
from itsdangerous import JSONWebSignatureSerializer
|
from itsdangerous import JSONWebSignatureSerializer
|
||||||
from little_boxes import strtobool
|
from little_boxes import strtobool
|
||||||
|
from little_boxes.activitypub import DEFAULT_CTX
|
||||||
from pymongo import MongoClient
|
from pymongo import MongoClient
|
||||||
|
|
||||||
from utils.key import KEY_DIR
|
from utils.key import KEY_DIR
|
||||||
|
@ -46,10 +47,6 @@ VERSION = (
|
||||||
|
|
||||||
DEBUG_MODE = strtobool(os.getenv("MICROBLOGPUB_DEBUG", "false"))
|
DEBUG_MODE = strtobool(os.getenv("MICROBLOGPUB_DEBUG", "false"))
|
||||||
|
|
||||||
|
|
||||||
CTX_AS = "https://www.w3.org/ns/activitystreams"
|
|
||||||
CTX_SECURITY = "https://w3id.org/security/v1"
|
|
||||||
AS_PUBLIC = "https://www.w3.org/ns/activitystreams#Public"
|
|
||||||
HEADERS = [
|
HEADERS = [
|
||||||
"application/activity+json",
|
"application/activity+json",
|
||||||
"application/ld+json;profile=https://www.w3.org/ns/activitystreams",
|
"application/ld+json;profile=https://www.w3.org/ns/activitystreams",
|
||||||
|
@ -129,7 +126,7 @@ def _admin_jwt_token() -> str:
|
||||||
ADMIN_API_KEY = get_secret_key("admin_api_key", _admin_jwt_token)
|
ADMIN_API_KEY = get_secret_key("admin_api_key", _admin_jwt_token)
|
||||||
|
|
||||||
ME = {
|
ME = {
|
||||||
"@context": [CTX_AS, CTX_SECURITY],
|
"@context": DEFAULT_CTX,
|
||||||
"type": "Person",
|
"type": "Person",
|
||||||
"id": ID,
|
"id": ID,
|
||||||
"following": ID + "/following",
|
"following": ID + "/following",
|
||||||
|
|
Loading…
Reference in a new issue