Handle tag filtering in the Bookmark service
This commit is contained in:
parent
72caf4e84c
commit
c79473bd84
5 changed files with 3 additions and 15 deletions
|
@ -296,6 +296,7 @@ class BookmarkFileService implements BookmarkServiceInterface
|
|||
if (empty($tag)
|
||||
|| (! $this->isLoggedIn && startsWith($tag, '.'))
|
||||
|| $tag === BookmarkMarkdownFormatter::NO_MD_TAG
|
||||
|| in_array($tag, $filteringTags, true)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -39,9 +39,6 @@ class TagCloudController extends ShaarliController
|
|||
$logMaxCount = $maxCount > 1 ? log($maxCount, 30) : 1;
|
||||
$tagList = [];
|
||||
foreach ($tags as $key => $value) {
|
||||
if (in_array($key, $filteringTags)) {
|
||||
continue;
|
||||
}
|
||||
// Tag font size scaling:
|
||||
// default 15 and 30 logarithm bases affect scaling,
|
||||
// 2.2 and 0.8 are arbitrary font sizes in em.
|
||||
|
|
|
@ -625,11 +625,6 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM
|
|||
$visibility = ! empty($_SESSION['visibility']) ? $_SESSION['visibility'] : '';
|
||||
$filteringTags = isset($_GET['searchtags']) ? explode(' ', $_GET['searchtags']) : [];
|
||||
$tags = $bookmarkService->bookmarksCountPerTag($filteringTags, $visibility);
|
||||
foreach ($filteringTags as $tag) {
|
||||
if (array_key_exists($tag, $tags)) {
|
||||
unset($tags[$tag]);
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($_GET['sort']) && $_GET['sort'] === 'alpha') {
|
||||
alphabetical_sort($tags, false, true);
|
||||
|
|
|
@ -816,7 +816,6 @@ class BookmarkFileServiceTest extends TestCase
|
|||
);
|
||||
$this->assertEquals(
|
||||
[
|
||||
'web' => 4,
|
||||
'cartoon' => 2,
|
||||
'gnu' => 1,
|
||||
'dev' => 1,
|
||||
|
@ -833,7 +832,6 @@ class BookmarkFileServiceTest extends TestCase
|
|||
);
|
||||
$this->assertEquals(
|
||||
[
|
||||
'web' => 1,
|
||||
'html' => 1,
|
||||
'w3c' => 1,
|
||||
'css' => 1,
|
||||
|
@ -968,7 +966,6 @@ class BookmarkFileServiceTest extends TestCase
|
|||
public function testCountLinkPerTagAllWithFilter()
|
||||
{
|
||||
$expected = [
|
||||
'gnu' => 2,
|
||||
'hashtag' => 2,
|
||||
'-exclude' => 1,
|
||||
'.hidden' => 1,
|
||||
|
@ -991,7 +988,6 @@ class BookmarkFileServiceTest extends TestCase
|
|||
public function testCountLinkPerTagPublicWithFilter()
|
||||
{
|
||||
$expected = [
|
||||
'gnu' => 2,
|
||||
'hashtag' => 2,
|
||||
'-exclude' => 1,
|
||||
'.hidden' => 1,
|
||||
|
@ -1015,7 +1011,6 @@ class BookmarkFileServiceTest extends TestCase
|
|||
{
|
||||
$expected = [
|
||||
'cartoon' => 1,
|
||||
'dev' => 1,
|
||||
'tag1' => 1,
|
||||
'tag2' => 1,
|
||||
'tag3' => 1,
|
||||
|
|
|
@ -127,8 +127,8 @@ class TagCloudControllerTest extends TestCase
|
|||
->expects(static::once())
|
||||
->method('bookmarksCountPerTag')
|
||||
->with(['ghi', 'def'], BookmarkFilter::$PRIVATE)
|
||||
->willReturnCallback(function () use ($allTags): array {
|
||||
return $allTags;
|
||||
->willReturnCallback(function (): array {
|
||||
return ['abc' => 3];
|
||||
})
|
||||
;
|
||||
|
||||
|
|
Loading…
Reference in a new issue