ticket 2055: added logos to Atom and RSS feeds

This commit is contained in:
Hue Bastard 2009-12-08 21:28:11 +10:00 committed by Brion Vibber
parent e2f0fc7b3f
commit 59e5958d3a
8 changed files with 49 additions and 20 deletions

View File

@ -101,6 +101,7 @@ class ApiTimelineFavoritesAction extends ApiBareAuthAction
function showTimeline()
{
$profile = $this->user->getProfile();
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
$sitename = common_config('site', 'name');
$title = sprintf(
@ -121,20 +122,21 @@ class ApiTimelineFavoritesAction extends ApiBareAuthAction
$profile->getBestName(),
$this->user->nickname
);
$logo = ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE);
switch($this->format) {
case 'xml':
$this->showXmlTimeline($this->notices);
break;
case 'rss':
$this->showRssTimeline($this->notices, $title, $link, $subtitle);
$this->showRssTimeline($this->notices, $title, $link, $subtitle, null, $logo, null, $logo);
break;
case 'atom':
$selfuri = common_root_url() .
ltrim($_SERVER['QUERY_STRING'], 'p=');
$this->showAtomTimeline(
$this->notices, $title, $id, $link, $subtitle,
null, $selfuri
null, $selfuri, $logo
);
break;
case 'json':

View File

@ -110,6 +110,7 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction
function showTimeline()
{
$profile = $this->user->getProfile();
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
$sitename = common_config('site', 'name');
$title = sprintf(_("%s and friends"), $this->user->nickname);
$taguribase = common_config('integration', 'taguri');
@ -121,13 +122,14 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction
_('Updates from %1$s and friends on %2$s!'),
$this->user->nickname, $sitename
);
$logo = ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE);
switch($this->format) {
case 'xml':
$this->showXmlTimeline($this->notices);
break;
case 'rss':
$this->showRssTimeline($this->notices, $title, $link, $subtitle);
$this->showRssTimeline($this->notices, $title, $link, $subtitle, null, $logo);
break;
case 'atom':
@ -144,7 +146,7 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction
$this->showAtomTimeline(
$this->notices, $title, $id, $link,
$subtitle, null, $selfuri
$subtitle, null, $selfuri, $logo
);
break;
case 'json':

View File

@ -105,6 +105,7 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction
function showTimeline()
{
$sitename = common_config('site', 'name');
$avatar = $this->group->homepage_logo;
$title = sprintf(_("%s timeline"), $this->group->nickname);
$taguribase = common_config('integration', 'taguri');
$id = "tag:$taguribase:GroupTimeline:" . $this->group->id;
@ -117,13 +118,14 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction
$this->group->nickname,
$sitename
);
$logo = ($avatar) ? $avatar : User_group::defaultLogo(AVATAR_PROFILE_SIZE);
switch($this->format) {
case 'xml':
$this->showXmlTimeline($this->notices);
break;
case 'rss':
$this->showRssTimeline($this->notices, $title, $link, $subtitle);
$this->showRssTimeline($this->notices, $title, $link, $subtitle, null, $logo);
break;
case 'atom':
$selfuri = common_root_url() .
@ -136,7 +138,8 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction
$link,
$subtitle,
null,
$selfuri
$selfuri,
$logo
);
break;
case 'json':

View File

@ -110,6 +110,7 @@ class ApiTimelineMentionsAction extends ApiBareAuthAction
function showTimeline()
{
$profile = $this->user->getProfile();
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
$sitename = common_config('site', 'name');
$title = sprintf(
@ -126,20 +127,21 @@ class ApiTimelineMentionsAction extends ApiBareAuthAction
_('%1$s updates that reply to updates from %2$s / %3$s.'),
$sitename, $this->user->nickname, $profile->getBestName()
);
$logo = ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE);
switch($this->format) {
case 'xml':
$this->showXmlTimeline($this->notices);
break;
case 'rss':
$this->showRssTimeline($this->notices, $title, $link, $subtitle);
$this->showRssTimeline($this->notices, $title, $link, $subtitle, null, $logo);
break;
case 'atom':
$selfuri = common_root_url() .
ltrim($_SERVER['QUERY_STRING'], 'p=');
$this->showAtomTimeline(
$this->notices, $title, $id, $link, $subtitle,
null, $selfuri
null, $selfuri, $logo
);
break;
case 'json':

View File

@ -103,6 +103,7 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction
function showTimeline()
{
$sitename = common_config('site', 'name');
$sitelogo = (common_config('site', 'logo')) ? common_config('site', 'logo') : Theme::path('logo.png');
$title = sprintf(_("%s public timeline"), $sitename);
$taguribase = common_config('integration', 'taguri');
$id = "tag:$taguribase:PublicTimeline";
@ -114,13 +115,13 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction
$this->showXmlTimeline($this->notices);
break;
case 'rss':
$this->showRssTimeline($this->notices, $title, $link, $subtitle);
$this->showRssTimeline($this->notices, $title, $link, $subtitle, null, $sitelogo);
break;
case 'atom':
$selfuri = common_root_url() . 'api/statuses/public_timeline.atom';
$this->showAtomTimeline(
$this->notices, $title, $id, $link,
$subtitle, null, $selfuri
$subtitle, null, $selfuri, $sitelogo
);
break;
case 'json':

View File

@ -98,6 +98,7 @@ class ApiTimelineTagAction extends ApiPrivateAuthAction
function showTimeline()
{
$sitename = common_config('site', 'name');
$sitelogo = (common_config('site', 'logo')) ? common_config('site', 'logo') : Theme::path('logo.png');
$title = sprintf(_("Notices tagged with %s"), $this->tag);
$link = common_local_url(
'tag',
@ -116,7 +117,7 @@ class ApiTimelineTagAction extends ApiPrivateAuthAction
$this->showXmlTimeline($this->notices);
break;
case 'rss':
$this->showRssTimeline($this->notices, $title, $link, $subtitle);
$this->showRssTimeline($this->notices, $title, $link, $subtitle, null, $sitelogo);
break;
case 'atom':
$selfuri = common_root_url() .
@ -129,7 +130,8 @@ class ApiTimelineTagAction extends ApiPrivateAuthAction
$link,
$subtitle,
null,
$selfuri
$selfuri,
$sitelogo
);
break;
case 'json':

View File

@ -112,6 +112,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
function showTimeline()
{
$profile = $this->user->getProfile();
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
$sitename = common_config('site', 'name');
$title = sprintf(_("%s timeline"), $this->user->nickname);
@ -125,6 +126,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
_('Updates from %1$s on %2$s!'),
$this->user->nickname, $sitename
);
$logo = ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE);
// FriendFeed's SUP protocol
// Also added RSS and Atom feeds
@ -139,7 +141,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
case 'rss':
$this->showRssTimeline(
$this->notices, $title, $link,
$subtitle, $suplink
$subtitle, $suplink, $logo
);
break;
case 'atom':
@ -153,7 +155,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
}
$this->showAtomTimeline(
$this->notices, $title, $id, $link,
$subtitle, $suplink, $selfuri
$subtitle, $suplink, $selfuri, $logo
);
break;
case 'json':

View File

@ -134,17 +134,19 @@ class ApiAction extends Action
$twitter_user['protected'] = false; # not supported by StatusNet yet
$twitter_user['followers_count'] = $profile->subscriberCount();
$user = $profile->getUser();
$design = null;
$user = $profile->getUser();
// Note: some profiles don't have an associated user
$defaultDesign = Design::siteDesign();
if (!empty($user)) {
$design = $user->getDesign();
}
if (empty($design)) {
$design = Design::siteDesign();
}
$color = Design::toWebColor(empty($design->backgroundcolor) ? $defaultDesign->backgroundcolor : $design->backgroundcolor);
$twitter_user['profile_background_color'] = ($color == null) ? '' : '#'.$color->hexValue();
$color = Design::toWebColor(empty($design->textcolor) ? $defaultDesign->textcolor : $design->textcolor);
@ -163,7 +165,7 @@ class ApiAction extends Action
$timezone = 'UTC';
if (!empty($user) && !empty($user->timezone)) {
if ($user->timezone) {
$timezone = $user->timezone;
}
@ -586,7 +588,7 @@ class ApiAction extends Action
$this->endDocument('xml');
}
function showRssTimeline($notice, $title, $link, $subtitle, $suplink=null)
function showRssTimeline($notice, $title, $link, $subtitle, $suplink=null, $logo=null)
{
$this->initDocument('rss');
@ -600,6 +602,15 @@ class ApiAction extends Action
'href' => $suplink,
'type' => 'application/json'));
}
if (!is_null($logo)) {
$this->elementStart('image');
$this->element('link', null, $link);
$this->element('title', null, $title);
$this->element('url', null, $logo);
$this->elementEnd('image');
}
$this->element('description', null, $subtitle);
$this->element('language', null, 'en-us');
$this->element('ttl', null, '40');
@ -619,7 +630,7 @@ class ApiAction extends Action
$this->endTwitterRss();
}
function showAtomTimeline($notice, $title, $id, $link, $subtitle=null, $suplink=null, $selfuri=null)
function showAtomTimeline($notice, $title, $id, $link, $subtitle=null, $suplink=null, $selfuri=null, $logo=null)
{
$this->initDocument('atom');
@ -628,6 +639,10 @@ class ApiAction extends Action
$this->element('id', null, $id);
$this->element('link', array('href' => $link, 'rel' => 'alternate', 'type' => 'text/html'), null);
if (!is_null($logo)) {
$this->element('logo',null,$logo);
}
if (!is_null($suplink)) {
# For FriendFeed's SUP protocol
$this->element('link', array('rel' => 'http://api.friendfeed.com/2008/03#sup',