Merge branch 'testing' of gitorious.org:statusnet/mainline into testing

This commit is contained in:
Brion Vibber 2010-02-25 18:52:26 -08:00
commit 2fa953da22
5 changed files with 24 additions and 31 deletions

View File

@ -107,8 +107,6 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction
$sitename = common_config('site', 'name'); $sitename = common_config('site', 'name');
$avatar = $this->group->homepage_logo; $avatar = $this->group->homepage_logo;
$title = sprintf(_("%s timeline"), $this->group->nickname); $title = sprintf(_("%s timeline"), $this->group->nickname);
$taguribase = TagURI::base();
$id = "tag:$taguribase:GroupTimeline:" . $this->group->id;
$subtitle = sprintf( $subtitle = sprintf(
_('Updates from %1$s on %2$s!'), _('Updates from %1$s on %2$s!'),
@ -138,19 +136,9 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction
try { try {
// If this was called using an integer ID, i.e.: using the canonical $atom = new AtomGroupNoticeFeed($this->group);
// URL for this group's feed, then pass the Group object into the feed,
// so the OStatus plugin, and possibly other plugins, can access it.
// Feels sorta hacky. -- Z
$atom = null; // @todo set all this Atom junk up inside the feed class
$id = $this->arg('id');
if (strval(intval($id)) === strval($id)) {
$atom = new AtomGroupNoticeFeed($this->group);
} else {
$atom = new AtomGroupNoticeFeed();
}
$atom->setId($id); $atom->setId($id);
$atom->setTitle($title); $atom->setTitle($title);
@ -169,6 +157,8 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction
$aargs['id'] = $id; $aargs['id'] = $id;
} }
$atom->setId($this->getSelfUri('ApiTimelineGroup', $aargs));
$atom->addLink( $atom->addLink(
$this->getSelfUri('ApiTimelineGroup', $aargs), $this->getSelfUri('ApiTimelineGroup', $aargs),
array('rel' => 'self', 'type' => 'application/atom+xml') array('rel' => 'self', 'type' => 'application/atom+xml')

View File

@ -116,8 +116,6 @@ class ApiTimelineUserAction extends ApiBareAuthAction
$sitename = common_config('site', 'name'); $sitename = common_config('site', 'name');
$title = sprintf(_("%s timeline"), $this->user->nickname); $title = sprintf(_("%s timeline"), $this->user->nickname);
$taguribase = TagURI::base();
$id = "tag:$taguribase:UserTimeline:" . $this->user->id;
$link = common_local_url( $link = common_local_url(
'showstream', 'showstream',
array('nickname' => $this->user->nickname) array('nickname' => $this->user->nickname)
@ -148,21 +146,10 @@ class ApiTimelineUserAction extends ApiBareAuthAction
header('Content-Type: application/atom+xml; charset=utf-8'); header('Content-Type: application/atom+xml; charset=utf-8');
// If this was called using an integer ID, i.e.: using the canonical // @todo set all this Atom junk up inside the feed class
// URL for this user's feed, then pass the User object into the feed,
// so the OStatus plugin, and possibly other plugins, can access it.
// Feels sorta hacky. -- Z
$atom = null; $atom = new AtomUserNoticeFeed($this->user);
$id = $this->arg('id');
if (strval(intval($id)) === strval($id)) {
$atom = new AtomUserNoticeFeed($this->user);
} else {
$atom = new AtomUserNoticeFeed();
}
$atom->setId($id);
$atom->setTitle($title); $atom->setTitle($title);
$atom->setSubtitle($subtitle); $atom->setSubtitle($subtitle);
$atom->setLogo($logo); $atom->setLogo($logo);
@ -181,6 +168,8 @@ class ApiTimelineUserAction extends ApiBareAuthAction
$aargs['id'] = $id; $aargs['id'] = $id;
} }
$atom->setId($this->getSelfUri('ApiTimelineUser', $aargs));
$atom->addLink( $atom->addLink(
$this->getSelfUri('ApiTimelineUser', $aargs), $this->getSelfUri('ApiTimelineUser', $aargs),
array('rel' => 'self', 'type' => 'application/atom+xml') array('rel' => 'self', 'type' => 'application/atom+xml')

View File

@ -517,7 +517,7 @@ class AvatarLink
} }
$alink = new AvatarLink(); $alink = new AvatarLink();
$alink->type = $avatar->mediatype; $alink->type = $avatar->mediatype;
$alink->height = $avatar->mediatype; $alink->height = $avatar->height;
$alink->width = $avatar->width; $alink->width = $avatar->width;
$alink->url = $avatar->displayUrl(); $alink->url = $avatar->displayUrl();
return $alink; return $alink;

View File

@ -1419,6 +1419,7 @@ class Ostatus_profile extends Memcached_DataObject
if (isset($feedUrl)) { if (isset($feedUrl)) {
try { try {
common_log(LOG_INFO, "Discovery on acct:$addr with feed URL $feedUrl");
$oprofile = self::ensureProfile($feedUrl, $hints); $oprofile = self::ensureProfile($feedUrl, $hints);
self::cacheSet(sprintf('ostatus_profile:webfinger:%s', $addr), $oprofile->uri); self::cacheSet(sprintf('ostatus_profile:webfinger:%s', $addr), $oprofile->uri);
return $oprofile; return $oprofile;
@ -1432,6 +1433,7 @@ class Ostatus_profile extends Memcached_DataObject
if (isset($profileUrl)) { if (isset($profileUrl)) {
try { try {
common_log(LOG_INFO, "Discovery on acct:$addr with profile URL $profileUrl");
$oprofile = self::ensureProfile($profileUrl, $hints); $oprofile = self::ensureProfile($profileUrl, $hints);
self::cacheSet(sprintf('ostatus_profile:webfinger:%s', $addr), $oprofile->uri); self::cacheSet(sprintf('ostatus_profile:webfinger:%s', $addr), $oprofile->uri);
return $oprofile; return $oprofile;

View File

@ -81,11 +81,14 @@ class Webfinger
function getServiceLinks($domain) function getServiceLinks($domain)
{ {
$url = 'http://'. $domain .'/.well-known/host-meta'; $url = 'http://'. $domain .'/.well-known/host-meta';
$content = $this->fetchURL($url); $content = $this->fetchURL($url);
if (empty($content)) { if (empty($content)) {
common_log(LOG_DEBUG, 'Error fetching host-meta'); common_log(LOG_DEBUG, 'Error fetching host-meta');
return false; return false;
} }
$result = XRD::parse($content); $result = XRD::parse($content);
// Ensure that the host == domain (spec may include signing later) // Ensure that the host == domain (spec may include signing later)
@ -119,6 +122,11 @@ class Webfinger
function fetchURL($url) function fetchURL($url)
{ {
try { try {
$c = Cache::instance();
$content = $c->get('webfinger:url:'.$url);
if ($content !== false) {
return $content;
}
$client = new HTTPClient(); $client = new HTTPClient();
$response = $client->get($url); $response = $client->get($url);
} catch (HTTP_Request2_Exception $e) { } catch (HTTP_Request2_Exception $e) {
@ -129,7 +137,11 @@ class Webfinger
return false; return false;
} }
return $response->getBody(); $body = $response->getBody();
$c->set('webfinger:url:'.$url, $body);
return $body;
} }
function applyTemplate($template, $id) function applyTemplate($template, $id)