From 60b0e3fdfb93ade29944e4ebf5744b00cdb7ea1f Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 10 Jan 2021 14:21:54 +0000 Subject: [PATCH] Two apschema versions --- context.py | 43 +++++++++++++++++++++++++++++++++++++++++++ pyjsonld.py | 10 +++++++++- 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/context.py b/context.py index 4375df9fc..3043616f0 100644 --- a/context.py +++ b/context.py @@ -11,6 +11,7 @@ validContexts = ( "https://www.w3.org/ns/activitystreams", "https://w3id.org/identity/v1", "https://w3id.org/security/v1", + "*/apschema/v1.9" "*/apschema/v1.21" ) @@ -54,6 +55,48 @@ def hasValidContext(postJsonObject: {}) -> bool: return True +def getApschemaV1_9() -> {}: + # https://domain/apschema/v1.9 + return { + "@context": { + "zot": "https://hub.disroot.org/apschema#", + "id": "@id", + "type": "@type", + "commentPolicy": "as:commentPolicy", + "meData": "zot:meData", + "meDataType": "zot:meDataType", + "meEncoding": "zot:meEncoding", + "meAlgorithm": "zot:meAlgorithm", + "meCreator": "zot:meCreator", + "meSignatureValue": "zot:meSignatureValue", + "locationAddress": "zot:locationAddress", + "locationPrimary": "zot:locationPrimary", + "locationDeleted": "zot:locationDeleted", + "nomadicLocation": "zot:nomadicLocation", + "nomadicHubs": "zot:nomadicHubs", + "emojiReaction": "zot:emojiReaction", + "expires": "zot:expires", + "directMessage": "zot:directMessage", + "schema": "http://schema.org#", + "PropertyValue": "schema:PropertyValue", + "value": "schema:value", + "magicEnv": { + "@id": "zot:magicEnv", + "@type": "@id" + }, + "nomadicLocations": { + "@id": "zot:nomadicLocations", + "@type": "@id" + }, + "ostatus": "http://ostatus.org#", + "conversation": "ostatus:conversation", + "diaspora": "https://diasporafoundation.org/ns/", + "guid": "diaspora:guid", + "Hashtag": "as:Hashtag" + } + } + + def getApschemaV1_21() -> {}: # https://domain/apschema/v1.21 return { diff --git a/pyjsonld.py b/pyjsonld.py index 35ebdf7a3..345418823 100644 --- a/pyjsonld.py +++ b/pyjsonld.py @@ -37,6 +37,7 @@ import traceback from collections import deque, namedtuple from numbers import Integral, Real +from context import getApschemaV1_9 from context import getApschemaV1_21 from context import getV1Schema from context import getV1SecuritySchema @@ -397,7 +398,14 @@ def load_document(url): 'document': getActivitystreamsSchema() } return doc - elif url == 'https://raitisoja.com/apschema/v1.21': + elif url.endswith('/apschema/v1.9'): + doc = { + 'contextUrl': None, + 'documentUrl': url, + 'document': getApschemaV1_9() + } + return doc + elif url.endswith('/apschema/v1.21'): doc = { 'contextUrl': None, 'documentUrl': url,