]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Handle tag filtering in the Bookmark service
authorArthurHoaro <arthur@hoa.ro>
Sat, 16 May 2020 11:13:00 +0000 (13:13 +0200)
committerArthurHoaro <arthur@hoa.ro>
Thu, 23 Jul 2020 19:19:21 +0000 (21:19 +0200)
application/bookmark/BookmarkFileService.php
application/front/controllers/TagCloudController.php
index.php
tests/bookmark/BookmarkFileServiceTest.php
tests/front/controller/TagCloudControllerTest.php

index fef998fdddc61e641e2571d18ea048d3020a9a20..3b3812afcea9512fe15049f286077252969a76e7 100644 (file)
@@ -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;
                 }
index b6f4a0ce99d30fd5d6f968eda0aef1c5064bbfc0..9389c2b03ad3ea783a1171190cbbac45869d4f39 100644 (file)
@@ -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.
index 423a68f4bfdce2735d132bca7353380cd7bb268e..bf7090e39c1a3560cf192ae9862710fa4a6f5834 100644 (file)
--- a/index.php
+++ b/index.php
@@ -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);
index 4900d41d80598b320e71784ff555739fb6444bdf..5adc26aad445efe897615679aab55d461a2dc9ee 100644 (file)
@@ -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,
index a76d58354e991e54e7f9fbfa6cee312e5ee6f5d5..5cbf06a9ee9458b579ef27232b6411dafcfdc764 100644 (file)
@@ -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];
             })
         ;