From a120fb2977331e0f7d7ffe05861ba179fdae8764 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Mon, 13 Aug 2018 10:42:27 +0200 Subject: Add OpenGraph meta tags on permalink page Includes: - og:title - og:type -> article - og:image -> if there is a thumbnail - og:url -> permalink - og:description -> first 300 chars of raw description - article:published_time - article:modified_time - article:tag -> one OG meta tag for each shaare tag Fixes #258 --- plugins/markdown/markdown.php | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins') diff --git a/plugins/markdown/markdown.php b/plugins/markdown/markdown.php index 821bb125..d4fb1f76 100644 --- a/plugins/markdown/markdown.php +++ b/plugins/markdown/markdown.php @@ -28,6 +28,7 @@ function hook_markdown_render_linklist($data, $conf) $value = stripNoMarkdownTag($value); continue; } + $value['description_src'] = $value['description']; $value['description'] = process_markdown( $value['description'], $conf->get('security.markdown_escape', true), -- cgit v1.2.3 From cb7940e2deacba66f2510816732be654b255cc70 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 14 Aug 2018 12:26:51 +0200 Subject: Fix hashtags with markdown escape enabled They're now transformed to markdown syntax links before processing them through Parsedown. Fixes #1210 --- plugins/markdown/markdown.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'plugins') diff --git a/plugins/markdown/markdown.php b/plugins/markdown/markdown.php index 821bb125..21972814 100644 --- a/plugins/markdown/markdown.php +++ b/plugins/markdown/markdown.php @@ -215,6 +215,15 @@ function reverse_text2clickable($description) $descriptionLine ); + // Make hashtag links markdown ready, otherwise the links will be ignored with escape set to true + if (!$codeBlockOn && !$codeLineOn) { + $descriptionLine = preg_replace( + '#([^<]+)#m', + '[$2]($1)', + $descriptionLine + ); + } + $descriptionOut .= $descriptionLine; if ($lineCount++ < count($descriptionLines) - 1) { $descriptionOut .= PHP_EOL; -- cgit v1.2.3 From 0e54e1059f3c3aa353a448567a9314ad694abbe1 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 14 Aug 2018 13:39:31 +0200 Subject: Isso plugin: add an icon in linklist if enabled Fixes #1075 --- plugins/isso/comment.png | Bin 0 -> 277 bytes plugins/isso/isso.php | 31 +++++++++++++++++++++++++++++-- plugins/isso/isso_button.html | 5 +++++ 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 plugins/isso/comment.png create mode 100644 plugins/isso/isso_button.html (limited to 'plugins') diff --git a/plugins/isso/comment.png b/plugins/isso/comment.png new file mode 100644 index 00000000..0158c03b Binary files /dev/null and b/plugins/isso/comment.png 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) $isso = sprintf($issoHtml, $issoUrl, $issoUrl, $link['id'], $link['id']); $data['plugin_end_zone'][] = $isso; + } else { + $button = ''; + // For the default theme we use a FontAwesome icon which is better than an image + if ($conf->get('resource.theme') === 'default') { + $button .= ''; + } else { + $button .= ' + + archive.org + + -- cgit v1.2.3 From a0ab3c3f68ed3bca7d218e6e5847820b82b086ca Mon Sep 17 00:00:00 2001 From: VirtualTam Date: Sat, 13 Oct 2018 00:22:45 +0200 Subject: lint: apply phpcbf to plugins/ Signed-off-by: VirtualTam --- plugins/archiveorg/archiveorg.php | 2 +- plugins/demo_plugin/demo_plugin.php | 4 +--- plugins/markdown/markdown.php | 16 +++++++++------- plugins/pubsubhubbub/pubsubhubbub.php | 5 +++-- plugins/qrcode/qrcode.php | 3 ++- plugins/wallabag/wallabag.php | 1 - 6 files changed, 16 insertions(+), 15 deletions(-) (limited to 'plugins') 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) $archive_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/archiveorg/archiveorg.html'); foreach ($data['links'] as &$value) { - if($value['private'] && preg_match('/^\?[a-zA-Z0-9-_@]{6}($|&|#)/', $value['real_url'])) { + if ($value['private'] && preg_match('/^\?[a-zA-Z0-9-_@]{6}($|&|#)/', $value['real_url'])) { continue; } $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..bdbc719b 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) { // Only execute when linklist is rendered. if ($data['_PAGE_'] == Router::$PAGE_LINKLIST) { - // If loggedin if ($data['_LOGGEDIN_'] === true) { /* @@ -448,8 +447,7 @@ function hook_demo_plugin_render_feed($data) foreach ($data['links'] as &$link) { if ($data['_PAGE_'] == Router::$PAGE_FEED_ATOM) { $link['description'] .= ' - ATOM Feed' ; - } - elseif ($data['_PAGE_'] == Router::$PAGE_FEED_RSS) { + } elseif ($data['_PAGE_'] == Router::$PAGE_FEED_RSS) { $link['description'] .= ' - RSS Feed'; } } diff --git a/plugins/markdown/markdown.php b/plugins/markdown/markdown.php index 08e64dae..8823af91 100644 --- a/plugins/markdown/markdown.php +++ b/plugins/markdown/markdown.php @@ -139,7 +139,6 @@ function hook_markdown_render_includes($data) || $data['_PAGE_'] == Router::$PAGE_DAILY || $data['_PAGE_'] == Router::$PAGE_EDITLINK ) { - $data['css_files'][] = PluginManager::$PLUGINS_PATH . '/markdown/markdown.css'; } @@ -195,8 +194,7 @@ function reverse_text2clickable($description) // Detect and toggle block of code if (!$codeBlockOn) { $codeBlockOn = preg_match('/^```/', $descriptionLine) > 0; - } - elseif (preg_match('/^```/', $descriptionLine) > 0) { + } elseif (preg_match('/^```/', $descriptionLine) > 0) { $codeBlockOn = false; } @@ -302,13 +300,17 @@ function sanitize_html($description) foreach ($escapeTags as $tag) { $description = preg_replace_callback( '#<\s*'. $tag .'[^>]*>(.*]*>)?#is', - function ($match) { return escape($match[0]); }, - $description); + function ($match) { + return escape($match[0]); + }, + $description + ); } $description = preg_replace( '#(<[^>]+\s)on[a-z]*="?[^ "]*"?#is', '$1', - $description); + $description + ); return $description; } @@ -341,7 +343,7 @@ function process_markdown($description, $escape = true, $allowedProtocols = []) ->text($processedDescription); $processedDescription = sanitize_html($processedDescription); - if(!empty($processedDescription)){ + if (!empty($processedDescription)) { $processedDescription = '
'. $processedDescription . '
'; } 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 @@ * PubSub is a protocol which fasten up RSS fetching: * - Every time a new link is posted, Shaarli notify the hub. * - The hub notify all feed subscribers that a new link has been posted. - * - Subscribers retrieve the new link. + * - Subscribers retrieve the new link. */ use pubsubhubbub\publisher\Publisher; @@ -82,7 +82,8 @@ function hook_pubsubhubbub_save_link($data, $conf) * * @throws Exception An error occurred. */ -function nocurl_http_post($url, $postString) { +function nocurl_http_post($url, $postString) +{ $params = array('http' => array( 'method' => 'POST', '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) $qrcode_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/qrcode/qrcode.html'); foreach ($data['links'] as &$value) { - $qrcode = sprintf($qrcode_html, + $qrcode = sprintf( + $qrcode_html, urlencode($value['url']), $value['url'], 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() t('Wallabag API URL'); t('Wallabag API version (1 or 2)'); } - -- cgit v1.2.3 From 9d9f6d75b94aab51067bdfbe50b58b66d1194f6d Mon Sep 17 00:00:00 2001 From: VirtualTam Date: Sat, 13 Oct 2018 01:40:04 +0200 Subject: lint: fix line-length warnings Signed-off-by: VirtualTam --- plugins/demo_plugin/demo_plugin.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'plugins') diff --git a/plugins/demo_plugin/demo_plugin.php b/plugins/demo_plugin/demo_plugin.php index bdbc719b..ca520d15 100644 --- a/plugins/demo_plugin/demo_plugin.php +++ b/plugins/demo_plugin/demo_plugin.php @@ -108,10 +108,10 @@ function hook_demo_plugin_render_header($data) * ], * ] * This example renders as: - *
- * - * - *
+ *
+ * + * + *
*/ $form = array( 'attr' => array( -- cgit v1.2.3