From dfc650aa239d3a2c028d0ba13132ce75b4f4c0b4 Mon Sep 17 00:00:00 2001 From: VirtualTam Date: Mon, 3 Dec 2018 00:08:04 +0100 Subject: namespacing: \Shaarli\Feed\{Cache,CachedPage,FeedBuilder} Signed-off-by: VirtualTam --- plugins/pubsubhubbub/pubsubhubbub.php | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins') diff --git a/plugins/pubsubhubbub/pubsubhubbub.php b/plugins/pubsubhubbub/pubsubhubbub.php index 9f0342a3..1872af8a 100644 --- a/plugins/pubsubhubbub/pubsubhubbub.php +++ b/plugins/pubsubhubbub/pubsubhubbub.php @@ -11,6 +11,7 @@ use pubsubhubbub\publisher\Publisher; use Shaarli\Config\ConfigManager; +use Shaarli\Feed\FeedBuilder; /** * Plugin init function - set the hub to the default appspot one. -- cgit v1.2.3 From a932f486f20f3daf8ad657d8d39a6d6c316e66eb Mon Sep 17 00:00:00 2001 From: VirtualTam Date: Tue, 4 Dec 2018 00:02:17 +0100 Subject: namespacing: \Shaarli\Router Signed-off-by: VirtualTam --- plugins/addlink_toolbar/addlink_toolbar.php | 2 ++ plugins/demo_plugin/demo_plugin.php | 1 + plugins/isso/isso.php | 1 + plugins/markdown/markdown.php | 1 + plugins/playvideos/playvideos.php | 2 ++ plugins/pubsubhubbub/pubsubhubbub.php | 1 + plugins/qrcode/qrcode.php | 2 ++ 7 files changed, 10 insertions(+) (limited to 'plugins') 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 @@ * Adds the addlink input on the linklist page. */ +use Shaarli\Router; + /** * When linklist is displayed, add play videos to header's toolbar. * diff --git a/plugins/demo_plugin/demo_plugin.php b/plugins/demo_plugin/demo_plugin.php index ca520d15..94ce38f8 100644 --- a/plugins/demo_plugin/demo_plugin.php +++ b/plugins/demo_plugin/demo_plugin.php @@ -15,6 +15,7 @@ */ use Shaarli\Config\ConfigManager; +use Shaarli\Router; /** * In the footer hook, there is a working example of a translation extension for Shaarli. diff --git a/plugins/isso/isso.php b/plugins/isso/isso.php index 378c11af..9bdd5909 100644 --- a/plugins/isso/isso.php +++ b/plugins/isso/isso.php @@ -5,6 +5,7 @@ */ use Shaarli\Config\ConfigManager; +use Shaarli\Router; /** * Display an error everywhere if the plugin is enabled without configuration. diff --git a/plugins/markdown/markdown.php b/plugins/markdown/markdown.php index 8823af91..9928a488 100644 --- a/plugins/markdown/markdown.php +++ b/plugins/markdown/markdown.php @@ -7,6 +7,7 @@ */ use Shaarli\Config\ConfigManager; +use Shaarli\Router; /* * If this tag is used on a shaare, the description won't be processed by Parsedown. diff --git a/plugins/playvideos/playvideos.php b/plugins/playvideos/playvideos.php index c6d6b0cc..bb5b9e98 100644 --- a/plugins/playvideos/playvideos.php +++ b/plugins/playvideos/playvideos.php @@ -6,6 +6,8 @@ * Note: this plugin adds jQuery. */ +use Shaarli\Router; + /** * When linklist is displayed, add play videos to header's toolbar. * diff --git a/plugins/pubsubhubbub/pubsubhubbub.php b/plugins/pubsubhubbub/pubsubhubbub.php index 1872af8a..a7bd34c1 100644 --- a/plugins/pubsubhubbub/pubsubhubbub.php +++ b/plugins/pubsubhubbub/pubsubhubbub.php @@ -12,6 +12,7 @@ use pubsubhubbub\publisher\Publisher; use Shaarli\Config\ConfigManager; use Shaarli\Feed\FeedBuilder; +use Shaarli\Router; /** * Plugin init function - set the hub to the default appspot one. diff --git a/plugins/qrcode/qrcode.php b/plugins/qrcode/qrcode.php index 4b59caa0..21908cee 100644 --- a/plugins/qrcode/qrcode.php +++ b/plugins/qrcode/qrcode.php @@ -5,6 +5,8 @@ * Display a QRCode icon in link list. */ +use Shaarli\Router; + /** * Add qrcode icon to link_plugin when rendering linklist. * -- cgit v1.2.3 From e1850388348d4bfdf463a5aa341bc470da79cf32 Mon Sep 17 00:00:00 2001 From: VirtualTam Date: Tue, 4 Dec 2018 00:26:50 +0100 Subject: namespacing: \Shaarli\Plugin\PluginManager Signed-off-by: VirtualTam --- plugins/archiveorg/archiveorg.php | 2 ++ plugins/demo_plugin/demo_plugin.php | 1 + plugins/isso/isso.php | 1 + plugins/markdown/markdown.php | 1 + plugins/piwik/piwik.php | 2 ++ plugins/playvideos/playvideos.php | 1 + plugins/pubsubhubbub/pubsubhubbub.php | 1 + plugins/qrcode/qrcode.php | 1 + plugins/wallabag/wallabag.php | 1 + 9 files changed, 11 insertions(+) (limited to 'plugins') diff --git a/plugins/archiveorg/archiveorg.php b/plugins/archiveorg/archiveorg.php index 5dcea5a6..0ee1c73c 100644 --- a/plugins/archiveorg/archiveorg.php +++ b/plugins/archiveorg/archiveorg.php @@ -5,6 +5,8 @@ * Add an icon in the link list for archive.org. */ +use Shaarli\Plugin\PluginManager; + /** * Add archive.org icon to link_plugin when rendering linklist. * diff --git a/plugins/demo_plugin/demo_plugin.php b/plugins/demo_plugin/demo_plugin.php index 94ce38f8..95ea7fe2 100644 --- a/plugins/demo_plugin/demo_plugin.php +++ b/plugins/demo_plugin/demo_plugin.php @@ -15,6 +15,7 @@ */ use Shaarli\Config\ConfigManager; +use Shaarli\Plugin\PluginManager; use Shaarli\Router; /** diff --git a/plugins/isso/isso.php b/plugins/isso/isso.php index 9bdd5909..dab75dd5 100644 --- a/plugins/isso/isso.php +++ b/plugins/isso/isso.php @@ -5,6 +5,7 @@ */ use Shaarli\Config\ConfigManager; +use Shaarli\Plugin\PluginManager; use Shaarli\Router; /** diff --git a/plugins/markdown/markdown.php b/plugins/markdown/markdown.php index 9928a488..628970d6 100644 --- a/plugins/markdown/markdown.php +++ b/plugins/markdown/markdown.php @@ -7,6 +7,7 @@ */ use Shaarli\Config\ConfigManager; +use Shaarli\Plugin\PluginManager; use Shaarli\Router; /* 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 @@ * Adds tracking code on each page. */ +use Shaarli\Plugin\PluginManager; + /** * Initialization function. * It will be called when the plugin is loaded. diff --git a/plugins/playvideos/playvideos.php b/plugins/playvideos/playvideos.php index bb5b9e98..0341ed59 100644 --- a/plugins/playvideos/playvideos.php +++ b/plugins/playvideos/playvideos.php @@ -6,6 +6,7 @@ * Note: this plugin adds jQuery. */ +use Shaarli\Plugin\PluginManager; use Shaarli\Router; /** diff --git a/plugins/pubsubhubbub/pubsubhubbub.php b/plugins/pubsubhubbub/pubsubhubbub.php index a7bd34c1..2878c050 100644 --- a/plugins/pubsubhubbub/pubsubhubbub.php +++ b/plugins/pubsubhubbub/pubsubhubbub.php @@ -12,6 +12,7 @@ use pubsubhubbub\publisher\Publisher; use Shaarli\Config\ConfigManager; use Shaarli\Feed\FeedBuilder; +use Shaarli\Plugin\PluginManager; use Shaarli\Router; /** diff --git a/plugins/qrcode/qrcode.php b/plugins/qrcode/qrcode.php index 21908cee..34eef8be 100644 --- a/plugins/qrcode/qrcode.php +++ b/plugins/qrcode/qrcode.php @@ -5,6 +5,7 @@ * Display a QRCode icon in link list. */ +use Shaarli\Plugin\PluginManager; use Shaarli\Router; /** diff --git a/plugins/wallabag/wallabag.php b/plugins/wallabag/wallabag.php index a6476c71..5ba1611d 100644 --- a/plugins/wallabag/wallabag.php +++ b/plugins/wallabag/wallabag.php @@ -6,6 +6,7 @@ require_once 'WallabagInstance.php'; use Shaarli\Config\ConfigManager; +use Shaarli\Plugin\PluginManager; /** * Init function, return an error if the server is not set. -- cgit v1.2.3 From 9585441734924cb8ece3924afa5fefb6aa2e2604 Mon Sep 17 00:00:00 2001 From: VirtualTam Date: Tue, 4 Dec 2018 23:17:23 +0100 Subject: namespacing: add plugin tests to \Shaarli\Plugin\[...] Signed-off-by: VirtualTam --- plugins/wallabag/WallabagInstance.php | 1 + plugins/wallabag/wallabag.php | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'plugins') 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 @@ Date: Sat, 25 May 2019 17:00:23 +0200 Subject: Remove QRCode link to an external service --- plugins/qrcode/qrcode.html | 2 +- plugins/qrcode/qrcode.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/qrcode/qrcode.html b/plugins/qrcode/qrcode.html index dc214ed1..a21f7932 100644 --- a/plugins/qrcode/qrcode.html +++ b/plugins/qrcode/qrcode.html @@ -1,5 +1,5 @@ diff --git a/plugins/qrcode/qrcode.php b/plugins/qrcode/qrcode.php index 34eef8be..c1d237d5 100644 --- a/plugins/qrcode/qrcode.php +++ b/plugins/qrcode/qrcode.php @@ -22,7 +22,6 @@ function hook_qrcode_render_linklist($data) foreach ($data['links'] as &$value) { $qrcode = sprintf( $qrcode_html, - urlencode($value['url']), $value['url'], PluginManager::$PLUGINS_PATH ); -- cgit v1.2.3 From a5a0c0399bcfea518330c4bad186da77f89ace6e Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Mon, 8 Jul 2019 23:10:00 +0200 Subject: WIP - Plugin to override default template colors * Adds a new core plugin to override default template colors * Adds a new hook when plugin settings are saved (`save_plugin_parameters`) * Use CSS native variables for main colors instead of SASS variables * Disable SASS sort order rules due to a bug in the plugin Fixes #1312 --- plugins/default_colors/default_colors.css.template | 3 + plugins/default_colors/default_colors.meta | 5 ++ plugins/default_colors/default_colors.php | 68 ++++++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 plugins/default_colors/default_colors.css.template create mode 100644 plugins/default_colors/default_colors.meta create mode 100644 plugins/default_colors/default_colors.php (limited to 'plugins') diff --git a/plugins/default_colors/default_colors.css.template b/plugins/default_colors/default_colors.css.template new file mode 100644 index 00000000..4b269baf --- /dev/null +++ b/plugins/default_colors/default_colors.css.template @@ -0,0 +1,3 @@ +:root { + %s +} diff --git a/plugins/default_colors/default_colors.meta b/plugins/default_colors/default_colors.meta new file mode 100644 index 00000000..108962c6 --- /dev/null +++ b/plugins/default_colors/default_colors.meta @@ -0,0 +1,5 @@ +description="Override default theme colors. Use any CSS valid color." +parameters="DEFAULT_COLORS_MAIN;DEFAULT_COLORS_BACKGROUND;DEFAULT_COLORS_DARK_MAIN" +parameter.DEFAULT_COLORS_MAIN="Main color (navbar green)" +parameter.DEFAULT_COLORS_BACKGROUND="Background color (light grey)" +parameter.DEFAULT_COLORS_DARK_MAIN="Dark main color (e.g. visited links)" diff --git a/plugins/default_colors/default_colors.php b/plugins/default_colors/default_colors.php new file mode 100644 index 00000000..b898814b --- /dev/null +++ b/plugins/default_colors/default_colors.php @@ -0,0 +1,68 @@ + Date: Sat, 13 Jul 2019 10:38:19 +0200 Subject: Default colors plugin - Add unit tests --- plugins/default_colors/default_colors.css.template | 2 +- plugins/default_colors/default_colors.php | 65 ++++++++++++++++++---- 2 files changed, 55 insertions(+), 12 deletions(-) (limited to 'plugins') diff --git a/plugins/default_colors/default_colors.css.template b/plugins/default_colors/default_colors.css.template index 4b269baf..87e22a08 100644 --- a/plugins/default_colors/default_colors.css.template +++ b/plugins/default_colors/default_colors.css.template @@ -1,3 +1,3 @@ :root { - %s +%s } diff --git a/plugins/default_colors/default_colors.php b/plugins/default_colors/default_colors.php index b898814b..1928cc9f 100644 --- a/plugins/default_colors/default_colors.php +++ b/plugins/default_colors/default_colors.php @@ -6,6 +6,7 @@ * Allow users to easily overrides colors of the default theme. */ +use Shaarli\Config\ConfigManager; use Shaarli\Plugin\PluginManager; const DEFAULT_COLORS_PLACEHOLDERS = [ @@ -15,7 +16,32 @@ const DEFAULT_COLORS_PLACEHOLDERS = [ ]; /** - * When plugin parameters are saved + * Display an error if the plugin is active a no color is configured. + * + * @param $conf ConfigManager instance + * + * @return array|null The errors array or null of there is none. + */ +function default_colors_init($conf) +{ + $params = ''; + foreach (DEFAULT_COLORS_PLACEHOLDERS as $placeholder) { + $params .= trim($conf->get('plugins.'. $placeholder, '')); + } + + if (empty($params)) { + $error = t('Default colors plugin error: '. + 'This plugin is active and no custom color is configured.'); + return array($error); + } +} + +/** + * When plugin parameters are saved, we regenerate the custom CSS file with provided settings. + * + * @param array $data $_POST array + * + * @return array Updated $_POST array */ function hook_default_colors_save_plugin_parameters($data) { @@ -27,16 +53,20 @@ function hook_default_colors_save_plugin_parameters($data) ? default_colors_format_css_rule($data, $rule) .';'. PHP_EOL : ''; } - file_put_contents($file, sprintf($template, $content)); + + if (! empty($content)) { + file_put_contents($file, sprintf($template, $content)); + } + return $data; } /** - * When linklist is displayed, include isso CSS file. + * When linklist is displayed, include default_colors CSS file. * * @param array $data - header data. * - * @return mixed - header data with isso CSS file added. + * @return mixed - header data with default_colors CSS file added. */ function hook_default_colors_render_includes($data) { @@ -48,6 +78,26 @@ function hook_default_colors_render_includes($data) return $data; } +/** + * Create a valid CSS rule from parameters settings and plugin parameter. + * + * @param array $data $_POST array + * @param string $parameter Plugin parameter name + * + * @return string CSS rules for the provided parameter and its matching value. + */ +function default_colors_format_css_rule($data, $parameter) +{ + if (empty($data[$parameter])) { + return ''; + } + + $key = str_replace('DEFAULT_COLORS_', '', $parameter); + $key = str_replace('_', '-', strtolower($key)) .'-color'; + return ' --'. $key .': '. $data[$parameter]; +} + + /** * This function is never called, but contains translation calls for GNU gettext extraction. */ @@ -59,10 +109,3 @@ function default_colors_translation() t('Background color (light grey)'); t('Dark main color (e.g. visited links)'); } - -function default_colors_format_css_rule($data, $parameter) -{ - $key = str_replace('DEFAULT_COLORS_', '', $parameter); - $key = str_replace('_', '-', strtolower($key)) .'-color'; - return ' --'. $key .': '. $data[$parameter]; -} -- cgit v1.2.3 From 15a61e59746d138d9386d4ef1df4e0d9961b1774 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sat, 13 Jul 2019 10:44:44 +0200 Subject: Add the new hook save_plugin_parameters to the demo plugin --- plugins/demo_plugin/demo_plugin.meta | 3 +++ plugins/demo_plugin/demo_plugin.php | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) (limited to 'plugins') diff --git a/plugins/demo_plugin/demo_plugin.meta b/plugins/demo_plugin/demo_plugin.meta index b063ecb7..cd616441 100644 --- a/plugins/demo_plugin/demo_plugin.meta +++ b/plugins/demo_plugin/demo_plugin.meta @@ -1 +1,4 @@ description="A demo plugin covering all use cases for template designers and plugin developers." +parameters="DEMO_PLUGIN_PARAMETER;DEMO_PLUGIN_OTHER_PARAMETER" +parameter.DEMO_PLUGIN_PARAMETER="This is a parameter dedicated to the demo plugin. It'll be suffixed." +parameter.DEMO_PLUGIN_OTHER_PARAMETER="Other demo parameter" diff --git a/plugins/demo_plugin/demo_plugin.php b/plugins/demo_plugin/demo_plugin.php index 95ea7fe2..71ba7495 100644 --- a/plugins/demo_plugin/demo_plugin.php +++ b/plugins/demo_plugin/demo_plugin.php @@ -456,6 +456,23 @@ function hook_demo_plugin_render_feed($data) return $data; } +/** + * When plugin parameters are saved. + * + * @param array $data $_POST array + * + * @return array Updated $_POST array + */ +function hook_demo_plugin_save_plugin_parameters($data) +{ + // Here we edit the provided value, but we can use this to generate config files, etc. + if (! empty($data['DEMO_PLUGIN_PARAMETER']) && ! endsWith($data['DEMO_PLUGIN_PARAMETER'], '_SUFFIX')) { + $data['DEMO_PLUGIN_PARAMETER'] .= '_SUFFIX'; + } + + return $data; +} + /** * This function is never called, but contains translation calls for GNU gettext extraction. */ @@ -463,4 +480,6 @@ function demo_dummy_translation() { // meta t('A demo plugin covering all use cases for template designers and plugin developers.'); + t('This is a parameter dedicated to the demo plugin. It\'ll be suffixed.'); + t('Other demo parameter'); } -- cgit v1.2.3