Merge pull request #1610 from ArthurHoaro/fix/wallabag

Plugin wallabag: minor improvements
This commit is contained in:
ArthurHoaro 2020-11-03 11:46:54 +01:00 committed by GitHub
commit 38b55fbf3d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 8 deletions

View file

@ -22,6 +22,7 @@ function wallabag_init($conf)
'Please define the "WALLABAG_URL" setting in the plugin administration page.');
return array($error);
}
$conf->setEmpty('plugins.WALLABAG_URL', '2');
}
/**
@ -35,7 +36,7 @@ function wallabag_init($conf)
function hook_wallabag_render_linklist($data, $conf)
{
$wallabagUrl = $conf->get('plugins.WALLABAG_URL');
if (empty($wallabagUrl)) {
if (empty($wallabagUrl) || !$data['_LOGGEDIN_']) {
return $data;
}
@ -51,7 +52,7 @@ function hook_wallabag_render_linklist($data, $conf)
$wallabag = sprintf(
$wallabagHtml,
$wallabagInstance->getWallabagUrl(),
urlencode($value['url']),
urlencode(unescape($value['url'])),
$path,
$linkTitle
);

View file

@ -49,14 +49,15 @@ class PluginWallabagTest extends \Shaarli\TestCase
$conf = new ConfigManager('');
$conf->set('plugins.WALLABAG_URL', 'value');
$str = 'http://randomstr.com/test';
$data = array(
$data = [
'title' => $str,
'links' => array(
array(
'links' => [
[
'url' => $str,
)
)
);
]
],
'_LOGGEDIN_' => true,
];
$data = hook_wallabag_render_linklist($data, $conf);
$link = $data['links'][0];
@ -69,4 +70,26 @@ class PluginWallabagTest extends \Shaarli\TestCase
$this->assertNotFalse(strpos($link['link_plugin'][0], urlencode($str)));
$this->assertNotFalse(strpos($link['link_plugin'][0], $conf->get('plugins.WALLABAG_URL')));
}
/**
* Test render_linklist hook while logged out: no change.
*/
public function testWallabagLinklistLoggedOut(): void
{
$conf = new ConfigManager('');
$str = 'http://randomstr.com/test';
$data = [
'title' => $str,
'links' => [
[
'url' => $str,
]
],
'_LOGGEDIN_' => false,
];
$result = hook_wallabag_render_linklist($data, $conf);
static::assertSame($data, $result);
}
}