Fix broken route to filter not tagged bookmarks

Also display the filter for visitors.

Fixes #1529
This commit is contained in:
ArthurHoaro 2020-08-31 13:58:09 +02:00
parent bea062149e
commit 63b0059ed5
4 changed files with 31 additions and 29 deletions

View file

@ -183,7 +183,6 @@ public function logout()
unset($this->session['expires_on']); unset($this->session['expires_on']);
unset($this->session['username']); unset($this->session['username']);
unset($this->session['visibility']); unset($this->session['visibility']);
unset($this->session['untaggedonly']);
} }
} }

View file

@ -95,7 +95,7 @@
$this->get('/add-tag/{newTag}', '\Shaarli\Front\Controller\Visitor\TagController:addTag'); $this->get('/add-tag/{newTag}', '\Shaarli\Front\Controller\Visitor\TagController:addTag');
$this->get('/remove-tag/{tag}', '\Shaarli\Front\Controller\Visitor\TagController:removeTag'); $this->get('/remove-tag/{tag}', '\Shaarli\Front\Controller\Visitor\TagController:removeTag');
$this->get('/links-per-page', '\Shaarli\Front\Controller\Visitor\PublicSessionFilterController:linksPerPage'); $this->get('/links-per-page', '\Shaarli\Front\Controller\Visitor\PublicSessionFilterController:linksPerPage');
$this->get('/untagged-only', '\Shaarli\Front\Controller\Admin\PublicSessionFilterController:untaggedOnly'); $this->get('/untagged-only', '\Shaarli\Front\Controller\Visitor\PublicSessionFilterController:untaggedOnly');
})->add('\Shaarli\Front\ShaarliMiddleware'); })->add('\Shaarli\Front\ShaarliMiddleware');
$app->group('/admin', function () { $app->group('/admin', function () {

View file

@ -207,15 +207,16 @@ public function testLogout()
'expires_on' => time() + 1000, 'expires_on' => time() + 1000,
'username' => 'johndoe', 'username' => 'johndoe',
'visibility' => 'public', 'visibility' => 'public',
'untaggedonly' => false, 'untaggedonly' => true,
]; ];
$this->sessionManager->logout(); $this->sessionManager->logout();
$this->assertFalse(isset($this->session['ip'])); $this->assertArrayNotHasKey('ip', $this->session);
$this->assertFalse(isset($this->session['expires_on'])); $this->assertArrayNotHasKey('expires_on', $this->session);
$this->assertFalse(isset($this->session['username'])); $this->assertArrayNotHasKey('username', $this->session);
$this->assertFalse(isset($this->session['visibility'])); $this->assertArrayNotHasKey('visibility', $this->session);
$this->assertFalse(isset($this->session['untaggedonly'])); $this->assertArrayHasKey('untaggedonly', $this->session);
$this->assertTrue($this->session['untaggedonly']);
} }
/** /**

View file

@ -1,27 +1,29 @@
<div class="linklist-paging"> <div class="linklist-paging">
<div class="paging pure-g"> <div class="paging pure-g">
<div class="linklist-filters pure-u-1-3"> <div class="linklist-filters pure-u-1-3">
{if="$is_logged_in or !empty($action_plugin)"} <span class="linklist-filters-text pure-u-0 pure-u-lg-visible">
<span class="linklist-filters-text pure-u-0 pure-u-lg-visible"> {'Filters'|t}
{'Filters'|t} </span>
</span> {if="$is_logged_in"}
{if="$is_logged_in"} <a href="{$base_path}/admin/visibility/private" aria-label="{'Only display private links'|t}" title="{'Only display private links'|t}"
<a href="{$base_path}/admin/visibility/private" aria-label="{'Only display private links'|t}" title="{'Only display private links'|t}" class="{if="$visibility==='private'"}filter-on{else}filter-off{/if}"
class="{if="$visibility==='private'"}filter-on{else}filter-off{/if}" ><i class="fa fa-user-secret" aria-hidden="true"></i></a>
><i class="fa fa-user-secret" aria-hidden="true"></i></a> <a href="{$base_path}/admin/visibility/public" aria-label="{'Only display public links'|t}" title="{'Only display public links'|t}"
<a href="{$base_path}/admin/visibility/public" aria-label="{'Only display public links'|t}" title="{'Only display public links'|t}" class="{if="$visibility==='public'"}filter-on{else}filter-off{/if}"
class="{if="$visibility==='public'"}filter-on{else}filter-off{/if}" ><i class="fa fa-globe" aria-hidden="true"></i></a>
><i class="fa fa-globe" aria-hidden="true"></i></a> {/if}
{/if} <a href="{$base_path}/untagged-only" aria-label="{'Filter untagged links'|t}" title="{'Filter untagged links'|t}"
<a href="{$base_path}/untagged-only" aria-label="{'Filter untagged links'|t}" title="{'Filter untagged links'|t}" class={if="$untaggedonly"}"filter-on"{else}"filter-off"{/if}
class={if="$untaggedonly"}"filter-on"{else}"filter-off"{/if} ><i class="fa fa-tag" aria-hidden="true"></i></a>
><i class="fa fa-tag" aria-hidden="true"></i></a> {if="$is_logged_in"}
<a href="#" aria-label="{'Select all'|t}" title="{'Select all'|t}" <a href="#" aria-label="{'Select all'|t}" title="{'Select all'|t}"
class="filter-off select-all-button pure-u-0 pure-u-lg-visible" class="filter-off select-all-button pure-u-0 pure-u-lg-visible"
><i class="fa fa-check-square-o" aria-hidden="true"></i></a> ><i class="fa fa-check-square-o" aria-hidden="true"></i></a>
<a href="#" class="filter-off fold-all pure-u-lg-0" aria-label="{'Fold all'|t}" title="{'Fold all'|t}"> {/if}
<i class="fa fa-chevron-up" aria-hidden="true"></i> <a href="#" class="filter-off fold-all pure-u-lg-0" aria-label="{'Fold all'|t}" title="{'Fold all'|t}">
</a> <i class="fa fa-chevron-up" aria-hidden="true"></i>
</a>
{if="!empty($action_plugin)"}
{loop="$action_plugin"} {loop="$action_plugin"}
{$value.attr.class=isset($value.attr.class) ? $value.attr.class : ''} {$value.attr.class=isset($value.attr.class) ? $value.attr.class : ''}
{$value.attr.class=!empty($value.on) ? $value.attr.class .' filter-on' : $value.attr.class .' filter-off'} {$value.attr.class=!empty($value.on) ? $value.attr.class .' filter-on' : $value.attr.class .' filter-off'}