aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-05-16 13:13:00 +0200
committerArthurHoaro <arthur@hoa.ro>2020-07-23 21:19:21 +0200
commitc79473bd84ab5aba7836d2caaf61847cabaf1e53 (patch)
treed4b730c015a91c1f390e4153c82cdf0395cf90af
parent72caf4e84c412ab6a4181b83a96dbef8ebb3c65a (diff)
downloadShaarli-c79473bd84ab5aba7836d2caaf61847cabaf1e53.tar.gz
Shaarli-c79473bd84ab5aba7836d2caaf61847cabaf1e53.tar.zst
Shaarli-c79473bd84ab5aba7836d2caaf61847cabaf1e53.zip
Handle tag filtering in the Bookmark service
-rw-r--r--application/bookmark/BookmarkFileService.php1
-rw-r--r--application/front/controllers/TagCloudController.php3
-rw-r--r--index.php5
-rw-r--r--tests/bookmark/BookmarkFileServiceTest.php5
-rw-r--r--tests/front/controller/TagCloudControllerTest.php4
5 files changed, 3 insertions, 15 deletions
diff --git a/application/bookmark/BookmarkFileService.php b/application/bookmark/BookmarkFileService.php
index fef998fd..3b3812af 100644
--- a/application/bookmark/BookmarkFileService.php
+++ b/application/bookmark/BookmarkFileService.php
@@ -296,6 +296,7 @@ class BookmarkFileService implements BookmarkServiceInterface
296 if (empty($tag) 296 if (empty($tag)
297 || (! $this->isLoggedIn && startsWith($tag, '.')) 297 || (! $this->isLoggedIn && startsWith($tag, '.'))
298 || $tag === BookmarkMarkdownFormatter::NO_MD_TAG 298 || $tag === BookmarkMarkdownFormatter::NO_MD_TAG
299 || in_array($tag, $filteringTags, true)
299 ) { 300 ) {
300 continue; 301 continue;
301 } 302 }
diff --git a/application/front/controllers/TagCloudController.php b/application/front/controllers/TagCloudController.php
index b6f4a0ce..9389c2b0 100644
--- a/application/front/controllers/TagCloudController.php
+++ b/application/front/controllers/TagCloudController.php
@@ -39,9 +39,6 @@ class TagCloudController extends ShaarliController
39 $logMaxCount = $maxCount > 1 ? log($maxCount, 30) : 1; 39 $logMaxCount = $maxCount > 1 ? log($maxCount, 30) : 1;
40 $tagList = []; 40 $tagList = [];
41 foreach ($tags as $key => $value) { 41 foreach ($tags as $key => $value) {
42 if (in_array($key, $filteringTags)) {
43 continue;
44 }
45 // Tag font size scaling: 42 // Tag font size scaling:
46 // default 15 and 30 logarithm bases affect scaling, 43 // default 15 and 30 logarithm bases affect scaling,
47 // 2.2 and 0.8 are arbitrary font sizes in em. 44 // 2.2 and 0.8 are arbitrary font sizes in em.
diff --git a/index.php b/index.php
index 423a68f4..bf7090e3 100644
--- a/index.php
+++ b/index.php
@@ -625,11 +625,6 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM
625 $visibility = ! empty($_SESSION['visibility']) ? $_SESSION['visibility'] : ''; 625 $visibility = ! empty($_SESSION['visibility']) ? $_SESSION['visibility'] : '';
626 $filteringTags = isset($_GET['searchtags']) ? explode(' ', $_GET['searchtags']) : []; 626 $filteringTags = isset($_GET['searchtags']) ? explode(' ', $_GET['searchtags']) : [];
627 $tags = $bookmarkService->bookmarksCountPerTag($filteringTags, $visibility); 627 $tags = $bookmarkService->bookmarksCountPerTag($filteringTags, $visibility);
628 foreach ($filteringTags as $tag) {
629 if (array_key_exists($tag, $tags)) {
630 unset($tags[$tag]);
631 }
632 }
633 628
634 if (! empty($_GET['sort']) && $_GET['sort'] === 'alpha') { 629 if (! empty($_GET['sort']) && $_GET['sort'] === 'alpha') {
635 alphabetical_sort($tags, false, true); 630 alphabetical_sort($tags, false, true);
diff --git a/tests/bookmark/BookmarkFileServiceTest.php b/tests/bookmark/BookmarkFileServiceTest.php
index 4900d41d..5adc26aa 100644
--- a/tests/bookmark/BookmarkFileServiceTest.php
+++ b/tests/bookmark/BookmarkFileServiceTest.php
@@ -816,7 +816,6 @@ class BookmarkFileServiceTest extends TestCase
816 ); 816 );
817 $this->assertEquals( 817 $this->assertEquals(
818 [ 818 [
819 'web' => 4,
820 'cartoon' => 2, 819 'cartoon' => 2,
821 'gnu' => 1, 820 'gnu' => 1,
822 'dev' => 1, 821 'dev' => 1,
@@ -833,7 +832,6 @@ class BookmarkFileServiceTest extends TestCase
833 ); 832 );
834 $this->assertEquals( 833 $this->assertEquals(
835 [ 834 [
836 'web' => 1,
837 'html' => 1, 835 'html' => 1,
838 'w3c' => 1, 836 'w3c' => 1,
839 'css' => 1, 837 'css' => 1,
@@ -968,7 +966,6 @@ class BookmarkFileServiceTest extends TestCase
968 public function testCountLinkPerTagAllWithFilter() 966 public function testCountLinkPerTagAllWithFilter()
969 { 967 {
970 $expected = [ 968 $expected = [
971 'gnu' => 2,
972 'hashtag' => 2, 969 'hashtag' => 2,
973 '-exclude' => 1, 970 '-exclude' => 1,
974 '.hidden' => 1, 971 '.hidden' => 1,
@@ -991,7 +988,6 @@ class BookmarkFileServiceTest extends TestCase
991 public function testCountLinkPerTagPublicWithFilter() 988 public function testCountLinkPerTagPublicWithFilter()
992 { 989 {
993 $expected = [ 990 $expected = [
994 'gnu' => 2,
995 'hashtag' => 2, 991 'hashtag' => 2,
996 '-exclude' => 1, 992 '-exclude' => 1,
997 '.hidden' => 1, 993 '.hidden' => 1,
@@ -1015,7 +1011,6 @@ class BookmarkFileServiceTest extends TestCase
1015 { 1011 {
1016 $expected = [ 1012 $expected = [
1017 'cartoon' => 1, 1013 'cartoon' => 1,
1018 'dev' => 1,
1019 'tag1' => 1, 1014 'tag1' => 1,
1020 'tag2' => 1, 1015 'tag2' => 1,
1021 'tag3' => 1, 1016 'tag3' => 1,
diff --git a/tests/front/controller/TagCloudControllerTest.php b/tests/front/controller/TagCloudControllerTest.php
index a76d5835..5cbf06a9 100644
--- a/tests/front/controller/TagCloudControllerTest.php
+++ b/tests/front/controller/TagCloudControllerTest.php
@@ -127,8 +127,8 @@ class TagCloudControllerTest extends TestCase
127 ->expects(static::once()) 127 ->expects(static::once())
128 ->method('bookmarksCountPerTag') 128 ->method('bookmarksCountPerTag')
129 ->with(['ghi', 'def'], BookmarkFilter::$PRIVATE) 129 ->with(['ghi', 'def'], BookmarkFilter::$PRIVATE)
130 ->willReturnCallback(function () use ($allTags): array { 130 ->willReturnCallback(function (): array {
131 return $allTags; 131 return ['abc' => 3];
132 }) 132 })
133 ; 133 ;
134 134