diff options
author | Arthur <arthur@hoa.ro> | 2015-11-08 12:46:17 +0100 |
---|---|---|
committer | Arthur <arthur@hoa.ro> | 2015-11-08 12:46:17 +0100 |
commit | 66017e28935c72ad4ed037f022483ee5630e7372 (patch) | |
tree | ed7ccfb26cda7cc42cfdeef69557ec071785a47e /plugins/wallabag | |
parent | e760840feaf7eff6b3aae86545ff45231b9e3592 (diff) | |
parent | 1696f6aa07734c7502702cf810c9fdc93532ef56 (diff) | |
download | Shaarli-66017e28935c72ad4ed037f022483ee5630e7372.tar.gz Shaarli-66017e28935c72ad4ed037f022483ee5630e7372.tar.zst Shaarli-66017e28935c72ad4ed037f022483ee5630e7372.zip |
Merge pull request #281 from ArthurHoaro/plugin-wallabag
PLUGIN wallabag
Diffstat (limited to 'plugins/wallabag')
-rw-r--r-- | plugins/wallabag/README.md | 29 | ||||
-rw-r--r-- | plugins/wallabag/config.php.dist | 3 | ||||
-rw-r--r-- | plugins/wallabag/wallabag.html | 1 | ||||
-rw-r--r-- | plugins/wallabag/wallabag.php | 39 | ||||
-rw-r--r-- | plugins/wallabag/wallabag.png | bin | 0 -> 369 bytes |
5 files changed, 72 insertions, 0 deletions
diff --git a/plugins/wallabag/README.md b/plugins/wallabag/README.md new file mode 100644 index 00000000..08e0d44a --- /dev/null +++ b/plugins/wallabag/README.md | |||
@@ -0,0 +1,29 @@ | |||
1 | ## Save to Wallabag plugin for Shaarli | ||
2 | |||
3 | For each link in your Shaarli, adds a button to save the target page in your [wallabag](https://www.wallabag.org/). | ||
4 | |||
5 | ### Installation/configuration | ||
6 | Clone this repository inside your `tpl/plugins/` directory, or download the archive and unpack it there. | ||
7 | The directory structure should look like: | ||
8 | |||
9 | ``` | ||
10 | └── tpl | ||
11 | └── plugins | ||
12 | └── wallabag | ||
13 | ├── README.md | ||
14 | ├── wallabag.html | ||
15 | └── wallabag.png | ||
16 | ``` | ||
17 | |||
18 | To enable the plugin, add `'wallabag'` to your list of enabled plugins in `data/options.php` (`PLUGINS` array) | ||
19 | . This should look like: | ||
20 | |||
21 | ``` | ||
22 | $GLOBALS['config']['PLUGINS'] = array('qrcode', 'any_other_plugin', 'wallabag') | ||
23 | ``` | ||
24 | |||
25 | Then, set the `WALLABAG_URL` variable in `data/options.php` pointing to your wallabag URL. Example: | ||
26 | |||
27 | ``` | ||
28 | $GLOBALS['config']['WALLABAG_URL'] = 'http://demo.wallabag.org' ; //Base URL of your wallabag installation | ||
29 | ``` \ No newline at end of file | ||
diff --git a/plugins/wallabag/config.php.dist b/plugins/wallabag/config.php.dist new file mode 100644 index 00000000..7cf0d303 --- /dev/null +++ b/plugins/wallabag/config.php.dist | |||
@@ -0,0 +1,3 @@ | |||
1 | <?php | ||
2 | |||
3 | $GLOBALS['plugins']['WALLABAG_URL'] = 'https://demo.wallabag.org/'; \ No newline at end of file | ||
diff --git a/plugins/wallabag/wallabag.html b/plugins/wallabag/wallabag.html new file mode 100644 index 00000000..ddcf8126 --- /dev/null +++ b/plugins/wallabag/wallabag.html | |||
@@ -0,0 +1 @@ | |||
<span><a href="%s/?plainurl=%s" target="_blank"><img width="13" height="13" src="%s/wallabag/wallabag.png" title="Save to wallabag" /></a></span> | |||
diff --git a/plugins/wallabag/wallabag.php b/plugins/wallabag/wallabag.php new file mode 100644 index 00000000..024a3d2b --- /dev/null +++ b/plugins/wallabag/wallabag.php | |||
@@ -0,0 +1,39 @@ | |||
1 | <?php | ||
2 | |||
3 | /** | ||
4 | * Plugin Wallabag. | ||
5 | */ | ||
6 | |||
7 | // don't raise unnecessary warnings | ||
8 | if (is_file(PluginManager::$PLUGINS_PATH . '/wallabag/config.php')) { | ||
9 | include PluginManager::$PLUGINS_PATH . '/wallabag/config.php'; | ||
10 | } | ||
11 | |||
12 | if (!isset($GLOBALS['plugins']['WALLABAG_URL'])) { | ||
13 | $GLOBALS['plugins']['errors'][] = 'Wallabag plugin error: '. | ||
14 | 'Please define "$GLOBALS[\'plugins\'][\'WALLABAG_URL\']" '. | ||
15 | 'in "plugins/wallabag/config.php" or in your Shaarli config.php file.'; | ||
16 | } | ||
17 | |||
18 | /** | ||
19 | * Add wallabag icon to link_plugin when rendering linklist. | ||
20 | * | ||
21 | * @param mixed $data - linklist data. | ||
22 | * | ||
23 | * @return mixed - linklist data with wallabag plugin. | ||
24 | */ | ||
25 | function hook_wallabag_render_linklist($data) | ||
26 | { | ||
27 | if (!isset($GLOBALS['plugins']['WALLABAG_URL'])) { | ||
28 | return $data; | ||
29 | } | ||
30 | |||
31 | $wallabag_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/wallabag/wallabag.html'); | ||
32 | |||
33 | foreach ($data['links'] as &$value) { | ||
34 | $wallabag = sprintf($wallabag_html, $GLOBALS['plugins']['WALLABAG_URL'], $value['url'], PluginManager::$PLUGINS_PATH); | ||
35 | $value['link_plugin'][] = $wallabag; | ||
36 | } | ||
37 | |||
38 | return $data; | ||
39 | } | ||
diff --git a/plugins/wallabag/wallabag.png b/plugins/wallabag/wallabag.png new file mode 100644 index 00000000..70aad33b --- /dev/null +++ b/plugins/wallabag/wallabag.png | |||
Binary files differ | |||