Self-host the AP ctx

This commit is contained in:
Thomas Sileo 2019-08-17 21:02:30 +02:00
parent ade3bee214
commit ad18ae5715
2 changed files with 17 additions and 1 deletions

10
app.py
View file

@ -43,6 +43,7 @@ from config import MEDIA_CACHE
from config import VERSION from config import VERSION
from core import activitypub from core import activitypub
from core import feed from core import feed
from core import jsonld
from core.activitypub import activity_from_doc from core.activitypub import activity_from_doc
from core.activitypub import activity_url from core.activitypub import activity_url
from core.activitypub import post_to_inbox from core.activitypub import post_to_inbox
@ -223,6 +224,14 @@ def robots_txt():
return Response(response=ROBOTS_TXT, headers={"Content-Type": "text/plain"}) 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/<media_id>") @app.route("/media/<media_id>")
@noindex @noindex
def serve_media(media_id): def serve_media(media_id):
@ -281,6 +290,7 @@ def remote_follow():
def index(): def index():
if is_api_request(): if is_api_request():
_log_sig() _log_sig()
print(ME)
return jsonify(**ME) return jsonify(**ME)
q = { q = {

View file

@ -7,7 +7,7 @@ from enum import Enum
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 little_boxes.activitypub import DEFAULT_CTX as AP_DEFAULT_CTX
from pymongo import MongoClient from pymongo import MongoClient
import sass 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]) 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") SASS_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "sass")
theme_css = f"$primary-color: {THEME_COLOR};\n" theme_css = f"$primary-color: {THEME_COLOR};\n"
with open(os.path.join(SASS_DIR, f"{THEME_STYLE.value}.scss")) as f: with open(os.path.join(SASS_DIR, f"{THEME_STYLE.value}.scss")) as f: