Better output for activities and HTML in BookmarkPlugin
This commit is contained in:
parent
d6030714f3
commit
cb76465cfa
@ -65,7 +65,7 @@ class BookmarkPlugin extends Plugin
|
|||||||
array(new ColumnDef('notice_id',
|
array(new ColumnDef('notice_id',
|
||||||
'integer',
|
'integer',
|
||||||
null,
|
null,
|
||||||
true,
|
false,
|
||||||
'PRI'),
|
'PRI'),
|
||||||
new ColumnDef('title',
|
new ColumnDef('title',
|
||||||
'varchar',
|
'varchar',
|
||||||
@ -90,6 +90,7 @@ class BookmarkPlugin extends Plugin
|
|||||||
function onEndShowStyles($action)
|
function onEndShowStyles($action)
|
||||||
{
|
{
|
||||||
$action->style('.bookmark_tags li { display: inline; }');
|
$action->style('.bookmark_tags li { display: inline; }');
|
||||||
|
$action->style('.bookmark_mentions li { display: inline; }');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,28 +163,91 @@ class BookmarkPlugin extends Plugin
|
|||||||
$tags = $nli->notice->getTags();
|
$tags = $nli->notice->getTags();
|
||||||
$nli->out->elementStart('ul', array('class' => 'bookmark_tags'));
|
$nli->out->elementStart('ul', array('class' => 'bookmark_tags'));
|
||||||
foreach ($tags as $tag) {
|
foreach ($tags as $tag) {
|
||||||
if (common_config('singleuser', 'enabled')) {
|
|
||||||
// regular TagAction isn't set up in 1user mode
|
|
||||||
$nickname = User::singleUserNickname();
|
|
||||||
$url = common_local_url('showstream',
|
|
||||||
array('nickname' => $nickname,
|
|
||||||
'tag' => $tag));
|
|
||||||
} else {
|
|
||||||
$url = common_local_url('tag', array('tag' => $tag));
|
|
||||||
}
|
|
||||||
$nli->out->elementStart('li');
|
$nli->out->elementStart('li');
|
||||||
$nli->out->element('a', array('rel' => 'tag',
|
$nli->out->element('a',
|
||||||
'href' => $url),
|
array('rel' => 'tag',
|
||||||
|
'href' => Notice_tag::url($tag)),
|
||||||
$tag);
|
$tag);
|
||||||
$nli->out->elementEnd('li');
|
$nli->out->elementEnd('li');
|
||||||
$nli->out->text(' ');
|
$nli->out->text(' ');
|
||||||
}
|
}
|
||||||
$nli->out->elementEnd('ul');
|
$nli->out->elementEnd('ul');
|
||||||
|
$replies = $nli->notice->getReplies();
|
||||||
|
if (!empty($replies)) {
|
||||||
|
$nli->out->elementStart('ul', array('class' => 'bookmark_mentions'));
|
||||||
|
foreach ($replies as $reply) {
|
||||||
|
$other = Profile::staticGet('id', $reply);
|
||||||
|
$nli->out->elementStart('li');
|
||||||
|
$nli->out->element('a', array('rel' => 'tag',
|
||||||
|
'href' => $other->profileurl,
|
||||||
|
'title' => $other->getBestName()),
|
||||||
|
sprintf('for:%s', $other->nickname));
|
||||||
|
$nli->out->elementEnd('li');
|
||||||
|
$nli->out->text(' ');
|
||||||
|
}
|
||||||
|
$nli->out->elementEnd('ul');
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onStartActivityObjectFromNotice($notice, &$object)
|
||||||
|
{
|
||||||
|
$nb = Notice_bookmark::staticGet('notice_id',
|
||||||
|
$notice->id);
|
||||||
|
|
||||||
|
if (!empty($nb)) {
|
||||||
|
|
||||||
|
$object->id = $notice->uri;
|
||||||
|
$object->type = ActivityObject::BOOKMARK;
|
||||||
|
$object->title = $nb->title;
|
||||||
|
$object->summary = $nb->summary;
|
||||||
|
|
||||||
|
// Attributes of the URL
|
||||||
|
|
||||||
|
$attachments = $notice->attachments();
|
||||||
|
|
||||||
|
if (count($attachments) != 1) {
|
||||||
|
throw new ServerException(_('Bookmark notice with the wrong number of attachments.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$target = $attachments[0];
|
||||||
|
|
||||||
|
$attrs = array('rel' => 'related',
|
||||||
|
'href' => $target->url);
|
||||||
|
|
||||||
|
if (!empty($target->title)) {
|
||||||
|
$attrs['title'] = $target->title;
|
||||||
|
}
|
||||||
|
|
||||||
|
$object->extra[] = array('link', $attrs);
|
||||||
|
|
||||||
|
// Attributes of the thumbnail, if any
|
||||||
|
|
||||||
|
$thumbnail = $target->getThumbnail();
|
||||||
|
|
||||||
|
if (!empty($thumbnail)) {
|
||||||
|
$tattrs = array('rel' => 'preview',
|
||||||
|
'href' => $thumbnail->url);
|
||||||
|
|
||||||
|
if (!empty($thumbnail->width)) {
|
||||||
|
$tattrs['media:width'] = $thumbnail->width;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($thumbnail->height)) {
|
||||||
|
$tattrs['media:height'] = $thumbnail->height;
|
||||||
|
}
|
||||||
|
|
||||||
|
$object->extra[] = array('link', $attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function onPluginVersion(&$versions)
|
function onPluginVersion(&$versions)
|
||||||
{
|
{
|
||||||
$versions[] = array('name' => 'Sample',
|
$versions[] = array('name' => 'Sample',
|
||||||
|
Loading…
Reference in New Issue
Block a user