aboutsummaryrefslogtreecommitdiffhomepage
path: root/plugins
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2019-07-27 12:34:30 +0200
committerArthurHoaro <arthur@hoa.ro>2019-07-27 12:34:30 +0200
commit38672ba0d1c722e5d6d33a58255ceb55e9410e46 (patch)
treedae4c7c47532380eac3ae641db99122fc77c93dc /plugins
parent83faedadff76c5bdca036f39f13943f63b27e164 (diff)
parent1e77e0448bbd25675d8c0fe4a73206ad9048904b (diff)
downloadShaarli-38672ba0d1c722e5d6d33a58255ceb55e9410e46.tar.gz
Shaarli-38672ba0d1c722e5d6d33a58255ceb55e9410e46.tar.zst
Shaarli-38672ba0d1c722e5d6d33a58255ceb55e9410e46.zip
Merge tag 'v0.10.4' into stable
Release v0.10.4
Diffstat (limited to 'plugins')
-rw-r--r--plugins/archiveorg/archiveorg.php2
-rw-r--r--plugins/demo_plugin/demo_plugin.php24
-rw-r--r--plugins/isso/comment.pngbin0 -> 277 bytes
-rw-r--r--plugins/isso/isso.php31
-rw-r--r--plugins/isso/isso_button.html5
-rw-r--r--plugins/markdown/markdown.php57
-rw-r--r--plugins/pubsubhubbub/pubsubhubbub.php5
-rw-r--r--plugins/qrcode/qrcode.php3
-rw-r--r--plugins/wallabag/wallabag.php1
9 files changed, 87 insertions, 41 deletions
diff --git a/plugins/archiveorg/archiveorg.php b/plugins/archiveorg/archiveorg.php
index cda35751..5dcea5a6 100644
--- a/plugins/archiveorg/archiveorg.php
+++ b/plugins/archiveorg/archiveorg.php
@@ -17,7 +17,7 @@ function hook_archiveorg_render_linklist($data)
17 $archive_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/archiveorg/archiveorg.html'); 17 $archive_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/archiveorg/archiveorg.html');
18 18
19 foreach ($data['links'] as &$value) { 19 foreach ($data['links'] as &$value) {
20 if($value['private'] && preg_match('/^\?[a-zA-Z0-9-_@]{6}($|&|#)/', $value['real_url'])) { 20 if ($value['private'] && preg_match('/^\?[a-zA-Z0-9-_@]{6}($|&|#)/', $value['real_url'])) {
21 continue; 21 continue;
22 } 22 }
23 $archive = sprintf($archive_html, $value['url'], t('View on archive.org')); 23 $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 b80a2b6d..ca520d15 100644
--- a/plugins/demo_plugin/demo_plugin.php
+++ b/plugins/demo_plugin/demo_plugin.php
@@ -73,7 +73,6 @@ function hook_demo_plugin_render_header($data)
73{ 73{
74 // Only execute when linklist is rendered. 74 // Only execute when linklist is rendered.
75 if ($data['_PAGE_'] == Router::$PAGE_LINKLIST) { 75 if ($data['_PAGE_'] == Router::$PAGE_LINKLIST) {
76
77 // If loggedin 76 // If loggedin
78 if ($data['_LOGGEDIN_'] === true) { 77 if ($data['_LOGGEDIN_'] === true) {
79 /* 78 /*
@@ -109,10 +108,10 @@ function hook_demo_plugin_render_header($data)
109 * ], 108 * ],
110 * ] 109 * ]
111 * This example renders as: 110 * This example renders as:
112 * <form form-attribute-1="form attribute 1 value" form-attribute-2="form attribute 2 value"> 111 * <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"> 112 * <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"> 113 * <input input-2-attribute-1="input 2 attribute 1 value">
115 * </form> 114 * </form>
116 */ 115 */
117 $form = array( 116 $form = array(
118 'attr' => array( 117 'attr' => array(
@@ -378,17 +377,13 @@ function hook_demo_plugin_render_daily($data)
378 377
379 378
380 // Manipulate columns data 379 // Manipulate columns data
381 foreach ($data['cols'] as &$value) { 380 foreach ($data['linksToDisplay'] as &$value) {
382 foreach ($value as &$value2) { 381 $value['formatedDescription'] .= ' ಠ_ಠ';
383 $value2['formatedDescription'] .= ' ಠ_ಠ';
384 }
385 } 382 }
386 383
387 // Add plugin content at the end of each link 384 // Add plugin content at the end of each link
388 foreach ($data['cols'] as &$value) { 385 foreach ($data['linksToDisplay'] as &$value) {
389 foreach ($value as &$value2) { 386 $value['link_plugin'][] = 'DEMO';
390 $value2['link_plugin'][] = 'DEMO';
391 }
392 } 387 }
393 388
394 return $data; 389 return $data;
@@ -452,8 +447,7 @@ function hook_demo_plugin_render_feed($data)
452 foreach ($data['links'] as &$link) { 447 foreach ($data['links'] as &$link) {
453 if ($data['_PAGE_'] == Router::$PAGE_FEED_ATOM) { 448 if ($data['_PAGE_'] == Router::$PAGE_FEED_ATOM) {
454 $link['description'] .= ' - ATOM Feed' ; 449 $link['description'] .= ' - ATOM Feed' ;
455 } 450 } elseif ($data['_PAGE_'] == Router::$PAGE_FEED_RSS) {
456 elseif ($data['_PAGE_'] == Router::$PAGE_FEED_RSS) {
457 $link['description'] .= ' - RSS Feed'; 451 $link['description'] .= ' - RSS Feed';
458 } 452 }
459 } 453 }
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..378c11af 100644
--- a/plugins/isso/isso.php
+++ b/plugins/isso/isso.php
@@ -46,9 +46,36 @@ function hook_isso_render_linklist($data, $conf)
46 46
47 $isso = sprintf($issoHtml, $issoUrl, $issoUrl, $link['id'], $link['id']); 47 $isso = sprintf($issoHtml, $issoUrl, $issoUrl, $link['id'], $link['id']);
48 $data['plugin_end_zone'][] = $isso; 48 $data['plugin_end_zone'][] = $isso;
49 } else {
50 $button = '<span><a href="?%s#isso-thread">';
51 // For the default theme we use a FontAwesome icon which is better than an image
52 if ($conf->get('resource.theme') === 'default') {
53 $button .= '<i class="linklist-plugin-icon fa fa-comment"></i>';
54 } else {
55 $button .= '<img class="linklist-plugin-icon" src="plugins/isso/comment.png" ';
56 $button .= 'title="Comment on this shaare" alt="Comments" />';
57 }
58 $button .= '</a></span>';
59 foreach ($data['links'] as &$value) {
60 $commentLink = sprintf($button, $value['shorturl']);
61 $value['link_plugin'][] = $commentLink;
62 }
63 }
49 64
50 // Hackish way to include this CSS file only when necessary. 65 return $data;
51 $data['plugins_includes']['css_files'][] = PluginManager::$PLUGINS_PATH . '/isso/isso.css'; 66}
67
68/**
69 * When linklist is displayed, include isso CSS file.
70 *
71 * @param array $data - header data.
72 *
73 * @return mixed - header data with isso CSS file added.
74 */
75function hook_isso_render_includes($data)
76{
77 if ($data['_PAGE_'] == Router::$PAGE_LINKLIST) {
78 $data['css_files'][] = PluginManager::$PLUGINS_PATH . '/isso/isso.css';
52 } 79 }
53 80
54 return $data; 81 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 1531549d..8823af91 100644
--- a/plugins/markdown/markdown.php
+++ b/plugins/markdown/markdown.php
@@ -6,6 +6,8 @@
6 * Shaare's descriptions are parsed with Markdown. 6 * Shaare's descriptions are parsed with Markdown.
7 */ 7 */
8 8
9use Shaarli\Config\ConfigManager;
10
9/* 11/*
10 * If this tag is used on a shaare, the description won't be processed by Parsedown. 12 * If this tag is used on a shaare, the description won't be processed by Parsedown.
11 */ 13 */
@@ -26,6 +28,7 @@ function hook_markdown_render_linklist($data, $conf)
26 $value = stripNoMarkdownTag($value); 28 $value = stripNoMarkdownTag($value);
27 continue; 29 continue;
28 } 30 }
31 $value['description_src'] = $value['description'];
29 $value['description'] = process_markdown( 32 $value['description'] = process_markdown(
30 $value['description'], 33 $value['description'],
31 $conf->get('security.markdown_escape', true), 34 $conf->get('security.markdown_escape', true),
@@ -50,6 +53,7 @@ function hook_markdown_render_feed($data, $conf)
50 $value = stripNoMarkdownTag($value); 53 $value = stripNoMarkdownTag($value);
51 continue; 54 continue;
52 } 55 }
56 $value['description'] = reverse_feed_permalink($value['description']);
53 $value['description'] = process_markdown( 57 $value['description'] = process_markdown(
54 $value['description'], 58 $value['description'],
55 $conf->get('security.markdown_escape', true), 59 $conf->get('security.markdown_escape', true),
@@ -70,19 +74,18 @@ function hook_markdown_render_feed($data, $conf)
70 */ 74 */
71function hook_markdown_render_daily($data, $conf) 75function hook_markdown_render_daily($data, $conf)
72{ 76{
77 //var_dump($data);die;
73 // Manipulate columns data 78 // Manipulate columns data
74 foreach ($data['cols'] as &$value) { 79 foreach ($data['linksToDisplay'] as &$value) {
75 foreach ($value as &$value2) { 80 if (!empty($value['tags']) && noMarkdownTag($value['tags'])) {
76 if (!empty($value2['tags']) && noMarkdownTag($value2['tags'])) { 81 $value = stripNoMarkdownTag($value);
77 $value2 = stripNoMarkdownTag($value2); 82 continue;
78 continue;
79 }
80 $value2['formatedDescription'] = process_markdown(
81 $value2['formatedDescription'],
82 $conf->get('security.markdown_escape', true),
83 $conf->get('security.allowed_protocols')
84 );
85 } 83 }
84 $value['formatedDescription'] = process_markdown(
85 $value['formatedDescription'],
86 $conf->get('security.markdown_escape', true),
87 $conf->get('security.allowed_protocols')
88 );
86 } 89 }
87 90
88 return $data; 91 return $data;
@@ -136,7 +139,6 @@ function hook_markdown_render_includes($data)
136 || $data['_PAGE_'] == Router::$PAGE_DAILY 139 || $data['_PAGE_'] == Router::$PAGE_DAILY
137 || $data['_PAGE_'] == Router::$PAGE_EDITLINK 140 || $data['_PAGE_'] == Router::$PAGE_EDITLINK
138 ) { 141 ) {
139
140 $data['css_files'][] = PluginManager::$PLUGINS_PATH . '/markdown/markdown.css'; 142 $data['css_files'][] = PluginManager::$PLUGINS_PATH . '/markdown/markdown.css';
141 } 143 }
142 144
@@ -192,8 +194,7 @@ function reverse_text2clickable($description)
192 // Detect and toggle block of code 194 // Detect and toggle block of code
193 if (!$codeBlockOn) { 195 if (!$codeBlockOn) {
194 $codeBlockOn = preg_match('/^```/', $descriptionLine) > 0; 196 $codeBlockOn = preg_match('/^```/', $descriptionLine) > 0;
195 } 197 } elseif (preg_match('/^```/', $descriptionLine) > 0) {
196 elseif (preg_match('/^```/', $descriptionLine) > 0) {
197 $codeBlockOn = false; 198 $codeBlockOn = false;
198 } 199 }
199 200
@@ -213,6 +214,15 @@ function reverse_text2clickable($description)
213 $descriptionLine 214 $descriptionLine
214 ); 215 );
215 216
217 // Make hashtag links markdown ready, otherwise the links will be ignored with escape set to true
218 if (!$codeBlockOn && !$codeLineOn) {
219 $descriptionLine = preg_replace(
220 '#<a href="([^ ]*)"'. $hashtagTitle .'>([^<]+)</a>#m',
221 '[$2]($1)',
222 $descriptionLine
223 );
224 }
225
216 $descriptionOut .= $descriptionLine; 226 $descriptionOut .= $descriptionLine;
217 if ($lineCount++ < count($descriptionLines) - 1) { 227 if ($lineCount++ < count($descriptionLines) - 1) {
218 $descriptionOut .= PHP_EOL; 228 $descriptionOut .= PHP_EOL;
@@ -245,6 +255,11 @@ function reverse_space2nbsp($description)
245 return preg_replace('/(^| )&nbsp;/m', '$1 ', $description); 255 return preg_replace('/(^| )&nbsp;/m', '$1 ', $description);
246} 256}
247 257
258function reverse_feed_permalink($description)
259{
260 return preg_replace('@&#8212; <a href="([^"]+)" title="[^"]+">(\w+)</a>$@im', '&#8212; [$2]($1)', $description);
261}
262
248/** 263/**
249 * Replace not whitelisted protocols with http:// in given description. 264 * Replace not whitelisted protocols with http:// in given description.
250 * 265 *
@@ -285,13 +300,17 @@ function sanitize_html($description)
285 foreach ($escapeTags as $tag) { 300 foreach ($escapeTags as $tag) {
286 $description = preg_replace_callback( 301 $description = preg_replace_callback(
287 '#<\s*'. $tag .'[^>]*>(.*</\s*'. $tag .'[^>]*>)?#is', 302 '#<\s*'. $tag .'[^>]*>(.*</\s*'. $tag .'[^>]*>)?#is',
288 function ($match) { return escape($match[0]); }, 303 function ($match) {
289 $description); 304 return escape($match[0]);
305 },
306 $description
307 );
290 } 308 }
291 $description = preg_replace( 309 $description = preg_replace(
292 '#(<[^>]+)on[a-z]*="?[^ "]*"?#is', 310 '#(<[^>]+\s)on[a-z]*="?[^ "]*"?#is',
293 '$1', 311 '$1',
294 $description); 312 $description
313 );
295 return $description; 314 return $description;
296} 315}
297 316
@@ -324,7 +343,7 @@ function process_markdown($description, $escape = true, $allowedProtocols = [])
324 ->text($processedDescription); 343 ->text($processedDescription);
325 $processedDescription = sanitize_html($processedDescription); 344 $processedDescription = sanitize_html($processedDescription);
326 345
327 if(!empty($processedDescription)){ 346 if (!empty($processedDescription)) {
328 $processedDescription = '<div class="markdown">'. $processedDescription . '</div>'; 347 $processedDescription = '<div class="markdown">'. $processedDescription . '</div>';
329 } 348 }
330 349
diff --git a/plugins/pubsubhubbub/pubsubhubbub.php b/plugins/pubsubhubbub/pubsubhubbub.php
index 184b588b..9f0342a3 100644
--- a/plugins/pubsubhubbub/pubsubhubbub.php
+++ b/plugins/pubsubhubbub/pubsubhubbub.php
@@ -6,7 +6,7 @@
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
12use pubsubhubbub\publisher\Publisher; 12use pubsubhubbub\publisher\Publisher;
@@ -82,7 +82,8 @@ function hook_pubsubhubbub_save_link($data, $conf)
82 * 82 *
83 * @throws Exception An error occurred. 83 * @throws Exception An error occurred.
84 */ 84 */
85function nocurl_http_post($url, $postString) { 85function nocurl_http_post($url, $postString)
86{
86 $params = array('http' => array( 87 $params = array('http' => array(
87 'method' => 'POST', 88 'method' => 'POST',
88 'content' => $postString, 89 'content' => $postString,
diff --git a/plugins/qrcode/qrcode.php b/plugins/qrcode/qrcode.php
index 0f96a106..4b59caa0 100644
--- a/plugins/qrcode/qrcode.php
+++ b/plugins/qrcode/qrcode.php
@@ -17,7 +17,8 @@ function hook_qrcode_render_linklist($data)
17 $qrcode_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/qrcode/qrcode.html'); 17 $qrcode_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/qrcode/qrcode.html');
18 18
19 foreach ($data['links'] as &$value) { 19 foreach ($data['links'] as &$value) {
20 $qrcode = sprintf($qrcode_html, 20 $qrcode = sprintf(
21 $qrcode_html,
21 urlencode($value['url']), 22 urlencode($value['url']),
22 $value['url'], 23 $value['url'],
23 PluginManager::$PLUGINS_PATH 24 PluginManager::$PLUGINS_PATH
diff --git a/plugins/wallabag/wallabag.php b/plugins/wallabag/wallabag.php
index 9dfd079e..a6476c71 100644
--- a/plugins/wallabag/wallabag.php
+++ b/plugins/wallabag/wallabag.php
@@ -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