aboutsummaryrefslogtreecommitdiffhomepage
path: root/plugins/wallabag
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/wallabag')
-rw-r--r--plugins/wallabag/README.md41
-rw-r--r--plugins/wallabag/config.php.dist4
-rw-r--r--plugins/wallabag/wallabag.html2
-rw-r--r--plugins/wallabag/wallabag.meta4
-rw-r--r--plugins/wallabag/wallabag.php38
5 files changed, 44 insertions, 45 deletions
diff --git a/plugins/wallabag/README.md b/plugins/wallabag/README.md
index 5bc35be1..ea21a519 100644
--- a/plugins/wallabag/README.md
+++ b/plugins/wallabag/README.md
@@ -4,39 +4,34 @@ For each link in your Shaarli, adds a button to save the target page in your [wa
4 4
5### Installation 5### Installation
6 6
7Clone this repository inside your `tpl/plugins/` directory, or download the archive and unpack it there. 7Clone this repository inside your `tpl/plugins/` directory, or download the archive and unpack it there.
8The directory structure should look like: 8The directory structure should look like:
9 9
10``` 10```bash
11└── tpl 11└── tpl
12 └── plugins 12 └── plugins
13    └── wallabag 13 └── wallabag
14    ├── README.md 14 ├── README.md
15 ├── config.php.dist 15 ├── wallabag.html
16    ├── wallabag.html 16 ├── wallabag.meta
17    ├── wallabag.php 17 ├── wallabag.php
18    └── wallabag.png 18 ├── wallabag.php
19 └── WallabagInstance.php
19``` 20```
20 21
21To enable the plugin, add `'wallabag'` to your list of enabled plugins in `data/options.php` (`PLUGINS` array). 22To enable the plugin, you can either:
22This should look like:
23 23
24``` 24 * enable it in the plugins administration page (`?do=pluginadmin`).
25$GLOBALS['config']['PLUGINS'] = array('qrcode', 'any_other_plugin', 'wallabag') 25 * add `wallabag` to your list of enabled plugins in `data/config.json.php` (`general.enabled_plugins` section).
26```
27 26
28### Configuration 27### Configuration
29 28
30Copy `config.php.dist` into `config.php` and setup your instance. 29Go to the plugin administration page, and edit the following settings (with the plugin enabled).
31 30
32*Wallabag instance URL* 31**WALLABAG_URL**: *Wallabag instance URL*
33``` 32Example value: `http://v2.wallabag.org`
34$GLOBALS['config']['WALLABAG_URL'] = 'http://v2.wallabag.org' ;
35```
36 33
37*Wallabag version*: either `1` (for 1.x) or `2` (for 2.x) 34**WALLABAG_VERSION**: *Wallabag version*
38``` 35Value: either `1` (for 1.x) or `2` (for 2.x)
39$GLOBALS['config']['WALLABAG_VERSION'] = 2;
40```
41 36
42> Note: these settings can also be set in `data/config.php`. \ No newline at end of file 37> Note: these settings can also be set in `data/config.json.php`, in the plugins section.
diff --git a/plugins/wallabag/config.php.dist b/plugins/wallabag/config.php.dist
deleted file mode 100644
index a602708f..00000000
--- a/plugins/wallabag/config.php.dist
+++ /dev/null
@@ -1,4 +0,0 @@
1<?php
2
3$GLOBALS['plugins']['WALLABAG_URL'] = 'https://demo.wallabag.org';
4$GLOBALS['plugins']['WALLABAG_VERSION'] = 1; \ No newline at end of file
diff --git a/plugins/wallabag/wallabag.html b/plugins/wallabag/wallabag.html
index c7b1d044..e861536d 100644
--- a/plugins/wallabag/wallabag.html
+++ b/plugins/wallabag/wallabag.html
@@ -1 +1 @@
<span><a href="%s%s" target="_blank"><img class="linklist-plugin-icon" src="%s/wallabag/wallabag.png" title="Save to wallabag" /></a></span> <span><a href="%s%s" target="_blank"><img class="linklist-plugin-icon" src="%s/wallabag/wallabag.png" title="Save to wallabag" alt="wallabag" /></a></span>
diff --git a/plugins/wallabag/wallabag.meta b/plugins/wallabag/wallabag.meta
index 26e1ea63..9c93f81c 100644
--- a/plugins/wallabag/wallabag.meta
+++ b/plugins/wallabag/wallabag.meta
@@ -1,2 +1,4 @@
1description="For each link, add a Wallabag icon to save it in your instance." 1description="For each link, add a Wallabag icon to save it in your instance."
2parameters="WALLABAG_URL;WALLABAG_VERSION" \ No newline at end of file 2parameters="WALLABAG_URL;WALLABAG_VERSION"
3parameter.WALLABAG_URL="Wallabag API URL"
4parameter.WALLABAG_VERSION="Wallabag API version (1 or 2)" \ No newline at end of file
diff --git a/plugins/wallabag/wallabag.php b/plugins/wallabag/wallabag.php
index 0d6fc66d..641e4cc2 100644
--- a/plugins/wallabag/wallabag.php
+++ b/plugins/wallabag/wallabag.php
@@ -6,34 +6,40 @@
6 6
7require_once 'WallabagInstance.php'; 7require_once 'WallabagInstance.php';
8 8
9// don't raise unnecessary warnings 9/**
10if (is_file(PluginManager::$PLUGINS_PATH . '/wallabag/config.php')) { 10 * Init function, return an error if the server is not set.
11 include PluginManager::$PLUGINS_PATH . '/wallabag/config.php'; 11 *
12} 12 * @param $conf ConfigManager instance.
13 13 *
14if (empty($GLOBALS['plugins']['WALLABAG_URL'])) { 14 * @return array Eventual error.
15 $GLOBALS['plugin_errors'][] = 'Wallabag plugin error: '. 15 */
16 'Please define "$GLOBALS[\'plugins\'][\'WALLABAG_URL\']" '. 16function wallabag_init($conf)
17 'in "plugins/wallabag/config.php" or in your Shaarli config.php file.'; 17{
18 $wallabagUrl = $conf->get('plugins.WALLABAG_URL');
19 if (empty($wallabagUrl)) {
20 $error = 'Wallabag plugin error: '.
21 'Please define the "WALLABAG_URL" setting in the plugin administration page.';
22 return array($error);
23 }
18} 24}
19 25
20/** 26/**
21 * Add wallabag icon to link_plugin when rendering linklist. 27 * Add wallabag icon to link_plugin when rendering linklist.
22 * 28 *
23 * @param mixed $data - linklist data. 29 * @param mixed $data Linklist data.
30 * @param ConfigManager $conf Configuration Manager instance.
24 * 31 *
25 * @return mixed - linklist data with wallabag plugin. 32 * @return mixed - linklist data with wallabag plugin.
26 */ 33 */
27function hook_wallabag_render_linklist($data) 34function hook_wallabag_render_linklist($data, $conf)
28{ 35{
29 if (!isset($GLOBALS['plugins']['WALLABAG_URL'])) { 36 $wallabagUrl = $conf->get('plugins.WALLABAG_URL');
37 if (empty($wallabagUrl)) {
30 return $data; 38 return $data;
31 } 39 }
32 40
33 $version = isset($GLOBALS['plugins']['WALLABAG_VERSION']) 41 $version = $conf->get('plugins.WALLABAG_VERSION');
34 ? $GLOBALS['plugins']['WALLABAG_VERSION'] 42 $wallabagInstance = new WallabagInstance($wallabagUrl, $version);
35 : '';
36 $wallabagInstance = new WallabagInstance($GLOBALS['plugins']['WALLABAG_URL'], $version);
37 43
38 $wallabagHtml = file_get_contents(PluginManager::$PLUGINS_PATH . '/wallabag/wallabag.html'); 44 $wallabagHtml = file_get_contents(PluginManager::$PLUGINS_PATH . '/wallabag/wallabag.html');
39 45