Commit 3f3b3876 authored by Craig Andrews's avatar Craig Andrews Committed by Evan Prodromou

move xrd and hostmeta out of the OStatus plugin and into core

add event for setting up hostmeta, and use them in the OStatus plugin
parent c65f1994
......@@ -591,6 +591,12 @@ EndPublicXRDS: End XRDS output (right before the closing XRDS tag)
- $action: the current action
- &$xrdsoutputter - XRDSOutputter object to write to
StartHostMetaLinks: Start /.well-known/host-meta links
- &links: array containing the links elements to be written
EndHostMetaLinks: End /.well-known/host-meta links
- &links: array containing the links elements to be written
StartCheckPassword: Check a username/password
- $nickname: The nickname to check
- $password: The password to check
......
......@@ -18,8 +18,10 @@
*/
/**
* @package OStatusPlugin
* @category Action
* @package StatusNet
* @maintainer James Walker <james@status.net>
* @author Craig Andrews <candrews@integralblue.com>
*/
if (!defined('STATUSNET')) {
......@@ -28,19 +30,29 @@ if (!defined('STATUSNET')) {
class HostMetaAction extends Action
{
/**
* Is read only?
*
* @return boolean true
*/
function isReadOnly()
{
return true;
}
function handle()
{
parent::handle();
$domain = common_config('site', 'server');
$url = common_local_url('userxrd');
$url.= '?uri={uri}';
$xrd = new XRD();
$xrd->host = $domain;
$xrd->links[] = array('rel' => Discovery::LRDD_REL,
'template' => $url,
'title' => array('Resource Descriptor'));
if(Event::handle('StartHostMetaLinks', array(&$xrd->links))) {
Event::handle('EndHostMetaLinks', array(&$xrd->links));
}
header('Content-type: application/xrd+xml');
print $xrd->toXML();
......
......@@ -189,7 +189,7 @@ function checkMirror($action_obj, $args)
function isLoginAction($action)
{
static $loginActions = array('login', 'recoverpassword', 'api', 'doc', 'register', 'publicxrds', 'otp', 'opensearch', 'rsd');
static $loginActions = array('login', 'recoverpassword', 'api', 'doc', 'register', 'publicxrds', 'otp', 'opensearch', 'rsd', 'hostmeta');
$login = null;
......
......@@ -149,6 +149,8 @@ class Router
$m->connect('main/xrds',
array('action' => 'publicxrds'));
$m->connect('.well-known/host-meta',
array('action' => 'hostmeta'));
// these take a code
......
......@@ -52,8 +52,6 @@ class OStatusPlugin extends Plugin
function onRouterInitialized($m)
{
// Discovery actions
$m->connect('.well-known/host-meta',
array('action' => 'hostmeta'));
$m->connect('main/xrd',
array('action' => 'userxrd'));
$m->connect('main/ownerxrd',
......@@ -1011,4 +1009,12 @@ class OStatusPlugin extends Plugin
return true;
}
function onStartHostMetaLinks(&$links) {
$url = common_local_url('userxrd');
$url.= '?uri={uri}';
$links[] = array('rel' => Discovery::LRDD_REL,
'template' => $url,
'title' => array('Resource Descriptor'));
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment