From 023f258b63c2c47b1af74811c39ab274b170e6b0 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Thu, 11 Mar 2010 23:05:56 +0000 Subject: - Output georss xmlns in rss element - Only output geopoint in rss if one is set --- lib/apiaction.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/apiaction.php b/lib/apiaction.php index e4a1df3d1..fd09f3d42 100644 --- a/lib/apiaction.php +++ b/lib/apiaction.php @@ -541,13 +541,12 @@ class ApiAction extends Action function showGeoRSS($geo) { - if (empty($geo)) { - // empty geo element - $this->element('geo'); - } else { - $this->elementStart('geo', array('xmlns:georss' => 'http://www.georss.org/georss')); - $this->element('georss:point', null, $geo['coordinates'][0] . ' ' . $geo['coordinates'][1]); - $this->elementEnd('geo'); + if (!empty($geo)) { + $this->element( + 'georss:point', + null, + $geo['coordinates'][0] . ' ' . $geo['coordinates'][1] + ); } } @@ -1138,7 +1137,14 @@ class ApiAction extends Action function initTwitterRss() { $this->startXML(); - $this->elementStart('rss', array('version' => '2.0', 'xmlns:atom'=>'http://www.w3.org/2005/Atom')); + $this->elementStart( + 'rss', + array( + 'version' => '2.0', + 'xmlns:atom' => 'http://www.w3.org/2005/Atom', + 'xmlns:georss' => 'http://www.georss.org/georss' + ) + ); $this->elementStart('channel'); Event::handle('StartApiRss', array($this)); } -- cgit v1.2.3-54-g00ecf From 7e1a1506f5afd26da8dbe654f5f67f5c11d9d6e9 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Thu, 11 Mar 2010 23:28:41 +0000 Subject: Output self link in rss2 feeds, if available --- lib/apiaction.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/apiaction.php b/lib/apiaction.php index fd09f3d42..73777f4e8 100644 --- a/lib/apiaction.php +++ b/lib/apiaction.php @@ -618,13 +618,25 @@ class ApiAction extends Action $this->endDocument('xml'); } - function showRssTimeline($notice, $title, $link, $subtitle, $suplink=null, $logo=null) + function showRssTimeline($notice, $title, $link, $subtitle, $suplink = null, $logo = null, $self = null) { $this->initDocument('rss'); $this->element('title', null, $title); $this->element('link', null, $link); + + if (!is_null($self)) { + $this->element( + 'atom:link', + array( + 'type' => 'application/rss+xml', + 'href' => $self, + 'rel' => 'self' + ) + ); + } + if (!is_null($suplink)) { // For FriendFeed's SUP protocol $this->element('link', array('xmlns' => 'http://www.w3.org/2005/Atom', -- cgit v1.2.3-54-g00ecf From 212b20e876fac3b989cd79b1b896b88f50995a37 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Thu, 11 Mar 2010 23:43:03 +0000 Subject: Add self link to user and group rss2 feeds --- actions/apitimelinegroup.php | 23 ++++++++++------------- actions/apitimelineuser.php | 31 +++++++++++++++++-------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/actions/apitimelinegroup.php b/actions/apitimelinegroup.php index 8f971392b..c4f8cbc65 100644 --- a/actions/apitimelinegroup.php +++ b/actions/apitimelinegroup.php @@ -107,6 +107,14 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction // We'll pull common formatting out of this for other formats $atom = new AtomGroupNoticeFeed($this->group); + // Calculate self link + $id = $this->arg('id'); + $aargs = array('format' => $this->format); + if (!empty($id)) { + $aargs['id'] = $id; + } + $self = $this->getSelfUri('ApiTimelineGroup', $aargs); + switch($this->format) { case 'xml': $this->showXmlTimeline($this->notices); @@ -118,7 +126,8 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction $this->group->homeUrl(), $atom->subtitle, null, - $atom->logo + $atom->logo, + $self ); break; case 'atom': @@ -126,24 +135,12 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction header('Content-Type: application/atom+xml; charset=utf-8'); try { - $atom->addAuthorRaw($this->group->asAtomAuthor()); $atom->setActivitySubject($this->group->asActivitySubject()); - - $id = $this->arg('id'); - $aargs = array('format' => 'atom'); - if (!empty($id)) { - $aargs['id'] = $id; - } - $self = $this->getSelfUri('ApiTimelineGroup', $aargs); - $atom->setId($self); $atom->setSelfLink($self); - $atom->addEntryFromNotices($this->notices); - $this->raw($atom->getString()); - } catch (Atom10FeedException $e) { $this->serverError( 'Could not generate feed for group - ' . $e->getMessage() diff --git a/actions/apitimelineuser.php b/actions/apitimelineuser.php index 2d0047c04..5c4bcace4 100644 --- a/actions/apitimelineuser.php +++ b/actions/apitimelineuser.php @@ -116,13 +116,19 @@ class ApiTimelineUserAction extends ApiBareAuthAction // We'll use the shared params from the Atom stub // for other feed types. $atom = new AtomUserNoticeFeed($this->user); - $title = $atom->title; - $link = common_local_url( + + $link = common_local_url( 'showstream', array('nickname' => $this->user->nickname) ); - $subtitle = $atom->subtitle; - $logo = $atom->logo; + + // Calculate self link + $id = $this->arg('id'); + $aargs = array('format' => $this->format); + if (!empty($id)) { + $aargs['id'] = $id; + } + $self = $this->getSelfUri('ApiTimelineUser', $aargs); // FriendFeed's SUP protocol // Also added RSS and Atom feeds @@ -136,25 +142,22 @@ class ApiTimelineUserAction extends ApiBareAuthAction break; case 'rss': $this->showRssTimeline( - $this->notices, $title, $link, - $subtitle, $suplink, $logo + $this->notices, + $atom->title, + $link, + $atom->subtitle, + $suplink, + $atom->logo, + $self ); break; case 'atom': header('Content-Type: application/atom+xml; charset=utf-8'); - $id = $this->arg('id'); - $aargs = array('format' => 'atom'); - if (!empty($id)) { - $aargs['id'] = $id; - } - $self = $this->getSelfUri('ApiTimelineUser', $aargs); $atom->setId($self); $atom->setSelfLink($self); - $atom->addEntryFromNotices($this->notices); - $this->raw($atom->getString()); break; -- cgit v1.2.3-54-g00ecf From b12c3449309870c7c391ed0e2c7783f7a05a2334 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Thu, 11 Mar 2010 23:44:50 +0000 Subject: Generator tag should have 'uri' attr not 'url' --- lib/atom10feed.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/atom10feed.php b/lib/atom10feed.php index 2d342e785..a46d49f35 100644 --- a/lib/atom10feed.php +++ b/lib/atom10feed.php @@ -178,7 +178,7 @@ class Atom10Feed extends XMLStringer $this->element( 'generator', array( - 'url' => 'http://status.net', + 'uri' => 'http://status.net', 'version' => STATUSNET_VERSION ), 'StatusNet' -- cgit v1.2.3-54-g00ecf From 7cdcb89dc9d8dcc04848928c5b765f99566d2a4d Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 12 Mar 2010 00:36:26 +0000 Subject: Add id and updated elements to atom source --- classes/Notice.php | 2 ++ classes/User_group.php | 9 ++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/classes/Notice.php b/classes/Notice.php index 4c7e6ab4b..40a6263e5 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -1128,6 +1128,7 @@ class Notice extends Memcached_DataObject if ($source) { $xs->elementStart('source'); + $xs->element('id', null, $profile->profileurl); $xs->element('title', null, $profile->nickname . " - " . common_config('site', 'name')); $xs->element('link', array('href' => $profile->profileurl)); $user = User::staticGet('id', $profile->id); @@ -1143,6 +1144,7 @@ class Notice extends Memcached_DataObject } $xs->element('icon', null, $profile->avatarUrl(AVATAR_PROFILE_SIZE)); + $xs->element('updated', null, common_date_w3dtf($this->created)); } if ($source) { diff --git a/classes/User_group.php b/classes/User_group.php index 0460c9870..f29594502 100644 --- a/classes/User_group.php +++ b/classes/User_group.php @@ -295,7 +295,7 @@ class User_group extends Memcached_DataObject } // If not, check local groups. - + $group = Local_group::staticGet('nickname', $nickname); if (!empty($group)) { return User_group::staticGet('id', $group->group_id); @@ -371,11 +371,10 @@ class User_group extends Memcached_DataObject if ($source) { $xs->elementStart('source'); + $xs->element('id', null, $this->permalink()); $xs->element('title', null, $profile->nickname . " - " . common_config('site', 'name')); $xs->element('link', array('href' => $this->permalink())); - } - - if ($source) { + $xs->element('updated', null, $this->modified); $xs->elementEnd('source'); } @@ -455,7 +454,7 @@ class User_group extends Memcached_DataObject $group = new User_group(); $group->query('BEGIN'); - + if (empty($uri)) { // fill in later... $uri = null; -- cgit v1.2.3-54-g00ecf From 78f0d6bbd21ed84733e960201c4652e69c565450 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 12 Mar 2010 01:12:30 +0000 Subject: Scrub all atom output with common_xml_safe_str() --- classes/Notice.php | 8 ++++++-- classes/User_group.php | 8 ++++++-- lib/activity.php | 23 +++++++++++++++++------ lib/apiaction.php | 12 ++++++++---- 4 files changed, 37 insertions(+), 14 deletions(-) diff --git a/classes/Notice.php b/classes/Notice.php index 40a6263e5..a704053a0 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -1151,7 +1151,7 @@ class Notice extends Memcached_DataObject $xs->elementEnd('source'); } - $xs->element('title', null, $this->content); + $xs->element('title', null, common_xml_safe_str($this->content)); if ($author) { $xs->raw($profile->asAtomAuthor()); @@ -1227,7 +1227,11 @@ class Notice extends Memcached_DataObject } } - $xs->element('content', array('type' => 'html'), $this->rendered); + $xs->element( + 'content', + array('type' => 'html'), + common_xml_safe_str($this->rendered) + ); $tag = new Notice_tag(); $tag->notice_id = $this->id; diff --git a/classes/User_group.php b/classes/User_group.php index f29594502..63a407b4c 100644 --- a/classes/User_group.php +++ b/classes/User_group.php @@ -379,7 +379,7 @@ class User_group extends Memcached_DataObject } $xs->element('title', null, $this->nickname); - $xs->element('summary', null, $this->description); + $xs->element('summary', null, common_xml_safe_str($this->description)); $xs->element('link', array('rel' => 'alternate', 'href' => $this->permalink())); @@ -389,7 +389,11 @@ class User_group extends Memcached_DataObject $xs->element('published', null, common_date_w3dtf($this->created)); $xs->element('updated', null, common_date_w3dtf($this->modified)); - $xs->element('content', array('type' => 'html'), $this->description); + $xs->element( + 'content', + array('type' => 'html'), + common_xml_safe_str($this->description) + ); $xs->elementEnd('entry'); diff --git a/lib/activity.php b/lib/activity.php index 2cb80f9e1..125d391b0 100644 --- a/lib/activity.php +++ b/lib/activity.php @@ -78,7 +78,7 @@ class PoCoAddress if (!empty($this->formatted)) { $xs = new XMLStringer(true); $xs->elementStart('poco:address'); - $xs->element('poco:formatted', null, $this->formatted); + $xs->element('poco:formatted', null, common_xml_safe_str($this->formatted)); $xs->elementEnd('poco:address'); return $xs->getString(); } @@ -279,7 +279,7 @@ class PoCo ); if (!empty($this->note)) { - $xs->element('poco:note', null, $this->note); + $xs->element('poco:note', null, common_xml_safe_str($this->note)); } if (!empty($this->address)) { @@ -805,7 +805,6 @@ class ActivityObject return $object; } - function asString($tag='activity:object') { $xs = new XMLStringer(true); @@ -817,16 +816,28 @@ class ActivityObject $xs->element(self::ID, null, $this->id); if (!empty($this->title)) { - $xs->element(self::TITLE, null, $this->title); + $xs->element( + self::TITLE, + null, + common_xml_safe_str($this->title) + ); } if (!empty($this->summary)) { - $xs->element(self::SUMMARY, null, $this->summary); + $xs->element( + self::SUMMARY, + null, + common_xml_safe_str($this->summary) + ); } if (!empty($this->content)) { // XXX: assuming HTML content here - $xs->element(ActivityUtils::CONTENT, array('type' => 'html'), $this->content); + $xs->element( + ActivityUtils::CONTENT, + array('type' => 'html'), + common_xml_safe_str($this->content) + ); } if (!empty($this->link)) { diff --git a/lib/apiaction.php b/lib/apiaction.php index 73777f4e8..cef5d1c1e 100644 --- a/lib/apiaction.php +++ b/lib/apiaction.php @@ -743,8 +743,12 @@ class ApiAction extends Action function showTwitterAtomEntry($entry) { $this->elementStart('entry'); - $this->element('title', null, $entry['title']); - $this->element('content', array('type' => 'html'), $entry['content']); + $this->element('title', null, common_xml_safe_str($entry['title'])); + $this->element( + 'content', + array('type' => 'html'), + common_xml_safe_str($entry['content']) + ); $this->element('id', null, $entry['id']); $this->element('published', null, $entry['published']); $this->element('updated', null, $entry['updated']); @@ -859,7 +863,7 @@ class ApiAction extends Action $this->initDocument('atom'); - $this->element('title', null, $title); + $this->element('title', null, common_xml_safe_str($title)); $this->element('id', null, $id); $this->element('link', array('href' => $link, 'rel' => 'alternate', 'type' => 'text/html'), null); @@ -869,7 +873,7 @@ class ApiAction extends Action } $this->element('updated', null, common_date_iso8601('now')); - $this->element('subtitle', null, $subtitle); + $this->element('subtitle', null, common_xml_safe_str($subtitle)); if (is_array($group)) { foreach ($group as $g) { -- cgit v1.2.3-54-g00ecf From e1537d83871811cf3446a592e44f56d26e961afe Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 12 Mar 2010 01:40:52 +0000 Subject: More generalized method for calculating Atom rel="self" links --- actions/apitimelinegroup.php | 8 +------- actions/apitimelineuser.php | 8 +------- lib/apiaction.php | 16 +++++++++++++++- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/actions/apitimelinegroup.php b/actions/apitimelinegroup.php index c4f8cbc65..da816c40a 100644 --- a/actions/apitimelinegroup.php +++ b/actions/apitimelinegroup.php @@ -107,13 +107,7 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction // We'll pull common formatting out of this for other formats $atom = new AtomGroupNoticeFeed($this->group); - // Calculate self link - $id = $this->arg('id'); - $aargs = array('format' => $this->format); - if (!empty($id)) { - $aargs['id'] = $id; - } - $self = $this->getSelfUri('ApiTimelineGroup', $aargs); + $self = $this->getSelfUri(); switch($this->format) { case 'xml': diff --git a/actions/apitimelineuser.php b/actions/apitimelineuser.php index 5c4bcace4..11431a82c 100644 --- a/actions/apitimelineuser.php +++ b/actions/apitimelineuser.php @@ -122,13 +122,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction array('nickname' => $this->user->nickname) ); - // Calculate self link - $id = $this->arg('id'); - $aargs = array('format' => $this->format); - if (!empty($id)) { - $aargs['id'] = $id; - } - $self = $this->getSelfUri('ApiTimelineUser', $aargs); + $self = $this->getSelfUri(); // FriendFeed's SUP protocol // Also added RSS and Atom feeds diff --git a/lib/apiaction.php b/lib/apiaction.php index cef5d1c1e..a01809ed9 100644 --- a/lib/apiaction.php +++ b/lib/apiaction.php @@ -1358,8 +1358,22 @@ class ApiAction extends Action } } - function getSelfUri($action, $aargs) + /** + * Calculate the complete URI that called up this action. Used for + * Atom rel="self" links. Warning: this is funky. + * + * @return string URL a URL suitable for rel="self" Atom links + */ + function getSelfUri() { + $action = mb_substr(get_class($this), 0, -6); // remove 'Action' + + $id = $this->arg('id'); + $aargs = array('format' => $this->format); + if (!empty($id)) { + $aargs['id'] = $id; + } + parse_str($_SERVER['QUERY_STRING'], $params); $pstring = ''; if (!empty($params)) { -- cgit v1.2.3-54-g00ecf From d10cb89f6ad13729de8ac620560f53a3f0d968c2 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 12 Mar 2010 02:00:53 +0000 Subject: - Output correct content type header for public timeline Atom feed - Also calculate Atom link and self links properly --- actions/apitimelinepublic.php | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/actions/apitimelinepublic.php b/actions/apitimelinepublic.php index 3e4dad690..903461425 100644 --- a/actions/apitimelinepublic.php +++ b/actions/apitimelinepublic.php @@ -107,7 +107,8 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction $title = sprintf(_("%s public timeline"), $sitename); $taguribase = TagURI::base(); $id = "tag:$taguribase:PublicTimeline"; - $link = common_root_url(); + $link = common_local_url('public'); + $self = $this->getSelfUri(); $subtitle = sprintf(_("%s updates from everyone!"), $sitename); switch($this->format) { @@ -115,10 +116,20 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction $this->showXmlTimeline($this->notices); break; case 'rss': - $this->showRssTimeline($this->notices, $title, $link, $subtitle, null, $sitelogo); + $this->showRssTimeline( + $this->notices, + $title, + $link, + $subtitle, + null, + $sitelogo, + $self + ); break; case 'atom': + header('Content-Type: application/atom+xml; charset=utf-8'); + $atom = new AtomNoticeFeed(); $atom->setId($id); @@ -126,16 +137,8 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction $atom->setSubtitle($subtitle); $atom->setLogo($sitelogo); $atom->setUpdated('now'); - $atom->addLink(common_local_url('public')); - - $atom->addLink( - $this->getSelfUri( - 'ApiTimelinePublic', array('format' => 'atom') - ), - array('rel' => 'self', 'type' => 'application/atom+xml') - ); - + $atom->setSelfLink($self); $atom->addEntryFromNotices($this->notices); $this->raw($atom->getString()); -- cgit v1.2.3-54-g00ecf From 0444cc7bfb7cf3b7353385180e0ec6e19385b2eb Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 12 Mar 2010 02:18:53 +0000 Subject: Calculate Atom self link for friends timeline --- actions/apitimelinefriends.php | 39 +++++++++++++-------------------------- 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/actions/apitimelinefriends.php b/actions/apitimelinefriends.php index 9ef3ace60..ac350ab1b 100644 --- a/actions/apitimelinefriends.php +++ b/actions/apitimelinefriends.php @@ -117,9 +117,17 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction $subtitle = sprintf( _('Updates from %1$s and friends on %2$s!'), - $this->user->nickname, $sitename + $this->user->nickname, + $sitename ); + $link = common_local_url( + 'all', + array('nickname' => $this->user->nickname) + ); + + $self = $this->getSelfUri(); + $logo = (!empty($avatar)) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE); @@ -130,19 +138,14 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction break; case 'rss': - $link = common_local_url( - 'all', array( - 'nickname' => $this->user->nickname - ) - ); - $this->showRssTimeline( $this->notices, $title, $link, $subtitle, null, - $logo + $logo, + $self ); break; case 'atom': @@ -156,24 +159,8 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction $atom->setSubtitle($subtitle); $atom->setLogo($logo); $atom->setUpdated('now'); - - $atom->addLink( - common_local_url( - 'all', - array('nickname' => $this->user->nickname) - ) - ); - - $id = $this->arg('id'); - $aargs = array('format' => 'atom'); - if (!empty($id)) { - $aargs['id'] = $id; - } - - $atom->addLink( - $this->getSelfUri('ApiTimelineFriends', $aargs), - array('rel' => 'self', 'type' => 'application/atom+xml') - ); + $atom->addLink($link); + $atom->setSelfLink($self); $atom->addEntryFromNotices($this->notices); -- cgit v1.2.3-54-g00ecf From 849d0b5dcddccd935270f079fc1279d726eb2853 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 12 Mar 2010 03:15:51 +0000 Subject: Output Atom self link in home timeline --- actions/apitimelinehome.php | 39 ++++++++++++++------------------------- 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/actions/apitimelinehome.php b/actions/apitimelinehome.php index abd387786..1618c9923 100644 --- a/actions/apitimelinehome.php +++ b/actions/apitimelinehome.php @@ -72,7 +72,7 @@ class ApiTimelineHomeAction extends ApiBareAuthAction function prepare($args) { parent::prepare($args); - common_debug("api home_timeline"); + $this->user = $this->getTargetUser($this->arg('id')); if (empty($this->user)) { @@ -121,8 +121,15 @@ class ApiTimelineHomeAction extends ApiBareAuthAction $this->user->nickname, $sitename ); - $logo = (!empty($avatar)) - ? $avatar->displayUrl() + $link = common_local_url( + 'all', + array('nickname' => $this->user->nickname) + ); + + $self = $this->getSelfUri(); + + $logo = (!empty($avatar)) + ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE); switch($this->format) { @@ -130,17 +137,14 @@ class ApiTimelineHomeAction extends ApiBareAuthAction $this->showXmlTimeline($this->notices); break; case 'rss': - $link = common_local_url( - 'all', - array('nickname' => $this->user->nickname) - ); $this->showRssTimeline( $this->notices, $title, $link, $subtitle, null, - $logo + $logo, + $self ); break; case 'atom': @@ -155,23 +159,8 @@ class ApiTimelineHomeAction extends ApiBareAuthAction $atom->setLogo($logo); $atom->setUpdated('now'); - $atom->addLink( - common_local_url( - 'all', - array('nickname' => $this->user->nickname) - ) - ); - - $id = $this->arg('id'); - $aargs = array('format' => 'atom'); - if (!empty($id)) { - $aargs['id'] = $id; - } - - $atom->addLink( - $this->getSelfUri('ApiTimelineHome', $aargs), - array('rel' => 'self', 'type' => 'application/atom+xml') - ); + $atom->addLink($link); + $atom->setSelfLink($self); $atom->addEntryFromNotices($this->notices); $this->raw($atom->getString()); -- cgit v1.2.3-54-g00ecf From 4b41a8ebbfea7211ea10b867c3cb825737b2ccfe Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 12 Mar 2010 03:27:37 +0000 Subject: - Output correct content header for Atom output in mentions timeline - Add self link --- actions/apitimelinementions.php | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/actions/apitimelinementions.php b/actions/apitimelinementions.php index 31627ab7b..c3aec7c5a 100644 --- a/actions/apitimelinementions.php +++ b/actions/apitimelinementions.php @@ -123,6 +123,9 @@ class ApiTimelineMentionsAction extends ApiBareAuthAction 'replies', array('nickname' => $this->user->nickname) ); + + $self = $this->getSelfUri(); + $subtitle = sprintf( _('%1$s updates that reply to updates from %2$s / %3$s.'), $sitename, $this->user->nickname, $profile->getBestName() @@ -134,10 +137,20 @@ class ApiTimelineMentionsAction extends ApiBareAuthAction $this->showXmlTimeline($this->notices); break; case 'rss': - $this->showRssTimeline($this->notices, $title, $link, $subtitle, null, $logo); + $this->showRssTimeline( + $this->notices, + $title, + $link, + $subtitle, + null, + $logo, + $self + ); break; case 'atom': + header('Content-Type: application/atom+xml; charset=utf-8'); + $atom = new AtomNoticeFeed(); $atom->setId($id); @@ -146,23 +159,8 @@ class ApiTimelineMentionsAction extends ApiBareAuthAction $atom->setLogo($logo); $atom->setUpdated('now'); - $atom->addLink( - common_local_url( - 'replies', - array('nickname' => $this->user->nickname) - ) - ); - - $id = $this->arg('id'); - $aargs = array('format' => 'atom'); - if (!empty($id)) { - $aargs['id'] = $id; - } - - $atom->addLink( - $this->getSelfUri('ApiTimelineMentions', $aargs), - array('rel' => 'self', 'type' => 'application/atom+xml') - ); + $atom->addLink($link); + $atom->setSelfLink($self); $atom->addEntryFromNotices($this->notices); $this->raw($atom->getString()); -- cgit v1.2.3-54-g00ecf From d31004653f51eadd5b26bfb34474387a834811a3 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 12 Mar 2010 03:42:00 +0000 Subject: Add Atom self link to favorites timeline --- actions/apitimelinefavorites.php | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/actions/apitimelinefavorites.php b/actions/apitimelinefavorites.php index c89d02247..8cb2e808d 100644 --- a/actions/apitimelinefavorites.php +++ b/actions/apitimelinefavorites.php @@ -23,7 +23,8 @@ * @package StatusNet * @author Craig Andrews * @author Evan Prodromou - * @author Zach Copley * @copyright 2009 StatusNet, Inc. + * @author Zach Copley + * @copyright 2009-2010 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ @@ -123,22 +124,26 @@ class ApiTimelineFavoritesAction extends ApiBareAuthAction ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE); + $link = common_local_url( + 'showfavorites', + array('nickname' => $this->user->nickname) + ); + + $self = $this->getSelfUri(); + switch($this->format) { case 'xml': $this->showXmlTimeline($this->notices); break; case 'rss': - $link = common_local_url( - 'showfavorites', - array('nickname' => $this->user->nickname) - ); $this->showRssTimeline( $this->notices, $title, $link, $subtitle, null, - $logo + $logo, + $self ); break; case 'atom': @@ -153,23 +158,8 @@ class ApiTimelineFavoritesAction extends ApiBareAuthAction $atom->setLogo($logo); $atom->setUpdated('now'); - $atom->addLink( - common_local_url( - 'showfavorites', - array('nickname' => $this->user->nickname) - ) - ); - - $id = $this->arg('id'); - $aargs = array('format' => 'atom'); - if (!empty($id)) { - $aargs['id'] = $id; - } - - $atom->addLink( - $this->getSelfUri('ApiTimelineFavorites', $aargs), - array('rel' => 'self', 'type' => 'application/atom+xml') - ); + $atom->addLink($link); + $atom->setSelfLink($self); $atom->addEntryFromNotices($this->notices); -- cgit v1.2.3-54-g00ecf From 13556e7ba967c4184009688348082fed1480a5d4 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 12 Mar 2010 04:08:31 +0000 Subject: Add Atom self link to tag timeline --- actions/apitimelinetag.php | 38 ++++++++++++++++---------------------- lib/apiaction.php | 5 +++++ 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/actions/apitimelinetag.php b/actions/apitimelinetag.php index a29061fcc..fed1437ea 100644 --- a/actions/apitimelinetag.php +++ b/actions/apitimelinetag.php @@ -25,7 +25,7 @@ * @author Evan Prodromou * @author Jeffery To * @author Zach Copley - * @copyright 2009 StatusNet, Inc. + * @copyright 2009-2010 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ @@ -67,6 +67,8 @@ class ApiTimelineTagAction extends ApiPrivateAuthAction { parent::prepare($args); + common_debug("apitimelinetag prepare()"); + $this->tag = $this->arg('tag'); $this->notices = $this->getNotices(); @@ -108,22 +110,28 @@ class ApiTimelineTagAction extends ApiPrivateAuthAction $taguribase = TagURI::base(); $id = "tag:$taguribase:TagTimeline:".$tag; + $link = common_local_url( + 'tag', + array('tag' => $this->tag) + ); + + $self = $this->getSelfUri(); + + common_debug("self link is: $self"); + switch($this->format) { case 'xml': $this->showXmlTimeline($this->notices); break; case 'rss': - $link = common_local_url( - 'tag', - array('tag' => $this->tag) - ); $this->showRssTimeline( $this->notices, $title, $link, $subtitle, null, - $sitelogo + $sitelogo, + $self ); break; case 'atom': @@ -138,22 +146,8 @@ class ApiTimelineTagAction extends ApiPrivateAuthAction $atom->setLogo($logo); $atom->setUpdated('now'); - $atom->addLink( - common_local_url( - 'tag', - array('tag' => $this->tag) - ) - ); - - $aargs = array('format' => 'atom'); - if (!empty($this->tag)) { - $aargs['tag'] = $this->tag; - } - - $atom->addLink( - $this->getSelfUri('ApiTimelineTag', $aargs), - array('rel' => 'self', 'type' => 'application/atom+xml') - ); + $atom->addLink($link); + $atom->setSelfLink($self); $atom->addEntryFromNotices($this->notices); $this->raw($atom->getString()); diff --git a/lib/apiaction.php b/lib/apiaction.php index a01809ed9..b90607862 100644 --- a/lib/apiaction.php +++ b/lib/apiaction.php @@ -1374,6 +1374,11 @@ class ApiAction extends Action $aargs['id'] = $id; } + $tag = $this->arg('tag'); + if (!empty($tag)) { + $aargs['tag'] = $tag; + } + parse_str($_SERVER['QUERY_STRING'], $params); $pstring = ''; if (!empty($params)) { -- cgit v1.2.3-54-g00ecf From 3dc84dd02d5558b7e2e9de903eac04edcd73aec7 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 12 Mar 2010 05:39:36 +0000 Subject: Output enclosing geo elements and GeoRSS xmlns in XML timelines --- lib/apiaction.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/apiaction.php b/lib/apiaction.php index b90607862..e6aaf9316 100644 --- a/lib/apiaction.php +++ b/lib/apiaction.php @@ -491,7 +491,7 @@ class ApiAction extends Action $this->showXmlAttachments($twitter_status['attachments']); break; case 'geo': - $this->showGeoRSS($value); + $this->showGeoXML($value); break; case 'retweeted_status': $this->showTwitterXmlStatus($value, 'retweeted_status'); @@ -539,6 +539,18 @@ class ApiAction extends Action } } + function showGeoXML($geo) + { + if (empty($geo)) { + // empty geo element + $this->element('geo'); + } else { + $this->elementStart('geo', array('xmlns:georss' => 'http://www.georss.org/georss')); + $this->element('georss:point', null, $geo['coordinates'][0] . ' ' . $geo['coordinates'][1]); + $this->elementEnd('geo'); + } + } + function showGeoRSS($geo) { if (!empty($geo)) { -- cgit v1.2.3-54-g00ecf