diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/addlink_toolbar/addlink_toolbar.php | 2 | ||||
-rw-r--r-- | plugins/archiveorg/archiveorg.php | 4 | ||||
-rw-r--r-- | plugins/demo_plugin/demo_plugin.php | 14 | ||||
-rw-r--r-- | plugins/isso/comment.png | bin | 0 -> 277 bytes | |||
-rw-r--r-- | plugins/isso/isso.php | 33 | ||||
-rw-r--r-- | plugins/isso/isso_button.html | 5 | ||||
-rw-r--r-- | plugins/markdown/markdown.php | 28 | ||||
-rw-r--r-- | plugins/piwik/piwik.php | 2 | ||||
-rw-r--r-- | plugins/playvideos/playvideos.php | 3 | ||||
-rw-r--r-- | plugins/pubsubhubbub/pubsubhubbub.php | 8 | ||||
-rw-r--r-- | plugins/qrcode/qrcode.php | 6 | ||||
-rw-r--r-- | plugins/wallabag/WallabagInstance.php | 1 | ||||
-rw-r--r-- | plugins/wallabag/wallabag.php | 7 |
13 files changed, 89 insertions, 24 deletions
diff --git a/plugins/addlink_toolbar/addlink_toolbar.php b/plugins/addlink_toolbar/addlink_toolbar.php index 8c05a231..8bf4ed46 100644 --- a/plugins/addlink_toolbar/addlink_toolbar.php +++ b/plugins/addlink_toolbar/addlink_toolbar.php | |||
@@ -5,6 +5,8 @@ | |||
5 | * Adds the addlink input on the linklist page. | 5 | * Adds the addlink input on the linklist page. |
6 | */ | 6 | */ |
7 | 7 | ||
8 | use Shaarli\Router; | ||
9 | |||
8 | /** | 10 | /** |
9 | * When linklist is displayed, add play videos to header's toolbar. | 11 | * When linklist is displayed, add play videos to header's toolbar. |
10 | * | 12 | * |
diff --git a/plugins/archiveorg/archiveorg.php b/plugins/archiveorg/archiveorg.php index cda35751..0ee1c73c 100644 --- a/plugins/archiveorg/archiveorg.php +++ b/plugins/archiveorg/archiveorg.php | |||
@@ -5,6 +5,8 @@ | |||
5 | * Add an icon in the link list for archive.org. | 5 | * Add an icon in the link list for archive.org. |
6 | */ | 6 | */ |
7 | 7 | ||
8 | use Shaarli\Plugin\PluginManager; | ||
9 | |||
8 | /** | 10 | /** |
9 | * Add archive.org icon to link_plugin when rendering linklist. | 11 | * Add archive.org icon to link_plugin when rendering linklist. |
10 | * | 12 | * |
@@ -17,7 +19,7 @@ function hook_archiveorg_render_linklist($data) | |||
17 | $archive_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/archiveorg/archiveorg.html'); | 19 | $archive_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/archiveorg/archiveorg.html'); |
18 | 20 | ||
19 | foreach ($data['links'] as &$value) { | 21 | foreach ($data['links'] as &$value) { |
20 | if($value['private'] && preg_match('/^\?[a-zA-Z0-9-_@]{6}($|&|#)/', $value['real_url'])) { | 22 | if ($value['private'] && preg_match('/^\?[a-zA-Z0-9-_@]{6}($|&|#)/', $value['real_url'])) { |
21 | continue; | 23 | continue; |
22 | } | 24 | } |
23 | $archive = sprintf($archive_html, $value['url'], t('View on archive.org')); | 25 | $archive = sprintf($archive_html, $value['url'], t('View on archive.org')); |
diff --git a/plugins/demo_plugin/demo_plugin.php b/plugins/demo_plugin/demo_plugin.php index f3a63b6a..95ea7fe2 100644 --- a/plugins/demo_plugin/demo_plugin.php +++ b/plugins/demo_plugin/demo_plugin.php | |||
@@ -15,6 +15,8 @@ | |||
15 | */ | 15 | */ |
16 | 16 | ||
17 | use Shaarli\Config\ConfigManager; | 17 | use Shaarli\Config\ConfigManager; |
18 | use Shaarli\Plugin\PluginManager; | ||
19 | use Shaarli\Router; | ||
18 | 20 | ||
19 | /** | 21 | /** |
20 | * In the footer hook, there is a working example of a translation extension for Shaarli. | 22 | * In the footer hook, there is a working example of a translation extension for Shaarli. |
@@ -73,7 +75,6 @@ function hook_demo_plugin_render_header($data) | |||
73 | { | 75 | { |
74 | // Only execute when linklist is rendered. | 76 | // Only execute when linklist is rendered. |
75 | if ($data['_PAGE_'] == Router::$PAGE_LINKLIST) { | 77 | if ($data['_PAGE_'] == Router::$PAGE_LINKLIST) { |
76 | |||
77 | // If loggedin | 78 | // If loggedin |
78 | if ($data['_LOGGEDIN_'] === true) { | 79 | if ($data['_LOGGEDIN_'] === true) { |
79 | /* | 80 | /* |
@@ -109,10 +110,10 @@ function hook_demo_plugin_render_header($data) | |||
109 | * ], | 110 | * ], |
110 | * ] | 111 | * ] |
111 | * This example renders as: | 112 | * This example renders as: |
112 | * <form form-attribute-1="form attribute 1 value" form-attribute-2="form attribute 2 value"> | 113 | * <form form-attribute-1="form attribute 1 value" form-attribute-2="form attribute 2 value"> |
113 | * <input input-1-attribute-1="input 1 attribute 1 value" input-1-attribute-2="input 1 attribute 2 value"> | 114 | * <input input-1-attribute-1="input 1 attribute 1 value" input-1-attribute-2="input 1 attribute 2 value"> |
114 | * <input input-2-attribute-1="input 2 attribute 1 value"> | 115 | * <input input-2-attribute-1="input 2 attribute 1 value"> |
115 | * </form> | 116 | * </form> |
116 | */ | 117 | */ |
117 | $form = array( | 118 | $form = array( |
118 | 'attr' => array( | 119 | 'attr' => array( |
@@ -448,8 +449,7 @@ function hook_demo_plugin_render_feed($data) | |||
448 | foreach ($data['links'] as &$link) { | 449 | foreach ($data['links'] as &$link) { |
449 | if ($data['_PAGE_'] == Router::$PAGE_FEED_ATOM) { | 450 | if ($data['_PAGE_'] == Router::$PAGE_FEED_ATOM) { |
450 | $link['description'] .= ' - ATOM Feed' ; | 451 | $link['description'] .= ' - ATOM Feed' ; |
451 | } | 452 | } elseif ($data['_PAGE_'] == Router::$PAGE_FEED_RSS) { |
452 | elseif ($data['_PAGE_'] == Router::$PAGE_FEED_RSS) { | ||
453 | $link['description'] .= ' - RSS Feed'; | 453 | $link['description'] .= ' - RSS Feed'; |
454 | } | 454 | } |
455 | } | 455 | } |
diff --git a/plugins/isso/comment.png b/plugins/isso/comment.png new file mode 100644 index 00000000..0158c03b --- /dev/null +++ b/plugins/isso/comment.png | |||
Binary files differ | |||
diff --git a/plugins/isso/isso.php b/plugins/isso/isso.php index 5bc1cce2..dab75dd5 100644 --- a/plugins/isso/isso.php +++ b/plugins/isso/isso.php | |||
@@ -5,6 +5,8 @@ | |||
5 | */ | 5 | */ |
6 | 6 | ||
7 | use Shaarli\Config\ConfigManager; | 7 | use Shaarli\Config\ConfigManager; |
8 | use Shaarli\Plugin\PluginManager; | ||
9 | use Shaarli\Router; | ||
8 | 10 | ||
9 | /** | 11 | /** |
10 | * Display an error everywhere if the plugin is enabled without configuration. | 12 | * Display an error everywhere if the plugin is enabled without configuration. |
@@ -46,9 +48,36 @@ function hook_isso_render_linklist($data, $conf) | |||
46 | 48 | ||
47 | $isso = sprintf($issoHtml, $issoUrl, $issoUrl, $link['id'], $link['id']); | 49 | $isso = sprintf($issoHtml, $issoUrl, $issoUrl, $link['id'], $link['id']); |
48 | $data['plugin_end_zone'][] = $isso; | 50 | $data['plugin_end_zone'][] = $isso; |
51 | } else { | ||
52 | $button = '<span><a href="?%s#isso-thread">'; | ||
53 | // For the default theme we use a FontAwesome icon which is better than an image | ||
54 | if ($conf->get('resource.theme') === 'default') { | ||
55 | $button .= '<i class="linklist-plugin-icon fa fa-comment"></i>'; | ||
56 | } else { | ||
57 | $button .= '<img class="linklist-plugin-icon" src="plugins/isso/comment.png" '; | ||
58 | $button .= 'title="Comment on this shaare" alt="Comments" />'; | ||
59 | } | ||
60 | $button .= '</a></span>'; | ||
61 | foreach ($data['links'] as &$value) { | ||
62 | $commentLink = sprintf($button, $value['shorturl']); | ||
63 | $value['link_plugin'][] = $commentLink; | ||
64 | } | ||
65 | } | ||
49 | 66 | ||
50 | // Hackish way to include this CSS file only when necessary. | 67 | return $data; |
51 | $data['plugins_includes']['css_files'][] = PluginManager::$PLUGINS_PATH . '/isso/isso.css'; | 68 | } |
69 | |||
70 | /** | ||
71 | * When linklist is displayed, include isso CSS file. | ||
72 | * | ||
73 | * @param array $data - header data. | ||
74 | * | ||
75 | * @return mixed - header data with isso CSS file added. | ||
76 | */ | ||
77 | function hook_isso_render_includes($data) | ||
78 | { | ||
79 | if ($data['_PAGE_'] == Router::$PAGE_LINKLIST) { | ||
80 | $data['css_files'][] = PluginManager::$PLUGINS_PATH . '/isso/isso.css'; | ||
52 | } | 81 | } |
53 | 82 | ||
54 | return $data; | 83 | return $data; |
diff --git a/plugins/isso/isso_button.html b/plugins/isso/isso_button.html new file mode 100644 index 00000000..3f828480 --- /dev/null +++ b/plugins/isso/isso_button.html | |||
@@ -0,0 +1,5 @@ | |||
1 | <span> | ||
2 | <a href="?%s#isso-thread"> | ||
3 | <img class="linklist-plugin-icon" src="plugins/archiveorg/internetarchive.png" title="%s" alt="archive.org" /> | ||
4 | </a> | ||
5 | </span> | ||
diff --git a/plugins/markdown/markdown.php b/plugins/markdown/markdown.php index 821bb125..628970d6 100644 --- a/plugins/markdown/markdown.php +++ b/plugins/markdown/markdown.php | |||
@@ -7,6 +7,8 @@ | |||
7 | */ | 7 | */ |
8 | 8 | ||
9 | use Shaarli\Config\ConfigManager; | 9 | use Shaarli\Config\ConfigManager; |
10 | use Shaarli\Plugin\PluginManager; | ||
11 | use Shaarli\Router; | ||
10 | 12 | ||
11 | /* | 13 | /* |
12 | * If this tag is used on a shaare, the description won't be processed by Parsedown. | 14 | * If this tag is used on a shaare, the description won't be processed by Parsedown. |
@@ -28,6 +30,7 @@ function hook_markdown_render_linklist($data, $conf) | |||
28 | $value = stripNoMarkdownTag($value); | 30 | $value = stripNoMarkdownTag($value); |
29 | continue; | 31 | continue; |
30 | } | 32 | } |
33 | $value['description_src'] = $value['description']; | ||
31 | $value['description'] = process_markdown( | 34 | $value['description'] = process_markdown( |
32 | $value['description'], | 35 | $value['description'], |
33 | $conf->get('security.markdown_escape', true), | 36 | $conf->get('security.markdown_escape', true), |
@@ -138,7 +141,6 @@ function hook_markdown_render_includes($data) | |||
138 | || $data['_PAGE_'] == Router::$PAGE_DAILY | 141 | || $data['_PAGE_'] == Router::$PAGE_DAILY |
139 | || $data['_PAGE_'] == Router::$PAGE_EDITLINK | 142 | || $data['_PAGE_'] == Router::$PAGE_EDITLINK |
140 | ) { | 143 | ) { |
141 | |||
142 | $data['css_files'][] = PluginManager::$PLUGINS_PATH . '/markdown/markdown.css'; | 144 | $data['css_files'][] = PluginManager::$PLUGINS_PATH . '/markdown/markdown.css'; |
143 | } | 145 | } |
144 | 146 | ||
@@ -194,8 +196,7 @@ function reverse_text2clickable($description) | |||
194 | // Detect and toggle block of code | 196 | // Detect and toggle block of code |
195 | if (!$codeBlockOn) { | 197 | if (!$codeBlockOn) { |
196 | $codeBlockOn = preg_match('/^```/', $descriptionLine) > 0; | 198 | $codeBlockOn = preg_match('/^```/', $descriptionLine) > 0; |
197 | } | 199 | } elseif (preg_match('/^```/', $descriptionLine) > 0) { |
198 | elseif (preg_match('/^```/', $descriptionLine) > 0) { | ||
199 | $codeBlockOn = false; | 200 | $codeBlockOn = false; |
200 | } | 201 | } |
201 | 202 | ||
@@ -215,6 +216,15 @@ function reverse_text2clickable($description) | |||
215 | $descriptionLine | 216 | $descriptionLine |
216 | ); | 217 | ); |
217 | 218 | ||
219 | // Make hashtag links markdown ready, otherwise the links will be ignored with escape set to true | ||
220 | if (!$codeBlockOn && !$codeLineOn) { | ||
221 | $descriptionLine = preg_replace( | ||
222 | '#<a href="([^ ]*)"'. $hashtagTitle .'>([^<]+)</a>#m', | ||
223 | '[$2]($1)', | ||
224 | $descriptionLine | ||
225 | ); | ||
226 | } | ||
227 | |||
218 | $descriptionOut .= $descriptionLine; | 228 | $descriptionOut .= $descriptionLine; |
219 | if ($lineCount++ < count($descriptionLines) - 1) { | 229 | if ($lineCount++ < count($descriptionLines) - 1) { |
220 | $descriptionOut .= PHP_EOL; | 230 | $descriptionOut .= PHP_EOL; |
@@ -292,13 +302,17 @@ function sanitize_html($description) | |||
292 | foreach ($escapeTags as $tag) { | 302 | foreach ($escapeTags as $tag) { |
293 | $description = preg_replace_callback( | 303 | $description = preg_replace_callback( |
294 | '#<\s*'. $tag .'[^>]*>(.*</\s*'. $tag .'[^>]*>)?#is', | 304 | '#<\s*'. $tag .'[^>]*>(.*</\s*'. $tag .'[^>]*>)?#is', |
295 | function ($match) { return escape($match[0]); }, | 305 | function ($match) { |
296 | $description); | 306 | return escape($match[0]); |
307 | }, | ||
308 | $description | ||
309 | ); | ||
297 | } | 310 | } |
298 | $description = preg_replace( | 311 | $description = preg_replace( |
299 | '#(<[^>]+\s)on[a-z]*="?[^ "]*"?#is', | 312 | '#(<[^>]+\s)on[a-z]*="?[^ "]*"?#is', |
300 | '$1', | 313 | '$1', |
301 | $description); | 314 | $description |
315 | ); | ||
302 | return $description; | 316 | return $description; |
303 | } | 317 | } |
304 | 318 | ||
@@ -331,7 +345,7 @@ function process_markdown($description, $escape = true, $allowedProtocols = []) | |||
331 | ->text($processedDescription); | 345 | ->text($processedDescription); |
332 | $processedDescription = sanitize_html($processedDescription); | 346 | $processedDescription = sanitize_html($processedDescription); |
333 | 347 | ||
334 | if(!empty($processedDescription)){ | 348 | if (!empty($processedDescription)) { |
335 | $processedDescription = '<div class="markdown">'. $processedDescription . '</div>'; | 349 | $processedDescription = '<div class="markdown">'. $processedDescription . '</div>'; |
336 | } | 350 | } |
337 | 351 | ||
diff --git a/plugins/piwik/piwik.php b/plugins/piwik/piwik.php index ca00c2be..17b1aecc 100644 --- a/plugins/piwik/piwik.php +++ b/plugins/piwik/piwik.php | |||
@@ -4,6 +4,8 @@ | |||
4 | * Adds tracking code on each page. | 4 | * Adds tracking code on each page. |
5 | */ | 5 | */ |
6 | 6 | ||
7 | use Shaarli\Plugin\PluginManager; | ||
8 | |||
7 | /** | 9 | /** |
8 | * Initialization function. | 10 | * Initialization function. |
9 | * It will be called when the plugin is loaded. | 11 | * It will be called when the plugin is loaded. |
diff --git a/plugins/playvideos/playvideos.php b/plugins/playvideos/playvideos.php index c6d6b0cc..0341ed59 100644 --- a/plugins/playvideos/playvideos.php +++ b/plugins/playvideos/playvideos.php | |||
@@ -6,6 +6,9 @@ | |||
6 | * Note: this plugin adds jQuery. | 6 | * Note: this plugin adds jQuery. |
7 | */ | 7 | */ |
8 | 8 | ||
9 | use Shaarli\Plugin\PluginManager; | ||
10 | use Shaarli\Router; | ||
11 | |||
9 | /** | 12 | /** |
10 | * When linklist is displayed, add play videos to header's toolbar. | 13 | * When linklist is displayed, add play videos to header's toolbar. |
11 | * | 14 | * |
diff --git a/plugins/pubsubhubbub/pubsubhubbub.php b/plugins/pubsubhubbub/pubsubhubbub.php index 184b588b..2878c050 100644 --- a/plugins/pubsubhubbub/pubsubhubbub.php +++ b/plugins/pubsubhubbub/pubsubhubbub.php | |||
@@ -6,11 +6,14 @@ | |||
6 | * PubSub is a protocol which fasten up RSS fetching: | 6 | * PubSub is a protocol which fasten up RSS fetching: |
7 | * - Every time a new link is posted, Shaarli notify the hub. | 7 | * - Every time a new link is posted, Shaarli notify the hub. |
8 | * - The hub notify all feed subscribers that a new link has been posted. | 8 | * - The hub notify all feed subscribers that a new link has been posted. |
9 | * - Subscribers retrieve the new link. | 9 | * - Subscribers retrieve the new link. |
10 | */ | 10 | */ |
11 | 11 | ||
12 | use pubsubhubbub\publisher\Publisher; | 12 | use pubsubhubbub\publisher\Publisher; |
13 | use Shaarli\Config\ConfigManager; | 13 | use Shaarli\Config\ConfigManager; |
14 | use Shaarli\Feed\FeedBuilder; | ||
15 | use Shaarli\Plugin\PluginManager; | ||
16 | use Shaarli\Router; | ||
14 | 17 | ||
15 | /** | 18 | /** |
16 | * Plugin init function - set the hub to the default appspot one. | 19 | * Plugin init function - set the hub to the default appspot one. |
@@ -82,7 +85,8 @@ function hook_pubsubhubbub_save_link($data, $conf) | |||
82 | * | 85 | * |
83 | * @throws Exception An error occurred. | 86 | * @throws Exception An error occurred. |
84 | */ | 87 | */ |
85 | function nocurl_http_post($url, $postString) { | 88 | function nocurl_http_post($url, $postString) |
89 | { | ||
86 | $params = array('http' => array( | 90 | $params = array('http' => array( |
87 | 'method' => 'POST', | 91 | 'method' => 'POST', |
88 | 'content' => $postString, | 92 | 'content' => $postString, |
diff --git a/plugins/qrcode/qrcode.php b/plugins/qrcode/qrcode.php index 0f96a106..34eef8be 100644 --- a/plugins/qrcode/qrcode.php +++ b/plugins/qrcode/qrcode.php | |||
@@ -5,6 +5,9 @@ | |||
5 | * Display a QRCode icon in link list. | 5 | * Display a QRCode icon in link list. |
6 | */ | 6 | */ |
7 | 7 | ||
8 | use Shaarli\Plugin\PluginManager; | ||
9 | use Shaarli\Router; | ||
10 | |||
8 | /** | 11 | /** |
9 | * Add qrcode icon to link_plugin when rendering linklist. | 12 | * Add qrcode icon to link_plugin when rendering linklist. |
10 | * | 13 | * |
@@ -17,7 +20,8 @@ function hook_qrcode_render_linklist($data) | |||
17 | $qrcode_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/qrcode/qrcode.html'); | 20 | $qrcode_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/qrcode/qrcode.html'); |
18 | 21 | ||
19 | foreach ($data['links'] as &$value) { | 22 | foreach ($data['links'] as &$value) { |
20 | $qrcode = sprintf($qrcode_html, | 23 | $qrcode = sprintf( |
24 | $qrcode_html, | ||
21 | urlencode($value['url']), | 25 | urlencode($value['url']), |
22 | $value['url'], | 26 | $value['url'], |
23 | PluginManager::$PLUGINS_PATH | 27 | PluginManager::$PLUGINS_PATH |
diff --git a/plugins/wallabag/WallabagInstance.php b/plugins/wallabag/WallabagInstance.php index eb8ab618..f4a0a92b 100644 --- a/plugins/wallabag/WallabagInstance.php +++ b/plugins/wallabag/WallabagInstance.php | |||
@@ -1,4 +1,5 @@ | |||
1 | <?php | 1 | <?php |
2 | namespace Shaarli\Plugin\Wallabag; | ||
2 | 3 | ||
3 | /** | 4 | /** |
4 | * Class WallabagInstance. | 5 | * Class WallabagInstance. |
diff --git a/plugins/wallabag/wallabag.php b/plugins/wallabag/wallabag.php index 9dfd079e..bc35df08 100644 --- a/plugins/wallabag/wallabag.php +++ b/plugins/wallabag/wallabag.php | |||
@@ -1,11 +1,11 @@ | |||
1 | <?php | 1 | <?php |
2 | |||
3 | /** | 2 | /** |
4 | * Plugin Wallabag. | 3 | * Wallabag plugin |
5 | */ | 4 | */ |
6 | 5 | ||
7 | require_once 'WallabagInstance.php'; | ||
8 | use Shaarli\Config\ConfigManager; | 6 | use Shaarli\Config\ConfigManager; |
7 | use Shaarli\Plugin\PluginManager; | ||
8 | use Shaarli\Plugin\Wallabag\WallabagInstance; | ||
9 | 9 | ||
10 | /** | 10 | /** |
11 | * Init function, return an error if the server is not set. | 11 | * Init function, return an error if the server is not set. |
@@ -69,4 +69,3 @@ function wallabag_dummy_translation() | |||
69 | t('Wallabag API URL'); | 69 | t('Wallabag API URL'); |
70 | t('Wallabag API version (1 or 2)'); | 70 | t('Wallabag API version (1 or 2)'); |
71 | } | 71 | } |
72 | |||