Merge pull request #12745 from MrPetovan/task/12728-jsonld-local-files

Read local files instead of performing self HTTP requests in JsonLD::documentLoader
This commit is contained in:
Philipp 2023-01-29 08:20:58 +01:00 committed by GitHub
commit 74b616f6d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View file

@ -43,7 +43,7 @@ class BasePath
}
/**
* Returns the base filesystem path of the App
* Returns the base Friendica filesystem path without trailing slash
*
* It first checks for the internal variable, then for DOCUMENT_ROOT and
* finally for PWD
@ -71,7 +71,7 @@ class BasePath
throw new \Exception(sprintf('\'%s\' is not a valid basepath', $baseDir));
}
return $baseDir;
return rtrim($baseDir, '/');
}
/**

View file

@ -44,26 +44,26 @@ class JsonLD
{
switch ($url) {
case 'https://w3id.org/security/v1':
$url = DI::baseUrl() . '/static/security-v1.jsonld';
$url = DI::basePath() . '/static/security-v1.jsonld';
break;
case 'https://w3id.org/identity/v1':
$url = DI::baseUrl() . '/static/identity-v1.jsonld';
$url = DI::basePath() . '/static/identity-v1.jsonld';
break;
case 'https://www.w3.org/ns/activitystreams':
$url = DI::baseUrl() . '/static/activitystreams.jsonld';
$url = DI::basePath() . '/static/activitystreams.jsonld';
break;
case 'https://funkwhale.audio/ns':
$url = DI::baseUrl() . '/static/funkwhale.audio.jsonld';
$url = DI::basePath() . '/static/funkwhale.audio.jsonld';
break;
default:
switch (parse_url($url, PHP_URL_PATH)) {
case '/schemas/litepub-0.1.jsonld';
$url = DI::baseUrl() . '/static/litepub-0.1.jsonld';
$url = DI::basePath() . '/static/litepub-0.1.jsonld';
break;
case '/apschema/v1.2':
case '/apschema/v1.9':
case '/apschema/v1.10':
$url = DI::baseUrl() . '/static/apschema.jsonld';
$url = DI::basePath() . '/static/apschema.jsonld';
break;
default:
Logger::info('Got url', ['url' =>$url]);