ticket 2055: added logos to Atom and RSS feeds
This commit is contained in:
parent
e2f0fc7b3f
commit
59e5958d3a
|
@ -101,6 +101,7 @@ class ApiTimelineFavoritesAction extends ApiBareAuthAction
|
||||||
function showTimeline()
|
function showTimeline()
|
||||||
{
|
{
|
||||||
$profile = $this->user->getProfile();
|
$profile = $this->user->getProfile();
|
||||||
|
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
|
||||||
|
|
||||||
$sitename = common_config('site', 'name');
|
$sitename = common_config('site', 'name');
|
||||||
$title = sprintf(
|
$title = sprintf(
|
||||||
|
@ -121,20 +122,21 @@ class ApiTimelineFavoritesAction extends ApiBareAuthAction
|
||||||
$profile->getBestName(),
|
$profile->getBestName(),
|
||||||
$this->user->nickname
|
$this->user->nickname
|
||||||
);
|
);
|
||||||
|
$logo = ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE);
|
||||||
|
|
||||||
switch($this->format) {
|
switch($this->format) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
$this->showXmlTimeline($this->notices);
|
$this->showXmlTimeline($this->notices);
|
||||||
break;
|
break;
|
||||||
case 'rss':
|
case 'rss':
|
||||||
$this->showRssTimeline($this->notices, $title, $link, $subtitle);
|
$this->showRssTimeline($this->notices, $title, $link, $subtitle, null, $logo, null, $logo);
|
||||||
break;
|
break;
|
||||||
case 'atom':
|
case 'atom':
|
||||||
$selfuri = common_root_url() .
|
$selfuri = common_root_url() .
|
||||||
ltrim($_SERVER['QUERY_STRING'], 'p=');
|
ltrim($_SERVER['QUERY_STRING'], 'p=');
|
||||||
$this->showAtomTimeline(
|
$this->showAtomTimeline(
|
||||||
$this->notices, $title, $id, $link, $subtitle,
|
$this->notices, $title, $id, $link, $subtitle,
|
||||||
null, $selfuri
|
null, $selfuri, $logo
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
|
|
|
@ -110,6 +110,7 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction
|
||||||
function showTimeline()
|
function showTimeline()
|
||||||
{
|
{
|
||||||
$profile = $this->user->getProfile();
|
$profile = $this->user->getProfile();
|
||||||
|
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
|
||||||
$sitename = common_config('site', 'name');
|
$sitename = common_config('site', 'name');
|
||||||
$title = sprintf(_("%s and friends"), $this->user->nickname);
|
$title = sprintf(_("%s and friends"), $this->user->nickname);
|
||||||
$taguribase = common_config('integration', 'taguri');
|
$taguribase = common_config('integration', 'taguri');
|
||||||
|
@ -121,13 +122,14 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction
|
||||||
_('Updates from %1$s and friends on %2$s!'),
|
_('Updates from %1$s and friends on %2$s!'),
|
||||||
$this->user->nickname, $sitename
|
$this->user->nickname, $sitename
|
||||||
);
|
);
|
||||||
|
$logo = ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE);
|
||||||
|
|
||||||
switch($this->format) {
|
switch($this->format) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
$this->showXmlTimeline($this->notices);
|
$this->showXmlTimeline($this->notices);
|
||||||
break;
|
break;
|
||||||
case 'rss':
|
case 'rss':
|
||||||
$this->showRssTimeline($this->notices, $title, $link, $subtitle);
|
$this->showRssTimeline($this->notices, $title, $link, $subtitle, null, $logo);
|
||||||
break;
|
break;
|
||||||
case 'atom':
|
case 'atom':
|
||||||
|
|
||||||
|
@ -144,7 +146,7 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction
|
||||||
|
|
||||||
$this->showAtomTimeline(
|
$this->showAtomTimeline(
|
||||||
$this->notices, $title, $id, $link,
|
$this->notices, $title, $id, $link,
|
||||||
$subtitle, null, $selfuri
|
$subtitle, null, $selfuri, $logo
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
|
|
|
@ -105,6 +105,7 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction
|
||||||
function showTimeline()
|
function showTimeline()
|
||||||
{
|
{
|
||||||
$sitename = common_config('site', 'name');
|
$sitename = common_config('site', 'name');
|
||||||
|
$avatar = $this->group->homepage_logo;
|
||||||
$title = sprintf(_("%s timeline"), $this->group->nickname);
|
$title = sprintf(_("%s timeline"), $this->group->nickname);
|
||||||
$taguribase = common_config('integration', 'taguri');
|
$taguribase = common_config('integration', 'taguri');
|
||||||
$id = "tag:$taguribase:GroupTimeline:" . $this->group->id;
|
$id = "tag:$taguribase:GroupTimeline:" . $this->group->id;
|
||||||
|
@ -117,13 +118,14 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction
|
||||||
$this->group->nickname,
|
$this->group->nickname,
|
||||||
$sitename
|
$sitename
|
||||||
);
|
);
|
||||||
|
$logo = ($avatar) ? $avatar : User_group::defaultLogo(AVATAR_PROFILE_SIZE);
|
||||||
|
|
||||||
switch($this->format) {
|
switch($this->format) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
$this->showXmlTimeline($this->notices);
|
$this->showXmlTimeline($this->notices);
|
||||||
break;
|
break;
|
||||||
case 'rss':
|
case 'rss':
|
||||||
$this->showRssTimeline($this->notices, $title, $link, $subtitle);
|
$this->showRssTimeline($this->notices, $title, $link, $subtitle, null, $logo);
|
||||||
break;
|
break;
|
||||||
case 'atom':
|
case 'atom':
|
||||||
$selfuri = common_root_url() .
|
$selfuri = common_root_url() .
|
||||||
|
@ -136,7 +138,8 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction
|
||||||
$link,
|
$link,
|
||||||
$subtitle,
|
$subtitle,
|
||||||
null,
|
null,
|
||||||
$selfuri
|
$selfuri,
|
||||||
|
$logo
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
|
|
|
@ -110,6 +110,7 @@ class ApiTimelineMentionsAction extends ApiBareAuthAction
|
||||||
function showTimeline()
|
function showTimeline()
|
||||||
{
|
{
|
||||||
$profile = $this->user->getProfile();
|
$profile = $this->user->getProfile();
|
||||||
|
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
|
||||||
|
|
||||||
$sitename = common_config('site', 'name');
|
$sitename = common_config('site', 'name');
|
||||||
$title = sprintf(
|
$title = sprintf(
|
||||||
|
@ -126,20 +127,21 @@ class ApiTimelineMentionsAction extends ApiBareAuthAction
|
||||||
_('%1$s updates that reply to updates from %2$s / %3$s.'),
|
_('%1$s updates that reply to updates from %2$s / %3$s.'),
|
||||||
$sitename, $this->user->nickname, $profile->getBestName()
|
$sitename, $this->user->nickname, $profile->getBestName()
|
||||||
);
|
);
|
||||||
|
$logo = ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE);
|
||||||
|
|
||||||
switch($this->format) {
|
switch($this->format) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
$this->showXmlTimeline($this->notices);
|
$this->showXmlTimeline($this->notices);
|
||||||
break;
|
break;
|
||||||
case 'rss':
|
case 'rss':
|
||||||
$this->showRssTimeline($this->notices, $title, $link, $subtitle);
|
$this->showRssTimeline($this->notices, $title, $link, $subtitle, null, $logo);
|
||||||
break;
|
break;
|
||||||
case 'atom':
|
case 'atom':
|
||||||
$selfuri = common_root_url() .
|
$selfuri = common_root_url() .
|
||||||
ltrim($_SERVER['QUERY_STRING'], 'p=');
|
ltrim($_SERVER['QUERY_STRING'], 'p=');
|
||||||
$this->showAtomTimeline(
|
$this->showAtomTimeline(
|
||||||
$this->notices, $title, $id, $link, $subtitle,
|
$this->notices, $title, $id, $link, $subtitle,
|
||||||
null, $selfuri
|
null, $selfuri, $logo
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
|
|
|
@ -103,6 +103,7 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction
|
||||||
function showTimeline()
|
function showTimeline()
|
||||||
{
|
{
|
||||||
$sitename = common_config('site', 'name');
|
$sitename = common_config('site', 'name');
|
||||||
|
$sitelogo = (common_config('site', 'logo')) ? common_config('site', 'logo') : Theme::path('logo.png');
|
||||||
$title = sprintf(_("%s public timeline"), $sitename);
|
$title = sprintf(_("%s public timeline"), $sitename);
|
||||||
$taguribase = common_config('integration', 'taguri');
|
$taguribase = common_config('integration', 'taguri');
|
||||||
$id = "tag:$taguribase:PublicTimeline";
|
$id = "tag:$taguribase:PublicTimeline";
|
||||||
|
@ -114,13 +115,13 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction
|
||||||
$this->showXmlTimeline($this->notices);
|
$this->showXmlTimeline($this->notices);
|
||||||
break;
|
break;
|
||||||
case 'rss':
|
case 'rss':
|
||||||
$this->showRssTimeline($this->notices, $title, $link, $subtitle);
|
$this->showRssTimeline($this->notices, $title, $link, $subtitle, null, $sitelogo);
|
||||||
break;
|
break;
|
||||||
case 'atom':
|
case 'atom':
|
||||||
$selfuri = common_root_url() . 'api/statuses/public_timeline.atom';
|
$selfuri = common_root_url() . 'api/statuses/public_timeline.atom';
|
||||||
$this->showAtomTimeline(
|
$this->showAtomTimeline(
|
||||||
$this->notices, $title, $id, $link,
|
$this->notices, $title, $id, $link,
|
||||||
$subtitle, null, $selfuri
|
$subtitle, null, $selfuri, $sitelogo
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
|
|
|
@ -98,6 +98,7 @@ class ApiTimelineTagAction extends ApiPrivateAuthAction
|
||||||
function showTimeline()
|
function showTimeline()
|
||||||
{
|
{
|
||||||
$sitename = common_config('site', 'name');
|
$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);
|
$title = sprintf(_("Notices tagged with %s"), $this->tag);
|
||||||
$link = common_local_url(
|
$link = common_local_url(
|
||||||
'tag',
|
'tag',
|
||||||
|
@ -116,7 +117,7 @@ class ApiTimelineTagAction extends ApiPrivateAuthAction
|
||||||
$this->showXmlTimeline($this->notices);
|
$this->showXmlTimeline($this->notices);
|
||||||
break;
|
break;
|
||||||
case 'rss':
|
case 'rss':
|
||||||
$this->showRssTimeline($this->notices, $title, $link, $subtitle);
|
$this->showRssTimeline($this->notices, $title, $link, $subtitle, null, $sitelogo);
|
||||||
break;
|
break;
|
||||||
case 'atom':
|
case 'atom':
|
||||||
$selfuri = common_root_url() .
|
$selfuri = common_root_url() .
|
||||||
|
@ -129,7 +130,8 @@ class ApiTimelineTagAction extends ApiPrivateAuthAction
|
||||||
$link,
|
$link,
|
||||||
$subtitle,
|
$subtitle,
|
||||||
null,
|
null,
|
||||||
$selfuri
|
$selfuri,
|
||||||
|
$sitelogo
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
|
|
|
@ -112,6 +112,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
||||||
function showTimeline()
|
function showTimeline()
|
||||||
{
|
{
|
||||||
$profile = $this->user->getProfile();
|
$profile = $this->user->getProfile();
|
||||||
|
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
|
||||||
|
|
||||||
$sitename = common_config('site', 'name');
|
$sitename = common_config('site', 'name');
|
||||||
$title = sprintf(_("%s timeline"), $this->user->nickname);
|
$title = sprintf(_("%s timeline"), $this->user->nickname);
|
||||||
|
@ -125,6 +126,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
||||||
_('Updates from %1$s on %2$s!'),
|
_('Updates from %1$s on %2$s!'),
|
||||||
$this->user->nickname, $sitename
|
$this->user->nickname, $sitename
|
||||||
);
|
);
|
||||||
|
$logo = ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE);
|
||||||
|
|
||||||
// FriendFeed's SUP protocol
|
// FriendFeed's SUP protocol
|
||||||
// Also added RSS and Atom feeds
|
// Also added RSS and Atom feeds
|
||||||
|
@ -139,7 +141,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
||||||
case 'rss':
|
case 'rss':
|
||||||
$this->showRssTimeline(
|
$this->showRssTimeline(
|
||||||
$this->notices, $title, $link,
|
$this->notices, $title, $link,
|
||||||
$subtitle, $suplink
|
$subtitle, $suplink, $logo
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'atom':
|
case 'atom':
|
||||||
|
@ -153,7 +155,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
||||||
}
|
}
|
||||||
$this->showAtomTimeline(
|
$this->showAtomTimeline(
|
||||||
$this->notices, $title, $id, $link,
|
$this->notices, $title, $id, $link,
|
||||||
$subtitle, $suplink, $selfuri
|
$subtitle, $suplink, $selfuri, $logo
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
|
|
27
lib/api.php
27
lib/api.php
|
@ -134,17 +134,19 @@ class ApiAction extends Action
|
||||||
$twitter_user['protected'] = false; # not supported by StatusNet yet
|
$twitter_user['protected'] = false; # not supported by StatusNet yet
|
||||||
$twitter_user['followers_count'] = $profile->subscriberCount();
|
$twitter_user['followers_count'] = $profile->subscriberCount();
|
||||||
|
|
||||||
$user = $profile->getUser();
|
|
||||||
$design = null;
|
$design = null;
|
||||||
|
$user = $profile->getUser();
|
||||||
|
|
||||||
// Note: some profiles don't have an associated user
|
// Note: some profiles don't have an associated user
|
||||||
|
|
||||||
$defaultDesign = Design::siteDesign();
|
|
||||||
|
|
||||||
if (!empty($user)) {
|
if (!empty($user)) {
|
||||||
$design = $user->getDesign();
|
$design = $user->getDesign();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($design)) {
|
||||||
|
$design = Design::siteDesign();
|
||||||
|
}
|
||||||
|
|
||||||
$color = Design::toWebColor(empty($design->backgroundcolor) ? $defaultDesign->backgroundcolor : $design->backgroundcolor);
|
$color = Design::toWebColor(empty($design->backgroundcolor) ? $defaultDesign->backgroundcolor : $design->backgroundcolor);
|
||||||
$twitter_user['profile_background_color'] = ($color == null) ? '' : '#'.$color->hexValue();
|
$twitter_user['profile_background_color'] = ($color == null) ? '' : '#'.$color->hexValue();
|
||||||
$color = Design::toWebColor(empty($design->textcolor) ? $defaultDesign->textcolor : $design->textcolor);
|
$color = Design::toWebColor(empty($design->textcolor) ? $defaultDesign->textcolor : $design->textcolor);
|
||||||
|
@ -163,7 +165,7 @@ class ApiAction extends Action
|
||||||
|
|
||||||
$timezone = 'UTC';
|
$timezone = 'UTC';
|
||||||
|
|
||||||
if (!empty($user) && !empty($user->timezone)) {
|
if ($user->timezone) {
|
||||||
$timezone = $user->timezone;
|
$timezone = $user->timezone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -586,7 +588,7 @@ class ApiAction extends Action
|
||||||
$this->endDocument('xml');
|
$this->endDocument('xml');
|
||||||
}
|
}
|
||||||
|
|
||||||
function showRssTimeline($notice, $title, $link, $subtitle, $suplink=null)
|
function showRssTimeline($notice, $title, $link, $subtitle, $suplink=null, $logo=null)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->initDocument('rss');
|
$this->initDocument('rss');
|
||||||
|
@ -600,6 +602,15 @@ class ApiAction extends Action
|
||||||
'href' => $suplink,
|
'href' => $suplink,
|
||||||
'type' => 'application/json'));
|
'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('description', null, $subtitle);
|
||||||
$this->element('language', null, 'en-us');
|
$this->element('language', null, 'en-us');
|
||||||
$this->element('ttl', null, '40');
|
$this->element('ttl', null, '40');
|
||||||
|
@ -619,7 +630,7 @@ class ApiAction extends Action
|
||||||
$this->endTwitterRss();
|
$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');
|
$this->initDocument('atom');
|
||||||
|
@ -628,6 +639,10 @@ class ApiAction extends Action
|
||||||
$this->element('id', null, $id);
|
$this->element('id', null, $id);
|
||||||
$this->element('link', array('href' => $link, 'rel' => 'alternate', 'type' => 'text/html'), null);
|
$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)) {
|
if (!is_null($suplink)) {
|
||||||
# For FriendFeed's SUP protocol
|
# For FriendFeed's SUP protocol
|
||||||
$this->element('link', array('rel' => 'http://api.friendfeed.com/2008/03#sup',
|
$this->element('link', array('rel' => 'http://api.friendfeed.com/2008/03#sup',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user