From ad18ae5715fe8265571cee86e3d121e91ebfcedb Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Sat, 17 Aug 2019 21:02:30 +0200 Subject: [PATCH] Self-host the AP ctx --- app.py | 10 ++++++++++ config.py | 8 +++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index fe678fc..f6d134d 100644 --- a/app.py +++ b/app.py @@ -43,6 +43,7 @@ from config import MEDIA_CACHE from config import VERSION from core import activitypub from core import feed +from core import jsonld from core.activitypub import activity_from_doc from core.activitypub import activity_url from core.activitypub import post_to_inbox @@ -223,6 +224,14 @@ def robots_txt(): return Response(response=ROBOTS_TXT, headers={"Content-Type": "text/plain"}) +@app.route("/microblogpub-0.0.jsonld") +def microblogpub_jsonld(): + return Response( + response=json.dumps(jsonld.MICROBLOGPUB), + headers={"Content-Type": "application/ld+json"}, + ) + + @app.route("/media/") @noindex def serve_media(media_id): @@ -281,6 +290,7 @@ def remote_follow(): def index(): if is_api_request(): _log_sig() + print(ME) return jsonify(**ME) q = { diff --git a/config.py b/config.py index a4967a9..607e62c 100644 --- a/config.py +++ b/config.py @@ -7,7 +7,7 @@ from enum import Enum import yaml from itsdangerous import JSONWebSignatureSerializer from little_boxes import strtobool -from little_boxes.activitypub import DEFAULT_CTX +from little_boxes.activitypub import DEFAULT_CTX as AP_DEFAULT_CTX from pymongo import MongoClient import sass @@ -73,6 +73,12 @@ with open(os.path.join(KEY_DIR, "me.yml")) as f: THEME_COLOR = theme_conf.get("color", DEFAULT_THEME_PRIMARY_COLOR[THEME_STYLE]) +DEFAULT_CTX = [ + AP_DEFAULT_CTX, + f"{BASE_URL}/microblogpub-0.0.jsonld", + {"@language": "und"}, +] + SASS_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "sass") theme_css = f"$primary-color: {THEME_COLOR};\n" with open(os.path.join(SASS_DIR, f"{THEME_STYLE.value}.scss")) as f: