forked from GNUsocial/gnu-social
Some upgrades to Atom output for OStatus
This commit is contained in:
parent
ce3c3be1bf
commit
e2c0f59414
@ -189,7 +189,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
|||||||
|
|
||||||
$atom->addEntryFromNotices($this->notices);
|
$atom->addEntryFromNotices($this->notices);
|
||||||
|
|
||||||
print $atom->getString();
|
$this->raw($atom->getString());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
|
@ -957,7 +957,10 @@ class Notice extends Memcached_DataObject
|
|||||||
|
|
||||||
if ($namespace) {
|
if ($namespace) {
|
||||||
$attrs = array('xmlns' => 'http://www.w3.org/2005/Atom',
|
$attrs = array('xmlns' => 'http://www.w3.org/2005/Atom',
|
||||||
'xmlns:thr' => 'http://purl.org/syndication/thread/1.0');
|
'xmlns:thr' => 'http://purl.org/syndication/thread/1.0',
|
||||||
|
'xmlns:georss' => 'http://www.georss.org/georss',
|
||||||
|
'xmlns:activity' => 'http://activitystrea.ms/spec/1.0/',
|
||||||
|
'xmlns:ostatus' => 'http://ostatus.org/schema/1.0');
|
||||||
} else {
|
} else {
|
||||||
$attrs = array();
|
$attrs = array();
|
||||||
}
|
}
|
||||||
@ -983,11 +986,6 @@ class Notice extends Memcached_DataObject
|
|||||||
$xs->element('icon', null, $profile->avatarUrl(AVATAR_PROFILE_SIZE));
|
$xs->element('icon', null, $profile->avatarUrl(AVATAR_PROFILE_SIZE));
|
||||||
}
|
}
|
||||||
|
|
||||||
$xs->elementStart('author');
|
|
||||||
$xs->element('name', null, $profile->nickname);
|
|
||||||
$xs->element('uri', null, $profile->profileurl);
|
|
||||||
$xs->elementEnd('author');
|
|
||||||
|
|
||||||
if ($source) {
|
if ($source) {
|
||||||
$xs->elementEnd('source');
|
$xs->elementEnd('source');
|
||||||
}
|
}
|
||||||
@ -995,6 +993,9 @@ class Notice extends Memcached_DataObject
|
|||||||
$xs->element('title', null, $this->content);
|
$xs->element('title', null, $this->content);
|
||||||
$xs->element('summary', null, $this->content);
|
$xs->element('summary', null, $this->content);
|
||||||
|
|
||||||
|
$xs->raw($profile->asAtomAuthor());
|
||||||
|
$xs->raw($profile->asActivityActor($namespace));
|
||||||
|
|
||||||
$xs->element('link', array('rel' => 'alternate',
|
$xs->element('link', array('rel' => 'alternate',
|
||||||
'href' => $this->bestUrl()));
|
'href' => $this->bestUrl()));
|
||||||
|
|
||||||
@ -1014,6 +1015,29 @@ class Notice extends Memcached_DataObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($this->conversation)
|
||||||
|
&& $this->conversation != $this->notice->id) {
|
||||||
|
$xs->element(
|
||||||
|
'link', array(
|
||||||
|
'rel' => 'osatus:conversation',
|
||||||
|
'href' => common_local_url(
|
||||||
|
'conversation',
|
||||||
|
array('id' => $this->conversation)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($this->repeat_of)) {
|
||||||
|
$repeat = Notice::staticGet('id', $this->repeat_of);
|
||||||
|
if (!empty($repeat)) {
|
||||||
|
$xs->element(
|
||||||
|
'ostatus:forward',
|
||||||
|
array('ref' => $repeat->uri, 'href' => $repeat->bestUrl())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$xs->element('content', array('type' => 'html'), $this->rendered);
|
$xs->element('content', array('type' => 'html'), $this->rendered);
|
||||||
|
|
||||||
$tag = new Notice_tag();
|
$tag = new Notice_tag();
|
||||||
@ -1041,9 +1065,7 @@ class Notice extends Memcached_DataObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($this->lat) && !empty($this->lon)) {
|
if (!empty($this->lat) && !empty($this->lon)) {
|
||||||
$xs->elementStart('geo', array('xmlns:georss' => 'http://www.georss.org/georss'));
|
|
||||||
$xs->element('georss:point', null, $this->lat . ' ' . $this->lon);
|
$xs->element('georss:point', null, $this->lat . ' ' . $this->lon);
|
||||||
$xs->elementEnd('geo');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$xs->elementEnd('entry');
|
$xs->elementEnd('entry');
|
||||||
|
@ -754,4 +754,53 @@ class Profile extends Memcached_DataObject
|
|||||||
|
|
||||||
return !empty($notice);
|
return !empty($notice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function asAtomAuthor()
|
||||||
|
{
|
||||||
|
$xs = new XMLStringer(true);
|
||||||
|
|
||||||
|
$xs->elementStart('author');
|
||||||
|
$xs->element('name', null, $this->nickname);
|
||||||
|
$xs->element('uri', null, $this->profileurl);
|
||||||
|
$xs->elementEnd('author');
|
||||||
|
|
||||||
|
return $xs->getString();
|
||||||
|
}
|
||||||
|
|
||||||
|
function asActivityActor()
|
||||||
|
{
|
||||||
|
$xs = new XMLStringer(true);
|
||||||
|
|
||||||
|
$xs->elementStart('activity:actor');
|
||||||
|
$xs->element(
|
||||||
|
'activity:object-type',
|
||||||
|
null,
|
||||||
|
'http://activitystrea.ms/schema/1.0/person'
|
||||||
|
);
|
||||||
|
$xs->element(
|
||||||
|
'id',
|
||||||
|
null,
|
||||||
|
common_local_url(
|
||||||
|
'userbyid',
|
||||||
|
array('id' => $this->id)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$xs->element('title', null, $this->getBestName());
|
||||||
|
|
||||||
|
$avatar = $this->getAvatar(AVATAR_PROFILE_SIZE);
|
||||||
|
|
||||||
|
$xs->element(
|
||||||
|
'link', array(
|
||||||
|
'type' => empty($avatar) ? 'image/png' : $avatar->mediatype,
|
||||||
|
'href' => empty($avatar)
|
||||||
|
? Avatar::defaultImage(AVATAR_PROFILE_SIZE)
|
||||||
|
: $avatar->displayUrl()
|
||||||
|
),
|
||||||
|
''
|
||||||
|
);
|
||||||
|
|
||||||
|
$xs->elementEnd('activity:actor');
|
||||||
|
|
||||||
|
return $xs->getString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,7 @@ class Atom10Feed extends XMLStringer
|
|||||||
* Assumes you want rel="alternate" and type="text/html" unless
|
* Assumes you want rel="alternate" and type="text/html" unless
|
||||||
* you send in $otherAttrs.
|
* you send in $otherAttrs.
|
||||||
*
|
*
|
||||||
* @param string $uri the uri the href need to point to
|
* @param string $uri the uri the href needs to point to
|
||||||
* @param array $otherAttrs other attributes to stick in
|
* @param array $otherAttrs other attributes to stick in
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
|
@ -5,12 +5,28 @@ class AtomNoticeFeed extends Atom10Feed
|
|||||||
function __construct($indent = true) {
|
function __construct($indent = true) {
|
||||||
parent::__construct($indent);
|
parent::__construct($indent);
|
||||||
|
|
||||||
// Feeds containing notice info use the Atom Threading Extensions
|
// Feeds containing notice info use these namespaces
|
||||||
|
|
||||||
$this->addNamespace(
|
$this->addNamespace(
|
||||||
'xmlns:thr',
|
'xmlns:thr',
|
||||||
'http://purl.org/syndication/thread/1.0'
|
'http://purl.org/syndication/thread/1.0'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->addNamespace(
|
||||||
|
'xmlns:georss',
|
||||||
|
'http://www.georss.org/georss'
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->addNamespace(
|
||||||
|
'xmlns:activity',
|
||||||
|
'http://activitystrea.ms/spec/1.0/'
|
||||||
|
);
|
||||||
|
|
||||||
|
// XXX: What should the uri be?
|
||||||
|
$this->addNamespace(
|
||||||
|
'xmlns:ostatus',
|
||||||
|
'http://ostatus.org/schema/1.0'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addEntryFromNotices($notices)
|
function addEntryFromNotices($notices)
|
||||||
|
Loading…
Reference in New Issue
Block a user