PLUGIN readityourself
Add an icon for each link (linklist) for ReadItYourself
This commit is contained in:
parent
a52e843593
commit
75b69987b3
4 changed files with 39 additions and 0 deletions
BIN
plugins/readityourself/book-open.png
Normal file
BIN
plugins/readityourself/book-open.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 568 B |
3
plugins/readityourself/config.php.dist
Normal file
3
plugins/readityourself/config.php.dist
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$GLOBALS['plugins']['READITYOUSELF_URL'] = 'http://someurl.com';
|
1
plugins/readityourself/readityourself.html
Normal file
1
plugins/readityourself/readityourself.html
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<span><a href="%s?url=%s"><img width="13" height="13" src="%s/readityourself/book-open.png" title="Read with Readityourself" /></a></span>
|
35
plugins/readityourself/readityourself.php
Normal file
35
plugins/readityourself/readityourself.php
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// If we're talking about https://github.com/memiks/readityourself
|
||||||
|
// it seems kinda dead.
|
||||||
|
// Not tested.
|
||||||
|
|
||||||
|
// don't raise unnecessary warnings
|
||||||
|
if (is_file(PluginManager::$PLUGINS_PATH . '/readityourself/config.php')) {
|
||||||
|
include PluginManager::$PLUGINS_PATH . '/readityourself/config.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($GLOBALS['plugins']['READITYOUSELF_URL'])) {
|
||||||
|
header('Content-Type: text/plain; charset=utf-8');
|
||||||
|
echo 'ReadItYourself plugin error: '. PHP_EOL;
|
||||||
|
echo ' Please copy "plugins/readityourself/config.php.dist" to config.php and configure your readityourself URL.'. PHP_EOL;
|
||||||
|
echo ' You can also define "$GLOBALS[\'plugins\'][\'READITYOUSELF_URL\']" in your global Shaarli config.php file.';
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add readityourself icon to link_plugin when rendering linklist.
|
||||||
|
*
|
||||||
|
* @param $data - linklist data.
|
||||||
|
* @return mixed - linklist data with readityourself plugin.
|
||||||
|
*/
|
||||||
|
function hook_readityourself_render_linklist($data) {
|
||||||
|
$readityourself_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/readityourself/readityourself.html');
|
||||||
|
|
||||||
|
foreach ($data['links'] as &$value) {
|
||||||
|
$readityourself = sprintf($readityourself_html, $GLOBALS['plugins']['READITYOUSELF_URL'], $value['url'], PluginManager::$PLUGINS_PATH);
|
||||||
|
$value['link_plugin'][] = $readityourself;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
Loading…
Reference in a new issue