diff options
author | ArthurHoaro <arthur@hoa.ro> | 2015-12-22 10:20:27 +0100 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2015-12-27 15:30:34 +0100 |
commit | 938d9cce77ed5098dd69643795cb4014f3688b35 (patch) | |
tree | b0bbdd80b81e6f54009f0c67631e69020e2f4399 /plugins/wallabag/wallabag.php | |
parent | 79851b489087f8a3027ecd805255cd13ee6fcf63 (diff) | |
download | Shaarli-938d9cce77ed5098dd69643795cb4014f3688b35.tar.gz Shaarli-938d9cce77ed5098dd69643795cb4014f3688b35.tar.zst Shaarli-938d9cce77ed5098dd69643795cb4014f3688b35.zip |
Wallabag plugin improvement
* Fixes a bug where URL weren't properly encoded.
* Adds Wallabag V2 support.
* Adds a URL function to handle trailing slash.
* UT.
* README updated.
Diffstat (limited to 'plugins/wallabag/wallabag.php')
-rw-r--r-- | plugins/wallabag/wallabag.php | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/plugins/wallabag/wallabag.php b/plugins/wallabag/wallabag.php index 37969c97..e3c399a9 100644 --- a/plugins/wallabag/wallabag.php +++ b/plugins/wallabag/wallabag.php | |||
@@ -4,6 +4,8 @@ | |||
4 | * Plugin Wallabag. | 4 | * Plugin Wallabag. |
5 | */ | 5 | */ |
6 | 6 | ||
7 | require_once 'WallabagInstance.php'; | ||
8 | |||
7 | // don't raise unnecessary warnings | 9 | // don't raise unnecessary warnings |
8 | if (is_file(PluginManager::$PLUGINS_PATH . '/wallabag/config.php')) { | 10 | if (is_file(PluginManager::$PLUGINS_PATH . '/wallabag/config.php')) { |
9 | include PluginManager::$PLUGINS_PATH . '/wallabag/config.php'; | 11 | include PluginManager::$PLUGINS_PATH . '/wallabag/config.php'; |
@@ -28,12 +30,23 @@ function hook_wallabag_render_linklist($data) | |||
28 | return $data; | 30 | return $data; |
29 | } | 31 | } |
30 | 32 | ||
31 | $wallabag_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/wallabag/wallabag.html'); | 33 | $version = isset($GLOBALS['plugins']['WALLABAG_VERSION']) |
34 | ? $GLOBALS['plugins']['WALLABAG_VERSION'] | ||
35 | : ''; | ||
36 | $wallabagInstance = new WallabagInstance($GLOBALS['plugins']['WALLABAG_URL'], $version); | ||
37 | |||
38 | $wallabagHtml = file_get_contents(PluginManager::$PLUGINS_PATH . '/wallabag/wallabag.html'); | ||
32 | 39 | ||
33 | foreach ($data['links'] as &$value) { | 40 | foreach ($data['links'] as &$value) { |
34 | $wallabag = sprintf($wallabag_html, $GLOBALS['plugins']['WALLABAG_URL'], $value['url'], PluginManager::$PLUGINS_PATH); | 41 | $wallabag = sprintf( |
42 | $wallabagHtml, | ||
43 | $wallabagInstance->getWallabagUrl(), | ||
44 | urlencode($value['url']), | ||
45 | PluginManager::$PLUGINS_PATH | ||
46 | ); | ||
35 | $value['link_plugin'][] = $wallabag; | 47 | $value['link_plugin'][] = $wallabag; |
36 | } | 48 | } |
37 | 49 | ||
38 | return $data; | 50 | return $data; |
39 | } | 51 | } |
52 | |||