summaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
Diffstat (limited to 'actions')
-rw-r--r--actions/all.php14
-rw-r--r--actions/newmessage.php21
-rw-r--r--actions/public.php17
-rw-r--r--actions/publicxrds.php81
-rw-r--r--actions/replies.php24
-rw-r--r--actions/showfavorites.php26
-rw-r--r--actions/showgroup.php14
-rw-r--r--actions/shownotice.php4
-rw-r--r--actions/showstream.php16
-rw-r--r--actions/tag.php16
-rw-r--r--actions/xrds.php106
11 files changed, 246 insertions, 93 deletions
diff --git a/actions/all.php b/actions/all.php
index f1786462e..61cedce74 100644
--- a/actions/all.php
+++ b/actions/all.php
@@ -99,19 +99,17 @@ class AllAction extends ProfileAction
sprintf(_('Feed for friends of %s (RSS 1.0)'), $this->user->nickname)),
new Feed(Feed::RSS2,
common_local_url(
- 'api', array(
- 'apiaction' => 'statuses',
- 'method' => 'friends_timeline',
- 'argument' => $this->user->nickname.'.rss'
+ 'ApiTimelineFriends', array(
+ 'format' => 'rss',
+ 'id' => $this->user->nickname
)
),
sprintf(_('Feed for friends of %s (RSS 2.0)'), $this->user->nickname)),
new Feed(Feed::ATOM,
common_local_url(
- 'api', array(
- 'apiaction' => 'statuses',
- 'method' => 'friends_timeline',
- 'argument' => $this->user->nickname.'.atom'
+ 'ApiTimelineFriends', array(
+ 'format' => 'atom',
+ 'id' => $this->user->nickname
)
),
sprintf(_('Feed for friends of %s (Atom)'), $this->user->nickname))
diff --git a/actions/newmessage.php b/actions/newmessage.php
index a0b17fc18..37fca1ca2 100644
--- a/actions/newmessage.php
+++ b/actions/newmessage.php
@@ -99,7 +99,9 @@ class NewmessageAction extends Action
$user = common_current_user();
if (!$user) {
- $this->clientError(_('Only logged-in users can send direct messages.'), 403);
+ /* Go log in, and then come back. */
+ common_set_returnto($_SERVER['REQUEST_URI']);
+ common_redirect(common_local_url('login'));
return false;
}
@@ -221,7 +223,22 @@ class NewmessageAction extends Action
}
$this->msg = $msg;
- $this->showPage();
+ if ($this->trimmed('ajax')) {
+ $this->startHTML('text/xml;charset=UTF-8');
+ $this->elementStart('head');
+ $this->element('title', null, _('New message'));
+ $this->elementEnd('head');
+ $this->elementStart('body');
+ if (common_logged_in()) {
+ $this->showNoticeForm();
+ }
+ $this->elementEnd('div');
+ $this->elementEnd('body');
+ $this->endHTML();
+ }
+ else {
+ $this->showPage();
+ }
}
function showPageNotice()
diff --git a/actions/public.php b/actions/public.php
index 73fad182a..982dfde15 100644
--- a/actions/public.php
+++ b/actions/public.php
@@ -131,6 +131,13 @@ class PublicAction extends Action
return _('Public timeline');
}
}
+
+ function extraHead()
+ {
+ parent::extraHead();
+ $this->element('meta', array('http-equiv' => 'X-XRDS-Location',
+ 'content' => common_local_url('publicxrds')));
+ }
/**
* Output <head> elements for RSS and Atom feeds
@@ -143,14 +150,12 @@ class PublicAction extends Action
return array(new Feed(Feed::RSS1, common_local_url('publicrss'),
_('Public Stream Feed (RSS 1.0)')),
new Feed(Feed::RSS2,
- common_local_url('api',
- array('apiaction' => 'statuses',
- 'method' => 'public_timeline.rss')),
+ common_local_url('ApiTimelinePublic',
+ array('format' => 'rss')),
_('Public Stream Feed (RSS 2.0)')),
new Feed(Feed::ATOM,
- common_local_url('api',
- array('apiaction' => 'statuses',
- 'method' => 'public_timeline.atom')),
+ common_local_url('ApiTimelinePublic',
+ array('format' => 'atom')),
_('Public Stream Feed (Atom)')));
}
diff --git a/actions/publicxrds.php b/actions/publicxrds.php
new file mode 100644
index 000000000..5fd4eead7
--- /dev/null
+++ b/actions/publicxrds.php
@@ -0,0 +1,81 @@
+<?php
+
+/**
+ * Public XRDS for OpenID
+ *
+ * PHP version 5
+ *
+ * @category Action
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @author Robin Millette <millette@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
+ * @link http://status.net/
+ *
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+if (!defined('STATUSNET') && !defined('LACONICA')) {
+ exit(1);
+}
+
+require_once INSTALLDIR.'/plugins/OpenID/openid.php';
+require_once INSTALLDIR.'/lib/xrdsoutputter.php';
+
+/**
+ * Public XRDS
+ *
+ * @category Action
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @author Robin Millette <millette@status.net>
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
+ * @link http://status.net/
+ *
+ * @todo factor out similarities with XrdsAction
+ */
+class PublicxrdsAction extends Action
+{
+ /**
+ * Is read only?
+ *
+ * @return boolean true
+ */
+ function isReadOnly($args)
+ {
+ return true;
+ }
+
+ /**
+ * Class handler.
+ *
+ * @param array $args array of arguments
+ *
+ * @return nothing
+ */
+ function handle($args)
+ {
+ parent::handle($args);
+ $xrdsOutputter = new XRDSOutputter();
+ $xrdsOutputter->startXRDS();
+ Event::handle('StartPublicXRDS', array($this,&$xrdsOutputter));
+ Event::handle('EndPublicXRDS', array($this,&$xrdsOutputter));
+ $xrdsOutputter->endXRDS();
+ }
+}
+
diff --git a/actions/replies.php b/actions/replies.php
index 6003ad30b..a13b5a227 100644
--- a/actions/replies.php
+++ b/actions/replies.php
@@ -138,11 +138,25 @@ class RepliesAction extends OwnerDesignAction
function getFeeds()
{
- $rssurl = common_local_url('repliesrss',
- array('nickname' => $this->user->nickname));
- $rsstitle = sprintf(_('Feed for replies to %s'), $this->user->nickname);
-
- return array(new Feed(Feed::RSS1, $rssurl, $rsstitle));
+ return array(new Feed(Feed::RSS1,
+ common_local_url('repliesrss',
+ array('nickname' => $this->user->nickname)),
+ sprintf(_('Replies feed for %s (RSS 1.0)'),
+ $this->user->nickname)),
+ new Feed(Feed::RSS2,
+ common_local_url('ApiTimelineMentions',
+ array(
+ 'id' => $this->user->nickname,
+ 'format' => 'rss')),
+ sprintf(_('Replies feed for %s (RSS 2.0)'),
+ $this->user->nickname)),
+ new Feed(Feed::ATOM,
+ common_local_url('ApiTimelineMentions',
+ array(
+ 'id' => $this->user->nickname,
+ 'format' => 'atom')),
+ sprintf(_('Replies feed for %s (Atom)'),
+ $this->user->nickname)));
}
/**
diff --git a/actions/showfavorites.php b/actions/showfavorites.php
index b96d2af37..b12fcdd9a 100644
--- a/actions/showfavorites.php
+++ b/actions/showfavorites.php
@@ -164,13 +164,25 @@ class ShowfavoritesAction extends OwnerDesignAction
function getFeeds()
{
- $feedurl = common_local_url('favoritesrss',
- array('nickname' =>
- $this->user->nickname));
- $feedtitle = sprintf(_('Feed for favorites of %s'),
- $this->user->nickname);
-
- return array(new Feed(Feed::RSS1, $feedurl, $feedtitle));
+ return array(new Feed(Feed::RSS1,
+ common_local_url('favoritesrss',
+ array('nickname' => $this->user->nickname)),
+ sprintf(_('Feed for favorites of %s (RSS 1.0)'),
+ $this->user->nickname)),
+ new Feed(Feed::RSS2,
+ common_local_url('ApiTimelineFavorites',
+ array(
+ 'id' => $this->user->nickname,
+ 'format' => 'rss')),
+ sprintf(_('Feed for favorites of %s (RSS 2.0)'),
+ $this->user->nickname)),
+ new Feed(Feed::ATOM,
+ common_local_url('ApiTimelineFavorites',
+ array(
+ 'id' => $this->user->nickname,
+ 'format' => 'atom')),
+ sprintf(_('Feed for favorites of %s (Atom)'),
+ $this->user->nickname)));
}
/**
diff --git a/actions/showgroup.php b/actions/showgroup.php
index bfe45ddad..a4af29391 100644
--- a/actions/showgroup.php
+++ b/actions/showgroup.php
@@ -328,17 +328,15 @@ class ShowgroupAction extends GroupDesignAction
sprintf(_('Notice feed for %s group (RSS 1.0)'),
$this->group->nickname)),
new Feed(Feed::RSS2,
- common_local_url('api',
- array('apiaction' => 'groups',
- 'method' => 'timeline',
- 'argument' => $this->group->nickname.'.rss')),
+ common_local_url('ApiTimelineGroup',
+ array('format' => 'rss',
+ 'id' => $this->group->nickname)),
sprintf(_('Notice feed for %s group (RSS 2.0)'),
$this->group->nickname)),
new Feed(Feed::ATOM,
- common_local_url('api',
- array('apiaction' => 'groups',
- 'method' => 'timeline',
- 'argument' => $this->group->nickname.'.atom')),
+ common_local_url('ApiTimelineGroup',
+ array('format' => 'atom',
+ 'id' => $this->group->nickname)),
sprintf(_('Notice feed for %s group (Atom)'),
$this->group->nickname)),
new Feed(Feed::FOAF,
diff --git a/actions/shownotice.php b/actions/shownotice.php
index 41408c23c..5d16fdad9 100644
--- a/actions/shownotice.php
+++ b/actions/shownotice.php
@@ -172,9 +172,9 @@ class ShownoticeAction extends OwnerDesignAction
function title()
{
if (!empty($this->profile->fullname)) {
- $base = $this->profile->fullname . ' (' . $this->user->nickname . ') ';
+ $base = $this->profile->fullname . ' (' . $this->profile->nickname . ') ';
} else {
- $base = $this->user->nickname;
+ $base = $this->profile->nickname;
}
return sprintf(_('%1$s\'s status on %2$s'),
diff --git a/actions/showstream.php b/actions/showstream.php
index de7100b1d..4f4806037 100644
--- a/actions/showstream.php
+++ b/actions/showstream.php
@@ -128,17 +128,17 @@ class ShowstreamAction extends ProfileAction
sprintf(_('Notice feed for %s (RSS 1.0)'),
$this->user->nickname)),
new Feed(Feed::RSS2,
- common_local_url('api',
- array('apiaction' => 'statuses',
- 'method' => 'user_timeline',
- 'argument' => $this->user->nickname.'.rss')),
+ common_local_url('ApiTimelineUser',
+ array(
+ 'id' => $this->user->nickname,
+ 'format' => 'rss')),
sprintf(_('Notice feed for %s (RSS 2.0)'),
$this->user->nickname)),
new Feed(Feed::ATOM,
- common_local_url('api',
- array('apiaction' => 'statuses',
- 'method' => 'user_timeline',
- 'argument' => $this->user->nickname.'.atom')),
+ common_local_url('ApiTimelineUser',
+ array(
+ 'id' => $this->user->nickname,
+ 'format' => 'atom')),
sprintf(_('Notice feed for %s (Atom)'),
$this->user->nickname)),
new Feed(Feed::FOAF,
diff --git a/actions/tag.php b/actions/tag.php
index f0ab30308..3a88c1229 100644
--- a/actions/tag.php
+++ b/actions/tag.php
@@ -86,17 +86,15 @@ class TagAction extends Action
sprintf(_('Notice feed for tag %s (RSS 1.0)'),
$this->tag)),
new Feed(Feed::RSS2,
- common_local_url('api',
- array('apiaction' => 'tags',
- 'method' => 'timeline',
- 'argument' => $this->tag.'.rss')),
- sprintf(_('Notice feed for %s group (RSS 2.0)'),
+ common_local_url('ApiTimelineTag',
+ array('format' => 'rss',
+ 'tag' => $this->tag)),
+ sprintf(_('Notice feed for tag %s (RSS 2.0)'),
$this->tag)),
new Feed(Feed::ATOM,
- common_local_url('api',
- array('apiaction' => 'tags',
- 'method' => 'timeline',
- 'argument' => $this->tag.'.atom')),
+ common_local_url('ApiTimelineTag',
+ array('format' => 'atom',
+ 'tag' => $this->tag)),
sprintf(_('Notice feed for tag %s (Atom)'),
$this->tag)));
}
diff --git a/actions/xrds.php b/actions/xrds.php
index 8ba89fec0..8f09557d1 100644
--- a/actions/xrds.php
+++ b/actions/xrds.php
@@ -36,6 +36,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
require_once INSTALLDIR.'/lib/omb.php';
require_once INSTALLDIR.'/extlib/libomb/service_provider.php';
require_once INSTALLDIR.'/extlib/libomb/xrds_mapper.php';
+require_once INSTALLDIR.'/lib/xrdsoutputter.php';
/**
* XRDS for OpenMicroBlogging
@@ -49,6 +50,8 @@ require_once INSTALLDIR.'/extlib/libomb/xrds_mapper.php';
*/
class XrdsAction extends Action
{
+ var $user;
+
/**
* Is read only?
*
@@ -58,60 +61,87 @@ class XrdsAction extends Action
{
return true;
}
-
- /**
- * Class handler.
- *
- * @param array $args query arguments
- *
- * @return void
- */
- function handle($args)
+
+ function prepare($args)
{
- parent::handle($args);
+ parent::prepare($args);
$nickname = $this->trimmed('nickname');
- $user = User::staticGet('nickname', $nickname);
- if (!$user) {
+ $this->user = User::staticGet('nickname', $nickname);
+ if (!$this->user) {
$this->clientError(_('No such user.'));
return;
}
- $this->showXrds($user);
+ return true;
}
/**
- * Show XRDS for a user.
+ * Class handler.
*
- * @param class $user XRDS for this user.
+ * @param array $args query arguments
*
* @return void
*/
- function showXrds($user)
+ function handle($args)
{
- $srv = new OMB_Service_Provider(profile_to_omb_profile($user->uri,
- $user->getProfile()));
- /* Use libomb’s default XRDS Writer. */
- $xrds_writer = null;
- $srv->writeXRDS(new Laconica_XRDS_Mapper(), $xrds_writer);
- }
-}
+ parent::handle($args);
+ $xrdsOutputter = new XRDSOutputter();
+ $xrdsOutputter->startXRDS();
-class Laconica_XRDS_Mapper implements OMB_XRDS_Mapper
-{
- protected $urls;
+ Event::handle('StartUserXRDS', array($this,&$xrdsOutputter));
- public function __construct()
- {
- $this->urls = array(
- OAUTH_ENDPOINT_REQUEST => 'requesttoken',
- OAUTH_ENDPOINT_AUTHORIZE => 'userauthorization',
- OAUTH_ENDPOINT_ACCESS => 'accesstoken',
- OMB_ENDPOINT_POSTNOTICE => 'postnotice',
- OMB_ENDPOINT_UPDATEPROFILE => 'updateprofile');
- }
+ //oauth
+ $xrdsOutputter->elementStart('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
+ 'xml:id' => 'oauth',
+ 'xmlns:simple' => 'http://xrds-simple.net/core/1.0',
+ 'version' => '2.0'));
+ $xrdsOutputter->element('Type', null, 'xri://$xrds*simple');
+ $xrdsOutputter->showXrdsService(OAUTH_ENDPOINT_REQUEST,
+ common_local_url('requesttoken'),
+ array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY, OAUTH_HMAC_SHA1));
+ $xrdsOutputter->showXrdsService( OAUTH_ENDPOINT_AUTHORIZE,
+ common_local_url('userauthorization'),
+ array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY, OAUTH_HMAC_SHA1),
+ null,
+ $this->user->getIdentifierURI());
+ $xrdsOutputter->showXrdsService(OAUTH_ENDPOINT_ACCESS,
+ common_local_url('accesstoken'),
+ array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY, OAUTH_HMAC_SHA1),
+ null,
+ $this->user->getIdentifierURI());
+ $xrdsOutputter->showXrdsService(OAUTH_ENDPOINT_RESOURCE,
+ null,
+ array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY, OAUTH_HMAC_SHA1),
+ null,
+ $this->user->getIdentifierURI());
+ $xrdsOutputter->elementEnd('XRD');
+
+ //omb
+ $xrdsOutputter->elementStart('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
+ 'xml:id' => 'oauth',
+ 'xmlns:simple' => 'http://xrds-simple.net/core/1.0',
+ 'version' => '2.0'));
+ $xrdsOutputter->element('Type', null, 'xri://$xrds*simple');
+ $xrdsOutputter->showXrdsService(OMB_ENDPOINT_POSTNOTICE,
+ common_local_url('postnotice'));
+ $xrdsOutputter->showXrdsService(OMB_ENDPOINT_UPDATEPROFILE,
+ common_local_url('updateprofile'));
+ $xrdsOutputter->elementEnd('XRD');
+
+ //misc
+ $xrdsOutputter->elementStart('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
+ 'xml:id' => 'oauth',
+ 'xmlns:simple' => 'http://xrds-simple.net/core/1.0',
+ 'version' => '2.0'));
+ $xrdsOutputter->showXrdsService(OAUTH_DISCOVERY,
+ '#oauth');
+ $xrdsOutputter->showXrdsService(OMB_VERSION,
+ '#omb');
+ $xrdsOutputter->elementEnd('XRD');
- public function getURL($action)
- {
- return common_local_url($this->urls[$action]);
+ Event::handle('EndUserXRDS', array($this,&$xrdsOutputter));
+
+ $xrdsOutputter->endXRDS();
+
}
}
?>