summaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
Diffstat (limited to 'actions')
-rw-r--r--actions/twitapidirect_messages.php22
-rw-r--r--actions/twitapifavorites.php14
-rw-r--r--actions/twitapisearchatom.php29
-rw-r--r--actions/twitapistatuses.php55
4 files changed, 82 insertions, 38 deletions
diff --git a/actions/twitapidirect_messages.php b/actions/twitapidirect_messages.php
index ce98bf6ec..7101db8df 100644
--- a/actions/twitapidirect_messages.php
+++ b/actions/twitapidirect_messages.php
@@ -38,7 +38,6 @@ class Twitapidirect_messagesAction extends TwitterapiAction
function show_messages($args, $apidata, $type)
{
-
$user = $apidata['user'];
$count = $this->arg('count');
@@ -102,7 +101,17 @@ class Twitapidirect_messagesAction extends TwitterapiAction
$this->show_rss_dmsgs($message, $title, $link, $subtitle);
break;
case 'atom':
- $this->show_atom_dmsgs($message, $title, $link, $subtitle);
+ $selfuri = common_root_url() . 'api/direct_messages';
+ $selfuri .= ($type == 'received') ? '.atom' : '/sent.atom';
+ $taguribase = common_config('integration', 'taguri');
+
+ if ($type == 'sent') {
+ $id = "tag:$taguribase:SentDirectMessages:" . $user->id;
+ } else {
+ $id = "tag:$taguribase:DirectMessages:" . $user->id;
+ }
+
+ $this->show_atom_dmsgs($message, $title, $link, $subtitle, $selfuri, $id);
break;
case 'json':
$this->show_json_dmsgs($message);
@@ -261,16 +270,17 @@ class Twitapidirect_messagesAction extends TwitterapiAction
}
- function show_atom_dmsgs($message, $title, $link, $subtitle)
+ function show_atom_dmsgs($message, $title, $link, $subtitle, $selfuri, $id)
{
$this->init_document('atom');
$this->element('title', null, $title);
- $siteserver = common_config('site', 'server');
- $this->element('id', null, "tag:$siteserver,2008:DirectMessage");
+ $this->element('id', null, $id);
$this->element('link', array('href' => $link, 'rel' => 'alternate', 'type' => 'text/html'), null);
- $this->element('updated', null, common_date_iso8601(strftime('%c')));
+ $this->element('link', array('href' => $selfuri, 'rel' => 'self',
+ 'type' => 'application/atom+xml'), null);
+ $this->element('updated', null, common_date_iso8601('now'));
$this->element('subtitle', null, $subtitle);
if (is_array($message)) {
diff --git a/actions/twitapifavorites.php b/actions/twitapifavorites.php
index 737b7229f..31dce341b 100644
--- a/actions/twitapifavorites.php
+++ b/actions/twitapifavorites.php
@@ -61,10 +61,9 @@ class TwitapifavoritesAction extends TwitterapiAction
}
$sitename = common_config('site', 'name');
- $siteserver = common_config('site', 'server');
-
$title = sprintf(_('%s / Favorites from %s'), $sitename, $user->nickname);
- $id = "tag:$siteserver:favorites:".$user->id;
+ $taguribase = common_config('integration', 'taguri');
+ $id = "tag:$taguribase:Favorites:".$user->id;
$link = common_local_url('favorites', array('nickname' => $user->nickname));
$subtitle = sprintf(_('%s updates favorited by %s / %s.'), $sitename, $profile->getBestName(), $user->nickname);
@@ -76,7 +75,14 @@ class TwitapifavoritesAction extends TwitterapiAction
$this->show_rss_timeline($notice, $title, $link, $subtitle);
break;
case 'atom':
- $this->show_atom_timeline($notice, $title, $id, $link, $subtitle);
+ if (isset($apidata['api_arg'])) {
+ $selfuri = $selfuri = common_root_url() .
+ 'api/favorites/' . $apidata['api_arg'] . '.atom';
+ } else {
+ $selfuri = $selfuri = common_root_url() .
+ 'api/favorites.atom';
+ }
+ $this->show_atom_timeline($notice, $title, $id, $link, $subtitle, null, $selfuri);
break;
case 'json':
$this->show_json_timeline($notice);
diff --git a/actions/twitapisearchatom.php b/actions/twitapisearchatom.php
index 3ab82bfb6..eb9ab5d8e 100644
--- a/actions/twitapisearchatom.php
+++ b/actions/twitapisearchatom.php
@@ -52,7 +52,6 @@ require_once INSTALLDIR.'/lib/twitterapi.php';
class TwitapisearchatomAction extends TwitterapiAction
{
- var $notices;
var $cnt;
var $query;
var $lang;
@@ -156,6 +155,7 @@ class TwitapisearchatomAction extends TwitterapiAction
{
// TODO: Support search operators like from: and to:, boolean, etc.
+ $notices = array();
$notice = new Notice();
// lcase it for comparison
@@ -218,7 +218,6 @@ class TwitapisearchatomAction extends TwitterapiAction
{
// TODO: A9 OpenSearch stuff like search.twitter.com?
- $lang = common_config('site', 'language');
$server = common_config('site', 'server');
$sitename = common_config('site', 'name');
@@ -226,11 +225,15 @@ class TwitapisearchatomAction extends TwitterapiAction
$this->elementStart('feed',
array('xmlns' => 'http://www.w3.org/2005/Atom',
+
+ // XXX: xmlns:twitter causes Atom validation to fail
+ // It's used for the source attr on notices
+
'xmlns:twitter' => 'http://api.twitter.com/',
- 'xml:lang' => $lang));
+ 'xml:lang' => 'en-US')); // XXX Other locales ?
- $year = date('Y');
- $this->element('id', null, "tag:$server,$year:search/$server");
+ $taguribase = common_config('integration', 'taguri');
+ $this->element('id', null, "tag:$taguribase:search/$server");
$site_uri = common_path(false);
@@ -251,13 +254,18 @@ class TwitapisearchatomAction extends TwitterapiAction
// self link
- $self_uri = $search_uri . '&page=' . $this->page;
+ $self_uri = $search_uri;
+ $self_uri .= ($this->page > 1) ? '&page=' . $this->page : '';
$this->element('link', array('type' => 'application/atom+xml',
'rel' => 'self',
'href' => $self_uri));
$this->element('title', null, "$this->query - $sitename Search");
+ $this->element('updated', null, common_date_iso8601('now'));
+
+ // XXX: The below "rel" links are not valid Atom, but it's what
+ // Twitter does...
// refresh link
@@ -308,18 +316,19 @@ class TwitapisearchatomAction extends TwitterapiAction
$this->elementStart('entry');
- $year = date('Y', strtotime($notice->created));
+ $taguribase = common_config('integration', 'taguri');
- $this->element('id', null, "tag:$server,$year:$notice->id");
+ $this->element('id', null, "tag:$taguribase:$notice->id");
$this->element('published', null, common_date_w3dtf($notice->created));
$this->element('link', array('type' => 'text/html',
'rel' => 'alternate',
'href' => $nurl));
$this->element('title', null, common_xml_safe_str(trim($notice->content)));
- $this->element('content', array('type' => 'text/html'), $notice->rendered);
+ $this->element('content', array('type' => 'html'), $notice->rendered);
$this->element('updated', null, common_date_w3dtf($notice->created));
$this->element('link', array('type' => 'image/png',
- 'rel' => 'image',
+ // XXX: Twitter uses rel="image" (not valid)
+ 'rel' => 'related',
'href' => $profile->avatarUrl()));
// TODO: Here is where we'd put in a link to an atom feed for threads
diff --git a/actions/twitapistatuses.php b/actions/twitapistatuses.php
index 63e29068b..323c4f1f8 100644
--- a/actions/twitapistatuses.php
+++ b/actions/twitapistatuses.php
@@ -29,10 +29,12 @@ class TwitapistatusesAction extends TwitterapiAction
parent::handle($args);
$sitename = common_config('site', 'name');
- $siteserver = common_config('site', 'server');
$title = sprintf(_("%s public timeline"), $sitename);
- $id = "tag:$siteserver:Statuses";
+
+ $taguribase = common_config('integration', 'taguri');
+ $id = "tag:$taguribase:PublicTimeline";
$link = common_root_url();
+
$subtitle = sprintf(_("%s updates from everyone!"), $sitename);
// Number of public statuses to return by default -- Twitter sends 20
@@ -70,7 +72,8 @@ class TwitapistatusesAction extends TwitterapiAction
$this->show_rss_timeline($notice, $title, $link, $subtitle);
break;
case 'atom':
- $this->show_atom_timeline($notice, $title, $id, $link, $subtitle);
+ $selfuri = common_root_url() . 'api/statuses/public_timeline.atom';
+ $this->show_atom_timeline($notice, $title, $id, $link, $subtitle, null, $selfuri);
break;
case 'json':
$this->show_json_timeline($notice);
@@ -114,7 +117,6 @@ class TwitapistatusesAction extends TwitterapiAction
}
$since = strtotime($this->arg('since'));
-
$user = $this->get_user($apidata['api_arg'], $apidata);
$this->auth_user = $user;
@@ -124,12 +126,10 @@ class TwitapistatusesAction extends TwitterapiAction
}
$profile = $user->getProfile();
-
$sitename = common_config('site', 'name');
- $siteserver = common_config('site', 'server');
-
$title = sprintf(_("%s and friends"), $user->nickname);
- $id = "tag:$siteserver:friends:" . $user->id;
+ $taguribase = common_config('integration', 'taguri');
+ $id = "tag:$taguribase:FriendsTimeline:" . $user->id;
$link = common_local_url('all', array('nickname' => $user->nickname));
$subtitle = sprintf(_('Updates from %1$s and friends on %2$s!'), $user->nickname, $sitename);
@@ -143,7 +143,14 @@ class TwitapistatusesAction extends TwitterapiAction
$this->show_rss_timeline($notice, $title, $link, $subtitle);
break;
case 'atom':
- $this->show_atom_timeline($notice, $title, $id, $link, $subtitle);
+ if (isset($apidata['api_arg'])) {
+ $selfuri = $selfuri = common_root_url() .
+ 'api/statuses/friends_timeline/' . $apidata['api_arg'] . '.atom';
+ } else {
+ $selfuri = $selfuri = common_root_url() .
+ 'api/statuses/friends_timeline.atom';
+ }
+ $this->show_atom_timeline($notice, $title, $id, $link, $subtitle, null, $selfuri);
break;
case 'json':
$this->show_json_timeline($notice);
@@ -199,10 +206,9 @@ class TwitapistatusesAction extends TwitterapiAction
$since = strtotime($this->arg('since'));
$sitename = common_config('site', 'name');
- $siteserver = common_config('site', 'server');
-
$title = sprintf(_("%s timeline"), $user->nickname);
- $id = "tag:$siteserver:user:".$user->id;
+ $taguribase = common_config('integration', 'taguri');
+ $id = "tag:$taguribase:UserTimeline:".$user->id;
$link = common_local_url('showstream', array('nickname' => $user->nickname));
$subtitle = sprintf(_('Updates from %1$s on %2$s!'), $user->nickname, $sitename);
@@ -224,7 +230,14 @@ class TwitapistatusesAction extends TwitterapiAction
$this->show_rss_timeline($notice, $title, $link, $subtitle, $suplink);
break;
case 'atom':
- $this->show_atom_timeline($notice, $title, $id, $link, $subtitle, $suplink);
+ if (isset($apidata['api_arg'])) {
+ $selfuri = $selfuri = common_root_url() .
+ 'api/statuses/user_timeline/' . $apidata['api_arg'] . '.atom';
+ } else {
+ $selfuri = $selfuri = common_root_url() .
+ 'api/statuses/user_timeline.atom';
+ }
+ $this->show_atom_timeline($notice, $title, $id, $link, $subtitle, $suplink, $selfuri);
break;
case 'json':
$this->show_json_timeline($notice);
@@ -342,15 +355,14 @@ class TwitapistatusesAction extends TwitterapiAction
$since_id = $this->arg('since_id');
$before_id = $this->arg('before_id');
+ $user = $this->get_user($apidata['api_arg'], $apidata);
$this->auth_user = $apidata['user'];
- $user = $this->auth_user;
$profile = $user->getProfile();
$sitename = common_config('site', 'name');
- $siteserver = common_config('site', 'server');
-
$title = sprintf(_('%1$s / Updates replying to %2$s'), $sitename, $user->nickname);
- $id = "tag:$siteserver:replies:".$user->id;
+ $taguribase = common_config('integration', 'taguri');
+ $id = "tag:$taguribase:Replies:".$user->id;
$link = common_local_url('replies', array('nickname' => $user->nickname));
$subtitle = sprintf(_('%1$s updates that reply to updates from %2$s / %3$s.'), $sitename, $user->nickname, $profile->getBestName());
@@ -388,7 +400,14 @@ class TwitapistatusesAction extends TwitterapiAction
$this->show_rss_timeline($notices, $title, $link, $subtitle);
break;
case 'atom':
- $this->show_atom_timeline($notices, $title, $id, $link, $subtitle);
+ if (isset($apidata['api_arg'])) {
+ $selfuri = $selfuri = common_root_url() .
+ 'api/statuses/replies/' . $apidata['api_arg'] . '.atom';
+ } else {
+ $selfuri = $selfuri = common_root_url() .
+ 'api/statuses/replies.atom';
+ }
+ $this->show_atom_timeline($notices, $title, $id, $link, $subtitle, null, $selfuri);
break;
case 'json':
$this->show_json_timeline($notices);