diff --git a/mod/oexchange.php b/mod/oexchange.php
index 2060ddd13..173de0a6b 100644
--- a/mod/oexchange.php
+++ b/mod/oexchange.php
@@ -20,20 +20,77 @@
*/
use Friendica\App;
-use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Module\Response;
use Friendica\Module\Security\Login;
+use Friendica\Util\XML;
-function oexchange_init(App $a) {
-
- if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'xrd')) {
- $tpl = Renderer::getMarkupTemplate('oexchange_xrd.tpl');
-
- $o = Renderer::replaceMacros($tpl, ['$base' => DI::baseUrl()]);
- System::httpExit($o, Response::TYPE_XML, 'application/xrd+xml');
+function oexchange_init(App $a)
+{
+ if ((DI::args()->getArgc() <= 1) || (DI::args()->getArgv()[1] != 'xrd')) {
+ return;
}
+
+ $baseURL = DI::baseUrl()->get();
+
+ $xml = null;
+
+ XML::fromArray([
+ 'XRD' => [
+ '@attributes' => [
+ 'xmlns' => 'http://docs.oasis-open.org/ns/xri/xrd-1.0',
+ ],
+ 'Subject' => $baseURL,
+ '1:Property' => [
+ '@attributes' => [
+ 'type' => 'http://www.oexchange.org/spec/0.8/prop/vendor',
+ ],
+ 'Friendica'
+ ],
+ '2:Property' => [
+ '@attributes' => [
+ 'type' => 'http://www.oexchange.org/spec/0.8/prop/title',
+ ],
+ 'Friendica Social Network'
+ ],
+ '3:Property' => [
+ '@attributes' => [
+ 'type' => 'http://www.oexchange.org/spec/0.8/prop/name',
+ ],
+ 'Friendica'
+ ],
+ '4:Property' => [
+ '@attributes' => [
+ 'type' => 'http://www.oexchange.org/spec/0.8/prop/prompt',
+ ],
+ 'Send to Friendica'
+ ],
+ '1:link' => [
+ '@attributes' => [
+ 'rel' => 'icon',
+ 'type' => 'image/png',
+ 'href' => $baseURL . '/images/friendica-16.png'
+ ]
+ ],
+ '2:link' => [
+ '@attributes' => [
+ 'rel' => 'icon32',
+ 'type' => 'image/png',
+ 'href' => $baseURL . '/images/friendica-32.png'
+ ]
+ ],
+ '3:link' => [
+ '@attributes' => [
+ 'rel' => 'http://www.oexchange.org/spec/0.8/rel/offer',
+ 'type' => 'text/html',
+ 'href' => $baseURL . '/oexchange'
+ ]
+ ],
+ ],
+ ], $xml);
+
+ System::httpExit($xml->saveXML(), Response::TYPE_XML, 'application/xrd+xml');
}
function oexchange_content(App $a) {
diff --git a/mod/poco.php b/mod/poco.php
index 73179a33f..b4d0f343a 100644
--- a/mod/poco.php
+++ b/mod/poco.php
@@ -24,13 +24,10 @@ use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
-use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
-use Friendica\Module\Response;
use Friendica\Util\DateTimeFormat;
-use Friendica\Util\XML;
function poco_init(App $a) {
if (intval(DI::config()->get('system', 'block_public')) || (DI::config()->get('system', 'block_local_dir'))) {
@@ -229,12 +226,9 @@ function poco_init(App $a) {
Logger::info("End of poco");
- if ($format === 'xml') {
- System::httpExit(Renderer::replaceMacros(Renderer::getMarkupTemplate('poco_xml.tpl'), XML::arrayEscape(['$response' => $ret])), Response::TYPE_XML);
- }
if ($format === 'json') {
System::jsonExit($ret);
} else {
- throw new \Friendica\Network\HTTPException\InternalServerErrorException();
+ throw new \Friendica\Network\HTTPException\UnsupportedMediaTypeException();
}
}
diff --git a/src/Module/WellKnown/HostMeta.php b/src/Module/WellKnown/HostMeta.php
index 2ca66f93b..b1ab0e0d3 100644
--- a/src/Module/WellKnown/HostMeta.php
+++ b/src/Module/WellKnown/HostMeta.php
@@ -22,12 +22,12 @@
namespace Friendica\Module\WellKnown;
use Friendica\BaseModule;
-use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Module\Response;
use Friendica\Protocol\Salmon;
use Friendica\Util\Crypto;
+use Friendica\Util\XML;
/**
* Prints the metadata for describing this host
@@ -46,14 +46,58 @@ class HostMeta extends BaseModule
$config->set('system', 'site_pubkey', $res['pubkey']);
}
- $tpl = Renderer::getMarkupTemplate('xrd_host.tpl');
- $content = Renderer::replaceMacros($tpl, [
- '$zhost' => DI::baseUrl()->getHostname(),
- '$zroot' => DI::baseUrl()->get(),
- '$domain' => DI::baseUrl()->get(),
- '$bigkey' => Salmon::salmonKey($config->get('system', 'site_pubkey'))
- ]);
+ $domain = DI::baseUrl()->get();
- System::httpExit($content, Response::TYPE_XML, 'application/xrd+xml');
+ $xml = null;
+ XML::fromArray([
+ 'XRD' => [
+ '@attributes' => [
+ 'xmlns' => 'http://docs.oasis-open.org/ns/xri/xrd-1.0',
+ ],
+ 'hm:Host' => DI::baseUrl()->getHostname(),
+ '1:link' => [
+ '@attributes' => [
+ 'rel' => 'lrdd',
+ 'type' => 'application/xrd+xml',
+ 'template' => $domain . '/xrd?uri={uri}'
+ ]
+ ],
+ '2:link' => [
+ '@attributes' => [
+ 'rel' => 'lrdd',
+ 'type' => 'application/json',
+ 'template' => $domain . '/.well-known/webfinger?resource={uri}'
+ ]
+ ],
+ '3:link' => [
+ '@attributes' => [
+ 'rel' => 'acct-mgmt',
+ 'href' => $domain . '/amcd'
+ ]
+ ],
+ '4:link' => [
+ '@attributes' => [
+ 'rel' => 'http://services.mozilla.com/amcd/0.1',
+ 'href' => $domain . '/amcd'
+ ]
+ ],
+ '5:link' => [
+ '@attributes' => [
+ 'rel' => 'http://oexchange.org/spec/0.8/rel/resident-target',
+ 'type' => 'application/xrd+xml',
+ 'href' => $domain . '/oexchange/xrd'
+ ]
+ ],
+ 'Property' => [
+ '@attributes' => [
+ 'type' => 'http://salmon-protocol.org/ns/magic-key',
+ 'mk:key_id' => '1'
+ ],
+ Salmon::salmonKey($config->get('system', 'site_pubkey'))
+ ]
+ ],
+ ], $xml, false, ['hm' => 'http://host-meta.net/xrd/1.0', 'mk' => 'http://salmon-protocol.org/ns/magic-key']);
+
+ System::httpExit($xml->saveXML(), Response::TYPE_XML, 'application/xrd+xml');
}
}
diff --git a/src/Module/Xrd.php b/src/Module/Xrd.php
index 143d3e722..b12e94a29 100644
--- a/src/Module/Xrd.php
+++ b/src/Module/Xrd.php
@@ -22,8 +22,6 @@
namespace Friendica\Module;
use Friendica\BaseModule;
-use Friendica\Core\Hook;
-use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Photo;
@@ -31,6 +29,7 @@ use Friendica\Model\User;
use Friendica\Network\HTTPException\NotFoundException;
use Friendica\Protocol\ActivityNamespace;
use Friendica\Protocol\Salmon;
+use Friendica\Util\XML;
/**
* Prints responses to /.well-known/webfinger or /xrd requests
@@ -82,15 +81,10 @@ class Xrd extends BaseModule
}
$this->printSystemJSON($owner);
} else {
- $user = User::getByNickname($name);
- if (empty($user)) {
- throw new NotFoundException('User was not found for name=' . $name);
- }
-
- $owner = User::getOwnerDataById($user['uid']);
+ $owner = User::getOwnerDataByNick($name);
if (empty($owner)) {
- DI::logger()->warning('No owner data for user id', ['uri' => $uri, 'name' => $name, 'user' => $user]);
- throw new NotFoundException('Owner was not found for user->uid=' . $user['uid']);
+ DI::logger()->warning('No owner data for user id', ['uri' => $uri, 'name' => $name]);
+ throw new NotFoundException('Owner was not found for user->uid=' . $name);
}
$alias = str_replace('/profile/', '/~', $owner['url']);
@@ -103,7 +97,7 @@ class Xrd extends BaseModule
}
if ($mode == Response::TYPE_XML) {
- $this->printXML($alias, $user, $owner, $avatar);
+ $this->printXML($alias, $owner, $avatar);
} else {
$this->printJSON($alias, $owner, $avatar);
}
@@ -158,7 +152,6 @@ class Xrd extends BaseModule
private function printJSON(string $alias, array $owner, array $avatar)
{
$baseURL = $this->baseUrl->get();
- $salmon_key = Salmon::salmonKey($owner['spubkey']);
$json = [
'subject' => 'acct:' . $owner['addr'],
@@ -223,7 +216,7 @@ class Xrd extends BaseModule
],
[
'rel' => 'magic-public-key',
- 'href' => 'data:application/magic-public-key,' . $salmon_key,
+ 'href' => 'data:application/magic-public-key,' . Salmon::salmonKey($owner['spubkey']),
],
[
'rel' => 'http://purl.org/openwebauth/v1',
@@ -237,35 +230,109 @@ class Xrd extends BaseModule
System::jsonExit($json, 'application/jrd+json; charset=utf-8');
}
- private function printXML(string $alias, array $user, array $owner, array $avatar)
+ private function printXML(string $alias, array $owner, array $avatar)
{
$baseURL = $this->baseUrl->get();
- $salmon_key = Salmon::salmonKey($owner['spubkey']);
- $tpl = Renderer::getMarkupTemplate('xrd_person.tpl');
+ $xml = null;
- $o = Renderer::replaceMacros($tpl, [
- '$nick' => $owner['nickname'],
- '$accturi' => 'acct:' . $owner['addr'],
- '$alias' => $alias,
- '$profile_url' => $owner['url'],
- '$hcard_url' => $baseURL . '/hcard/' . $owner['nickname'],
- '$atom' => $owner['poll'],
- '$poco_url' => $owner['poco'],
- '$photo' => User::getAvatarUrl($owner),
- '$type' => $avatar['type'],
- '$salmon' => $baseURL . '/salmon/' . $owner['nickname'],
- '$salmen' => $baseURL . '/salmon/' . $owner['nickname'] . '/mention',
- '$subscribe' => $baseURL . '/follow?url={uri}',
- '$openwebauth' => $baseURL . '/owa',
- '$modexp' => 'data:application/magic-public-key,' . $salmon_key
- ]);
-
- $arr = ['user' => $user, 'xml' => $o];
- Hook::callAll('personal_xrd', $arr);
+ XML::fromArray([
+ 'XRD' => [
+ '@attributes' => [
+ 'xmlns' => 'http://docs.oasis-open.org/ns/xri/xrd-1.0',
+ ],
+ 'Subject' => 'acct:' . $owner['addr'],
+ '1:Alias' => $owner['url'],
+ '2:Alias' => $alias,
+ '1:link' => [
+ '@attributes' => [
+ 'rel' => 'http://purl.org/macgirvin/dfrn/1.0',
+ 'href' => $owner['url']
+ ]
+ ],
+ '2:link' => [
+ '@attributes' => [
+ 'rel' => 'http://schemas.google.com/g/2010#updates-from',
+ 'type' => 'application/atom+xml',
+ 'href' => $owner['poll']
+ ]
+ ],
+ '3:link' => [
+ '@attributes' => [
+ 'rel' => 'http://webfinger.net/rel/profile-page',
+ 'type' => 'text/html',
+ 'href' => $owner['url']
+ ]
+ ],
+ '4:link' => [
+ '@attributes' => [
+ 'rel' => 'http://microformats.org/profile/hcard',
+ 'type' => 'text/html',
+ 'href' => $baseURL . '/hcard/' . $owner['nickname']
+ ]
+ ],
+ '5:link' => [
+ '@attributes' => [
+ 'rel' => 'http://portablecontacts.net/spec/1.0',
+ 'href' => $owner['poco']
+ ]
+ ],
+ '6:link' => [
+ '@attributes' => [
+ 'rel' => 'http://webfinger.net/rel/avatar',
+ 'type' => $avatar['type'],
+ 'href' => User::getAvatarUrl($owner)
+ ]
+ ],
+ '7:link' => [
+ '@attributes' => [
+ 'rel' => 'http://joindiaspora.com/seed_location',
+ 'type' => 'text/html',
+ 'href' => $baseURL
+ ]
+ ],
+ '8:link' => [
+ '@attributes' => [
+ 'rel' => 'salmon',
+ 'href' => $baseURL . '/salmon/' . $owner['nickname']
+ ]
+ ],
+ '9:link' => [
+ '@attributes' => [
+ 'rel' => 'http://salmon-protocol.org/ns/salmon-replies',
+ 'href' => $baseURL . '/salmon/' . $owner['nickname']
+ ]
+ ],
+ '10:link' => [
+ '@attributes' => [
+ 'rel' => 'http://salmon-protocol.org/ns/salmon-mention',
+ 'href' => $baseURL . '/salmon/' . $owner['nickname'] . '/mention'
+ ]
+ ],
+ '11:link' => [
+ '@attributes' => [
+ 'rel' => 'http://ostatus.org/schema/1.0/subscribe',
+ 'template' => $baseURL . '/follow?url={uri}'
+ ]
+ ],
+ '12:link' => [
+ '@attributes' => [
+ 'rel' => 'magic-public-key',
+ 'href' => 'data:application/magic-public-key,' . Salmon::salmonKey($owner['spubkey'])
+ ]
+ ],
+ '13:link' => [
+ '@attributes' => [
+ 'rel' => 'http://purl.org/openwebauth/v1',
+ 'type' => 'application/x-zot+json',
+ 'href' => $baseURL . '/owa'
+ ]
+ ],
+ ],
+ ], $xml);
header('Access-Control-Allow-Origin: *');
- System::httpExit($arr['xml'], Response::TYPE_XML, 'application/xrd+xml');
+ System::httpExit($xml->saveXML(), Response::TYPE_XML, 'application/xrd+xml');
}
}
diff --git a/view/templates/oexchange_xrd.tpl b/view/templates/oexchange_xrd.tpl
deleted file mode 100644
index 7c31f2126..000000000
--- a/view/templates/oexchange_xrd.tpl
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
- {{$base}}
-
- Friendica
- Friendica Social Network
- Friendica
- Send to Friendica
-
-
-
-
-
-
-
diff --git a/view/templates/poco_entry_xml.tpl b/view/templates/poco_entry_xml.tpl
deleted file mode 100644
index 26dd38014..000000000
--- a/view/templates/poco_entry_xml.tpl
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-{{if $entry.id}}{{$entry.id}}{{/if}}
-{{if $entry.displayName}}{{$entry.displayName}}{{/if}}
-{{if $entry.preferredUsername}}{{$entry.preferredUsername}}{{/if}}
-{{if $entry.urls}}{{foreach $entry.urls as $url}}{{$url.value}}{{$url.type}}{{/foreach}}{{/if}}
-{{if $entry.photos}}{{foreach $entry.photos as $photo}}{{$photo.value}}{{$photo.type}}{{/foreach}}{{/if}}
-
diff --git a/view/templates/poco_xml.tpl b/view/templates/poco_xml.tpl
deleted file mode 100644
index 0e38a692c..000000000
--- a/view/templates/poco_xml.tpl
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-{{if $response.sorted}}{{$response.sorted}}{{/if}}
-{{if $response.filtered}}{{$response.filtered}}{{/if}}
-{{if $response.updatedSince}}{{$response.updatedSince}}{{/if}}
-{{$response.startIndex}}
-{{$response.itemsPerPage}}
-{{$response.totalResults}}
-
-
-{{if $response.totalResults}}
-{{foreach $response.entry as $entry}}
-{{include file="poco_entry_xml.tpl"}}
-{{/foreach}}
-{{else}}
-
-{{/if}}
-
diff --git a/view/templates/xrd_host.tpl b/view/templates/xrd_host.tpl
deleted file mode 100644
index 7a49e06c0..000000000
--- a/view/templates/xrd_host.tpl
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
- {{$zhost}}
-
-
-
-
-
-
-
- {{$bigkey}}
-
diff --git a/view/templates/xrd_person.tpl b/view/templates/xrd_person.tpl
deleted file mode 100644
index 0fb81b09c..000000000
--- a/view/templates/xrd_person.tpl
+++ /dev/null
@@ -1,39 +0,0 @@
-
-
- {{$accturi}}
- {{$profile_url}}
- {{$alias}}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-