From: Evan Prodromou Date: Sun, 19 Dec 2010 15:18:33 +0000 (-0500) Subject: Better output for activities and HTML in BookmarkPlugin X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=cb76465cfabbe508928098720dc08816dac7ea29;p=quix0rs-gnu-social.git Better output for activities and HTML in BookmarkPlugin --- diff --git a/plugins/Bookmark/BookmarkPlugin.php b/plugins/Bookmark/BookmarkPlugin.php index e50e45cade..3f36770391 100644 --- a/plugins/Bookmark/BookmarkPlugin.php +++ b/plugins/Bookmark/BookmarkPlugin.php @@ -65,7 +65,7 @@ class BookmarkPlugin extends Plugin array(new ColumnDef('notice_id', 'integer', null, - true, + false, 'PRI'), new ColumnDef('title', 'varchar', @@ -90,6 +90,7 @@ class BookmarkPlugin extends Plugin function onEndShowStyles($action) { $action->style('.bookmark_tags li { display: inline; }'); + $action->style('.bookmark_mentions li { display: inline; }'); return true; } @@ -162,25 +163,88 @@ class BookmarkPlugin extends Plugin $tags = $nli->notice->getTags(); $nli->out->elementStart('ul', array('class' => 'bookmark_tags')); 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->element('a', array('rel' => 'tag', - 'href' => $url), + $nli->out->element('a', + array('rel' => 'tag', + 'href' => Notice_tag::url($tag)), $tag); $nli->out->elementEnd('li'); $nli->out->text(' '); } $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 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; }