aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--boot.php4
-rw-r--r--include/hostxrd.php6
-rw-r--r--mod/xrd.php27
-rw-r--r--view/xrd_host.tpl11
-rw-r--r--view/xrd_person.tpl17
5 files changed, 65 insertions, 0 deletions
diff --git a/boot.php b/boot.php
index b36a255eb..8d2628845 100644
--- a/boot.php
+++ b/boot.php
@@ -73,6 +73,10 @@ class App {
else {
$this->module = 'home';
}
+
+ if($this->cmd == '.well-known/host-meta')
+ require_once('include/hostxrd.php');
+
$this->pager['page'] = ((x($_GET,'page')) ? $_GET['page'] : 1);
$this->pager['itemspage'] = 50;
$this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];
diff --git a/include/hostxrd.php b/include/hostxrd.php
new file mode 100644
index 000000000..3279cea68
--- /dev/null
+++ b/include/hostxrd.php
@@ -0,0 +1,6 @@
+<?php
+
+ $tpl = file_get_contents('view/xrd_host.tpl');
+ echo str_replace('$domain',$this->hostname,$tpl);
+ session_write_close();
+ exit();
diff --git a/mod/xrd.php b/mod/xrd.php
new file mode 100644
index 000000000..5d43147a7
--- /dev/null
+++ b/mod/xrd.php
@@ -0,0 +1,27 @@
+<?php
+
+
+function xrd_content(&$a) {
+
+ $uri = notags(trim($_GET['uri']));
+ $local = str_replace('acct:', '', $uri);
+ $name = substr($local,0,strpos($local,'@'));
+
+ $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' LIMIT 1",
+ dbesc($name)
+ );
+ if(! count($r))
+ killme();
+
+ $tpl = file_get_contents('view/xrd_person.tpl');
+
+ $o = replace_macros($tpl, array(
+ '$accturi' => $uri,
+ '$profile_url' => $a->get_baseurl() . '/profile/' . $r[0]['nickname'],
+ '$photo' => $a->get_baseurl() . '/photo/profile/' . $r[0]['uid']
+ ));
+
+ echo $o;
+ killme();
+
+} \ No newline at end of file
diff --git a/view/xrd_host.tpl b/view/xrd_host.tpl
new file mode 100644
index 000000000..091c1541b
--- /dev/null
+++ b/view/xrd_host.tpl
@@ -0,0 +1,11 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'
+ xmlns:hm='http://host-meta.net/xrd/1.0'>
+
+ <hm:Host>$domain</hm:Host>
+
+ <Link rel='lrdd'
+ template='http://$domain/xrd/?uri={uri}'>
+ <Title>Resource Descriptor</Title>
+ </Link>
+</XRD>
diff --git a/view/xrd_person.tpl b/view/xrd_person.tpl
new file mode 100644
index 000000000..acf3c4cf4
--- /dev/null
+++ b/view/xrd_person.tpl
@@ -0,0 +1,17 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>
+
+ <Subject>$accturi</Subject>
+ <Alias>$profile_url</Alias>
+
+ <Link rel='http://portablecontacts.net/spec/1.0'
+ href='http://example.com/api/people/' />
+ <Link rel='http://webfinger.net/rel/profile-page'
+ type='text/html'
+ href='$profile_url' />
+ <Link rel='http://microformats.org/profile/hcard'
+ type='text/html'
+ href='$profile_url' />
+ <Link rel='http://webfinger.net/rel/avatar'
+ href='$photo' />
+</XRD>