TagCloud turned into plugin (performance issues on large installs)
This commit is contained in:
parent
5a008c3738
commit
a32bfe7d87
@ -170,12 +170,6 @@ class AllAction extends ShowstreamAction
|
||||
}
|
||||
$ibs->show();
|
||||
}
|
||||
// XXX: make this a little more convenient
|
||||
|
||||
if (!common_config('performance', 'high')) {
|
||||
$pop = new InboxTagCloudSection($this, $this->target);
|
||||
$pop->show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,9 +132,5 @@ class AttachmentAction extends ManagedAction
|
||||
function showSections() {
|
||||
$ns = new AttachmentNoticeSection($this);
|
||||
$ns->show();
|
||||
if (!common_config('performance', 'high')) {
|
||||
$atcs = new AttachmentTagCloudSection($this);
|
||||
$atcs->show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -86,12 +86,6 @@ class PublicAction extends SitestreamAction
|
||||
$ibs->show();
|
||||
}
|
||||
|
||||
$p = Profile::current();
|
||||
|
||||
if (!common_config('performance', 'high')) {
|
||||
$cloud = new PublicTagCloudSection($this);
|
||||
$cloud->show();
|
||||
}
|
||||
$feat = new FeaturedUsersSection($this);
|
||||
$feat->show();
|
||||
}
|
||||
|
@ -251,15 +251,6 @@ class ShowstreamAction extends NoticestreamAction
|
||||
$this->elementEnd('div');
|
||||
}
|
||||
|
||||
function showSections()
|
||||
{
|
||||
parent::showSections();
|
||||
if (!common_config('performance', 'high')) {
|
||||
$cloud = new PersonalTagCloudSection($this->target, $this);
|
||||
$cloud->show();
|
||||
}
|
||||
}
|
||||
|
||||
function noticeFormOptions()
|
||||
{
|
||||
$options = parent::noticeFormOptions();
|
||||
|
@ -112,11 +112,6 @@ class GroupAction extends Action
|
||||
}
|
||||
|
||||
$this->showAdmins();
|
||||
|
||||
if (!common_config('performance', 'high')) {
|
||||
$cloud = new GroupTagCloudSection($this, $this->group);
|
||||
$cloud->show();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -77,13 +77,6 @@ class PublicGroupNav extends Menu
|
||||
// TRANS: Menu item title in search group navigation panel.
|
||||
_('User groups'), $this->actionName == 'groups', 'nav_groups');
|
||||
|
||||
if (!common_config('performance', 'high')) {
|
||||
// TRANS: Menu item in search group navigation panel.
|
||||
$this->out->menuItem(common_local_url('publictagcloud'), _m('MENU','Recent tags'),
|
||||
// TRANS: Menu item title in search group navigation panel.
|
||||
_('Recent tags'), $this->actionName == 'publictagcloud', 'nav_recent-tags');
|
||||
}
|
||||
|
||||
if (count(common_config('nickname', 'featured')) > 0) {
|
||||
// TRANS: Menu item in search group navigation panel.
|
||||
$this->out->menuItem(common_local_url('featured'), _m('MENU','Featured'),
|
||||
|
@ -260,12 +260,6 @@ class Router
|
||||
array('action' => 'userbyid'),
|
||||
array('id' => '[0-9]+'));
|
||||
|
||||
if (!common_config('performance', 'high')) {
|
||||
$m->connect('tags/', array('action' => 'publictagcloud'));
|
||||
$m->connect('tag/', array('action' => 'publictagcloud'));
|
||||
$m->connect('tags', array('action' => 'publictagcloud'));
|
||||
$m->connect('tag', array('action' => 'publictagcloud'));
|
||||
}
|
||||
$m->connect('tag/:tag/rss',
|
||||
array('action' => 'tagrss'),
|
||||
array('tag' => self::REGEX_TAG));
|
||||
|
70
plugins/TagCloud/TagCloudPlugin.php
Normal file
70
plugins/TagCloud/TagCloudPlugin.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* GNU social plugin for "tag clouds" in the UI
|
||||
*
|
||||
* @category UI
|
||||
* @package GNUsocial
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @copyright 2016 Free Software Foundation, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://gnu.io/social/
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
class TagCloudPlugin extends Plugin {
|
||||
|
||||
public function onRouterInitialized(URLMapper $m)
|
||||
{
|
||||
$m->connect('tags/', array('action' => 'publictagcloud'));
|
||||
$m->connect('tag/', array('action' => 'publictagcloud'));
|
||||
$m->connect('tags', array('action' => 'publictagcloud'));
|
||||
$m->connect('tag', array('action' => 'publictagcloud'));
|
||||
}
|
||||
|
||||
public function onEndPublicGroupNav(Menu $menu)
|
||||
{
|
||||
// TRANS: Menu item in search group navigation panel.
|
||||
$menu->out->menuItem(common_local_url('publictagcloud'), _m('MENU','Recent tags'),
|
||||
// TRANS: Menu item title in search group navigation panel.
|
||||
_('Recent tags'), $menu->actionName === 'publictagcloud', 'nav_recent-tags');
|
||||
}
|
||||
|
||||
public function onEndShowSections(Action $action)
|
||||
{
|
||||
$cloud = null;
|
||||
|
||||
switch (true) {
|
||||
case $action instanceof AllAction:
|
||||
$cloud = new InboxTagCloudSection($action, $action->getTarget());
|
||||
break;
|
||||
case $action instanceof AttachmentAction:
|
||||
$cloud = new AttachmentTagCloudSection($action);
|
||||
break;
|
||||
case $action instanceof PublicAction:
|
||||
$cloud = new PublicTagCloudSection($action);
|
||||
break;
|
||||
case $action instanceof ShowstreamAction:
|
||||
$cloud = new PersonalTagCloudSection($action, $action->getTarget());
|
||||
break;
|
||||
case $action instanceof GroupAction:
|
||||
$cloud = new GroupTagCloudSection($action, $action->getGroup());
|
||||
}
|
||||
|
||||
if (!is_null($cloud)) {
|
||||
$cloud->show();
|
||||
}
|
||||
}
|
||||
|
||||
public function onPluginVersion(array &$versions)
|
||||
{
|
||||
$versions[] = array('name' => 'TagCloud',
|
||||
'version' => GNUSOCIAL_VERSION,
|
||||
'author' => 'Mikael Nordfeldth',
|
||||
'homepage' => 'https://gnu.io/social',
|
||||
'description' =>
|
||||
// TRANS: Plugin description.
|
||||
_m('Adds tag clouds to stream pages'));
|
||||
return true;
|
||||
}
|
||||
}
|
@ -42,7 +42,7 @@ class PersonalTagCloudSection extends TagCloudSection
|
||||
{
|
||||
protected $profile = null;
|
||||
|
||||
function __construct(Profile $profile, HTMLOutputter $out=null)
|
||||
function __construct(HTMLOutputter $out, Profile $profile)
|
||||
{
|
||||
parent::__construct($out);
|
||||
$this->profile = $profile;
|
Loading…
Reference in New Issue
Block a user