From ccd1862d5f6f2c0548473466aaff7ee99f9d67d2 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 19 Jan 2021 10:34:11 +0100 Subject: [PATCH 01/19] Inject current template name in templates Use either legacy key _PAGE_ or new 'template' one. Related to https://github.com/kalvn/Shaarli-Material/issues/118 --- .../front/controller/visitor/ShaarliVisitorController.php | 4 ++++ .../front/controller/visitor/ShaarliVisitorControllerTest.php | 3 +++ 2 files changed, 7 insertions(+) diff --git a/application/front/controller/visitor/ShaarliVisitorController.php b/application/front/controller/visitor/ShaarliVisitorController.php index ae946c59..d3f28f2f 100644 --- a/application/front/controller/visitor/ShaarliVisitorController.php +++ b/application/front/controller/visitor/ShaarliVisitorController.php @@ -56,6 +56,10 @@ protected function assignAllView(array $data): self protected function render(string $template): string { + // Legacy key that used to be injected by PluginManager + $this->assignView('_PAGE_', $template); + $this->assignView('template', $template); + $this->assignView('linkcount', $this->container->bookmarkService->count(BookmarkFilter::$ALL)); $this->assignView('privateLinkcount', $this->container->bookmarkService->count(BookmarkFilter::$PRIVATE)); diff --git a/tests/front/controller/visitor/ShaarliVisitorControllerTest.php b/tests/front/controller/visitor/ShaarliVisitorControllerTest.php index 935ec24e..7676f14d 100644 --- a/tests/front/controller/visitor/ShaarliVisitorControllerTest.php +++ b/tests/front/controller/visitor/ShaarliVisitorControllerTest.php @@ -93,6 +93,9 @@ public function testRender(): void static::assertSame('templateName', $render); + static::assertSame('templateName', $this->assignedValues['_PAGE_']); + static::assertSame('templateName', $this->assignedValues['template']); + static::assertSame(10, $this->assignedValues['linkcount']); static::assertSame(5, $this->assignedValues['privateLinkcount']); static::assertSame(['error'], $this->assignedValues['plugin_errors']); From 9e55beebfdbc7c8db8590792479689322b92a235 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 19 Jan 2021 11:18:56 +0100 Subject: [PATCH 02/19] Fix: error when using bulk shaare with a single URL Make sure that header metadata associated with permalink is only used in linklist template. Fixes #1686 --- tpl/default/includes.html | 2 +- tpl/vintage/includes.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tpl/default/includes.html b/tpl/default/includes.html index 3e3fb664..6be2a2ea 100644 --- a/tpl/default/includes.html +++ b/tpl/default/includes.html @@ -19,7 +19,7 @@ {/if} -{if="! empty($links) && count($links) === 1"} +{if="$template === 'linklist' && ! empty($links) && count($links) === 1"} {$link=reset($links)} diff --git a/tpl/vintage/includes.html b/tpl/vintage/includes.html index 2ce9da42..4fd78467 100644 --- a/tpl/vintage/includes.html +++ b/tpl/vintage/includes.html @@ -16,7 +16,7 @@ {if="is_file('data/user.css')"}{/if} -{if="! empty($links) && count($links) === 1"} +{if="$template === 'linklist' && ! empty($links) && count($links) === 1"} {$link=reset($links)} From 8fbc29de0252c462884605d4f691b6746e524fc9 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 19 Jan 2021 11:35:42 +0100 Subject: [PATCH 03/19] Fix: bulk add - use unique HTML ID Use links loop ID to make ID unique and fix browser labels behaviour. Fixes #1685 --- tpl/default/editlink.batch.html | 1 + tpl/default/editlink.html | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/tpl/default/editlink.batch.html b/tpl/default/editlink.batch.html index b1f8e5bd..973a5ccc 100644 --- a/tpl/default/editlink.batch.html +++ b/tpl/default/editlink.batch.html @@ -20,6 +20,7 @@ {loop="$links"} + {$batchId=$key} {include="editlink"} {/loop} diff --git a/tpl/default/editlink.html b/tpl/default/editlink.html index 83e541fd..a5828c75 100644 --- a/tpl/default/editlink.html +++ b/tpl/default/editlink.html @@ -1,3 +1,4 @@ +{$batchId=isset($batchId) ? $batchId : ''} {if="empty($batch_mode)"} @@ -10,7 +11,7 @@ {ignore}Lil hack: when included in a loop in batch mode, `$value` is assigned by RainTPL with template vars.{/ignore} {function="extract($value) ? '' : ''"} {/if} -