Skip to content
Permalink
Browse files

TagCloud turned into plugin (performance issues on large installs)

  • Loading branch information...
Mikael Nordfeldth
Mikael Nordfeldth committed Aug 27, 2016
1 parent 5a008c3 commit a32bfe7d87ae513ae5762db5cde628c87333b5aa
@@ -170,12 +170,6 @@ function showSections()
}
$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 @@ function showPageNoticeBlock()
function showSections() {
$ns = new AttachmentNoticeSection($this);
$ns->show();
if (!common_config('performance', 'high')) {
$atcs = new AttachmentTagCloudSection($this);
$atcs->show();
}
}
}
@@ -86,12 +86,6 @@ function showSections()
$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 @@ function showAnonymousMessage()
$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 @@ function showSections()
}
$this->showAdmins();
if (!common_config('performance', 'high')) {
$cloud = new GroupTagCloudSection($this, $this->group);
$cloud->show();
}
}
/**
@@ -77,13 +77,6 @@ function show()
// 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 @@ function initialize()
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));
@@ -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;
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -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;
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit a32bfe7

Please sign in to comment.
You can’t perform that action at this time.