Notice metadata for WebFinger. Not sure if implemented properly.

This is more of a proof of concept and will likely not stay in exactly
this form. We should reasonably deliver the entire notice upon webfinger
querying.
This commit is contained in:
Mikael Nordfeldth
2013-11-01 16:54:59 +01:00
parent 7ddd561837
commit 6ef1967cec
5 changed files with 36 additions and 12 deletions

View File

@@ -11,8 +11,6 @@
abstract class WebFingerResource
{
const PROFILEPAGE = 'http://webfinger.net/rel/profile-page';
protected $identities = array();
protected $object = null;
@@ -47,8 +45,5 @@ abstract class WebFingerResource
return $aliases;
}
public function updateXRD(XML_XRD $xrd) {
$xrd->links[] = new XML_XRD_Element_Link(WebFingerResource::PROFILEPAGE,
$this->object->getUrl(), 'text/html');
}
abstract public function updateXRD(XML_XRD $xrd);
}

View File

@@ -19,9 +19,19 @@ class WebFingerResource_Notice extends WebFingerResource
public function updateXRD(XML_XRD $xrd)
{
parent::updateXRD($xrd);
if (Event::handle('StartWebFingerNoticeLinks', array($xrd, $this->object))) {
$xrd->links[] = new XML_XRD_Element_Link('alternate',
common_local_url('ApiStatusesShow',
array('id'=>$this->object->id,
'format'=>'atom')),
'application/atom+xml');
// TODO: Add atom and json representation links here
// TODO: Add Salmon/callback links and stuff here
$xrd->links[] = new XML_XRD_Element_Link('alternate',
common_local_url('ApiStatusesShow',
array('id'=>$this->object->id,
'format'=>'json')),
'application/json');
Event::handle('EndWebFingerNoticeLinks', array($xrd, $this->object));
}
}
}

View File

@@ -11,6 +11,8 @@
class WebFingerResource_Profile extends WebFingerResource
{
const PROFILEPAGE = 'http://webfinger.net/rel/profile-page';
public function __construct(Profile $object)
{
// The type argument above verifies that it's our class
@@ -53,7 +55,8 @@ class WebFingerResource_Profile extends WebFingerResource
{
if (Event::handle('StartWebFingerProfileLinks', array($xrd, $this->object))) {
parent::updateXRD($xrd);
$xrd->links[] = new XML_XRD_Element_Link(self::PROFILEPAGE,
$this->object->getUrl(), 'text/html');
// XFN
$xrd->links[] = new XML_XRD_Element_Link('http://gmpg.org/xfn/11',