added webfinger support

This commit is contained in:
Mike Macgirvin 2010-07-23 16:33:34 -07:00
parent 938247427d
commit 89c15cc092
5 changed files with 65 additions and 0 deletions

View File

@ -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'];

6
include/hostxrd.php Normal file
View File

@ -0,0 +1,6 @@
<?php
$tpl = file_get_contents('view/xrd_host.tpl');
echo str_replace('$domain',$this->hostname,$tpl);
session_write_close();
exit();

27
mod/xrd.php Normal file
View File

@ -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();
}

11
view/xrd_host.tpl Normal file
View File

@ -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>

17
view/xrd_person.tpl Normal file
View File

@ -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>