summaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
authorZach Copley <zach@controlyourself.ca>2009-03-10 16:15:57 -0700
committerZach Copley <zach@controlyourself.ca>2009-03-10 16:15:57 -0700
commit91980c73a76bcbedd5f23a3232988a32aa8c7127 (patch)
tree94a49d0111d3484db7321032f879ac580b1d5065 /actions
parent945bbf00dc9ee106359e9387956c72c1290d12fc (diff)
Updates to the API to improve Atom feeds
Diffstat (limited to 'actions')
-rw-r--r--actions/twitapidirect_messages.php22
-rw-r--r--actions/twitapifavorites.php14
-rw-r--r--actions/twitapistatuses.php53
3 files changed, 62 insertions, 27 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/twitapistatuses.php b/actions/twitapistatuses.php
index 63e29068b..b50a17abd 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);
@@ -347,10 +360,9 @@ class TwitapistatusesAction extends TwitterapiAction
$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);