From 8d54809c3561bf56afcdb401ef3c009e9a180cbc Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Sun, 5 Sep 2010 17:43:29 -0400 Subject: [PATCH] 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 --- EVENTS.txt | 8 ++++++- .../OStatus/actions => actions}/hostmeta.php | 23 ++++++++++++++----- index.php | 2 +- lib/router.php | 2 ++ {plugins/OStatus/lib => lib}/xrd.php | 0 plugins/OStatus/OStatusPlugin.php | 10 ++++++-- 6 files changed, 35 insertions(+), 10 deletions(-) rename {plugins/OStatus/actions => actions}/hostmeta.php (75%) rename {plugins/OStatus/lib => lib}/xrd.php (100%) diff --git a/EVENTS.txt b/EVENTS.txt index 17e7d62b60..8b7448d675 100644 --- a/EVENTS.txt +++ b/EVENTS.txt @@ -551,6 +551,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 @@ -1095,4 +1101,4 @@ StartShowPageTitle: when beginning to show the page title

- $action: action being shown EndShowPageTitle: when done showing the page title

-- $action: action being shown \ No newline at end of file +- $action: action being shown diff --git a/plugins/OStatus/actions/hostmeta.php b/actions/hostmeta.php similarity index 75% rename from plugins/OStatus/actions/hostmeta.php rename to actions/hostmeta.php index 8ca07f9165..be73665f29 100644 --- a/plugins/OStatus/actions/hostmeta.php +++ b/actions/hostmeta.php @@ -18,8 +18,10 @@ */ /** - * @package OStatusPlugin + * @category Action + * @package StatusNet * @maintainer James Walker + * @author Craig Andrews */ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } @@ -27,19 +29,28 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } 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(); diff --git a/index.php b/index.php index 3efe5c8e49..21e222e3b8 100644 --- a/index.php +++ b/index.php @@ -204,7 +204,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; diff --git a/lib/router.php b/lib/router.php index ca3c2e880c..86dd116c8d 100644 --- a/lib/router.php +++ b/lib/router.php @@ -151,6 +151,8 @@ class Router $m->connect('main/xrds', array('action' => 'publicxrds')); + $m->connect('.well-known/host-meta', + array('action' => 'hostmeta')); // these take a code diff --git a/plugins/OStatus/lib/xrd.php b/lib/xrd.php similarity index 100% rename from plugins/OStatus/lib/xrd.php rename to lib/xrd.php diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php index 77bc9872b4..dd15099542 100644 --- a/plugins/OStatus/OStatusPlugin.php +++ b/plugins/OStatus/OStatusPlugin.php @@ -50,8 +50,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', @@ -1012,4 +1010,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')); + } }