From 7b2ba6ef820335df682fbe3dcfaceef3a62cf4a5 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Mon, 18 May 2020 17:17:36 +0200 Subject: RSS/ATOM feeds: process through Slim controller --- plugins/pubsubhubbub/pubsubhubbub.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/pubsubhubbub/pubsubhubbub.php b/plugins/pubsubhubbub/pubsubhubbub.php index 2878c050..41634dda 100644 --- a/plugins/pubsubhubbub/pubsubhubbub.php +++ b/plugins/pubsubhubbub/pubsubhubbub.php @@ -60,8 +60,8 @@ function hook_pubsubhubbub_render_feed($data, $conf) function hook_pubsubhubbub_save_link($data, $conf) { $feeds = array( - index_url($_SERVER) .'?do=atom', - index_url($_SERVER) .'?do=rss', + index_url($_SERVER) .'feed-atom', + index_url($_SERVER) .'feed-rss', ); $httpPost = function_exists('curl_version') ? false : 'nocurl_http_post'; -- cgit v1.2.3 From 9c75f877935fa6adec951a4d8d32b328aaab314f Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sat, 13 Jun 2020 13:08:01 +0200 Subject: Use multi-level routes for existing controllers instead of 1 level everywhere Also prefix most admin routes with /admin/ --- plugins/pubsubhubbub/pubsubhubbub.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/pubsubhubbub/pubsubhubbub.php b/plugins/pubsubhubbub/pubsubhubbub.php index 41634dda..170f3494 100644 --- a/plugins/pubsubhubbub/pubsubhubbub.php +++ b/plugins/pubsubhubbub/pubsubhubbub.php @@ -60,8 +60,8 @@ function hook_pubsubhubbub_render_feed($data, $conf) function hook_pubsubhubbub_save_link($data, $conf) { $feeds = array( - index_url($_SERVER) .'feed-atom', - index_url($_SERVER) .'feed-rss', + index_url($_SERVER) .'feed/atom', + index_url($_SERVER) .'feed/rss', ); $httpPost = function_exists('curl_version') ? false : 'nocurl_http_post'; -- cgit v1.2.3 From 1b8620b1ad4e2c647ff2d032c8e7c6687b6647a1 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sat, 20 Jun 2020 15:14:24 +0200 Subject: Process plugins administration page through Slim controllers --- plugins/wallabag/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/wallabag/README.md b/plugins/wallabag/README.md index ea21a519..c53a04d9 100644 --- a/plugins/wallabag/README.md +++ b/plugins/wallabag/README.md @@ -21,7 +21,7 @@ The directory structure should look like: To enable the plugin, you can either: - * enable it in the plugins administration page (`?do=pluginadmin`). + * enable it in the plugins administration page (`/admin/plugins`). * add `wallabag` to your list of enabled plugins in `data/config.json.php` (`general.enabled_plugins` section). ### Configuration -- cgit v1.2.3 From 1a8ac737e52cb25a5c346232ee398f5908cee7d7 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Mon, 6 Jul 2020 08:04:35 +0200 Subject: Process main page (linklist) through Slim controller Including a bunch of improvements on the container, and helper used across new controllers. --- plugins/addlink_toolbar/addlink_toolbar.php | 4 ++-- plugins/demo_plugin/demo_plugin.php | 8 ++++---- plugins/isso/isso.php | 4 ++-- plugins/playvideos/playvideos.php | 6 +++--- plugins/pubsubhubbub/pubsubhubbub.php | 4 ++-- plugins/qrcode/qrcode.php | 6 +++--- 6 files changed, 16 insertions(+), 16 deletions(-) (limited to 'plugins') diff --git a/plugins/addlink_toolbar/addlink_toolbar.php b/plugins/addlink_toolbar/addlink_toolbar.php index 8bf4ed46..c3e7abaf 100644 --- a/plugins/addlink_toolbar/addlink_toolbar.php +++ b/plugins/addlink_toolbar/addlink_toolbar.php @@ -5,7 +5,7 @@ * Adds the addlink input on the linklist page. */ -use Shaarli\Router; +use Shaarli\Render\TemplatePage; /** * When linklist is displayed, add play videos to header's toolbar. @@ -16,7 +16,7 @@ use Shaarli\Router; */ function hook_addlink_toolbar_render_header($data) { - if ($data['_PAGE_'] == Router::$PAGE_LINKLIST && $data['_LOGGEDIN_'] === true) { + if ($data['_PAGE_'] == TemplatePage::LINKLIST && $data['_LOGGEDIN_'] === true) { $form = array( 'attr' => array( 'method' => 'GET', diff --git a/plugins/demo_plugin/demo_plugin.php b/plugins/demo_plugin/demo_plugin.php index 8ae1b479..dd73d6a2 100644 --- a/plugins/demo_plugin/demo_plugin.php +++ b/plugins/demo_plugin/demo_plugin.php @@ -16,7 +16,7 @@ use Shaarli\Config\ConfigManager; use Shaarli\Plugin\PluginManager; -use Shaarli\Router; +use Shaarli\Render\TemplatePage; /** * In the footer hook, there is a working example of a translation extension for Shaarli. @@ -74,7 +74,7 @@ function demo_plugin_init($conf) function hook_demo_plugin_render_header($data) { // Only execute when linklist is rendered. - if ($data['_PAGE_'] == Router::$PAGE_LINKLIST) { + if ($data['_PAGE_'] == TemplatePage::LINKLIST) { // If loggedin if ($data['_LOGGEDIN_'] === true) { /* @@ -441,9 +441,9 @@ function hook_demo_plugin_delete_link($data) function hook_demo_plugin_render_feed($data) { foreach ($data['links'] as &$link) { - if ($data['_PAGE_'] == Router::$PAGE_FEED_ATOM) { + if ($data['_PAGE_'] == TemplatePage::FEED_ATOM) { $link['description'] .= ' - ATOM Feed' ; - } elseif ($data['_PAGE_'] == Router::$PAGE_FEED_RSS) { + } elseif ($data['_PAGE_'] == TemplatePage::FEED_RSS) { $link['description'] .= ' - RSS Feed'; } } diff --git a/plugins/isso/isso.php b/plugins/isso/isso.php index dab75dd5..16edd9a6 100644 --- a/plugins/isso/isso.php +++ b/plugins/isso/isso.php @@ -6,7 +6,7 @@ use Shaarli\Config\ConfigManager; use Shaarli\Plugin\PluginManager; -use Shaarli\Router; +use Shaarli\Render\TemplatePage; /** * Display an error everywhere if the plugin is enabled without configuration. @@ -76,7 +76,7 @@ function hook_isso_render_linklist($data, $conf) */ function hook_isso_render_includes($data) { - if ($data['_PAGE_'] == Router::$PAGE_LINKLIST) { + if ($data['_PAGE_'] == TemplatePage::LINKLIST) { $data['css_files'][] = PluginManager::$PLUGINS_PATH . '/isso/isso.css'; } diff --git a/plugins/playvideos/playvideos.php b/plugins/playvideos/playvideos.php index 0341ed59..91a9c1e5 100644 --- a/plugins/playvideos/playvideos.php +++ b/plugins/playvideos/playvideos.php @@ -7,7 +7,7 @@ */ use Shaarli\Plugin\PluginManager; -use Shaarli\Router; +use Shaarli\Render\TemplatePage; /** * When linklist is displayed, add play videos to header's toolbar. @@ -18,7 +18,7 @@ use Shaarli\Router; */ function hook_playvideos_render_header($data) { - if ($data['_PAGE_'] == Router::$PAGE_LINKLIST) { + if ($data['_PAGE_'] == TemplatePage::LINKLIST) { $playvideo = array( 'attr' => array( 'href' => '#', @@ -42,7 +42,7 @@ function hook_playvideos_render_header($data) */ function hook_playvideos_render_footer($data) { - if ($data['_PAGE_'] == Router::$PAGE_LINKLIST) { + if ($data['_PAGE_'] == TemplatePage::LINKLIST) { $data['js_files'][] = PluginManager::$PLUGINS_PATH . '/playvideos/jquery-1.11.2.min.js'; $data['js_files'][] = PluginManager::$PLUGINS_PATH . '/playvideos/youtube_playlist.js'; } diff --git a/plugins/pubsubhubbub/pubsubhubbub.php b/plugins/pubsubhubbub/pubsubhubbub.php index 170f3494..8fe6799c 100644 --- a/plugins/pubsubhubbub/pubsubhubbub.php +++ b/plugins/pubsubhubbub/pubsubhubbub.php @@ -13,7 +13,7 @@ use pubsubhubbub\publisher\Publisher; use Shaarli\Config\ConfigManager; use Shaarli\Feed\FeedBuilder; use Shaarli\Plugin\PluginManager; -use Shaarli\Router; +use Shaarli\Render\TemplatePage; /** * Plugin init function - set the hub to the default appspot one. @@ -41,7 +41,7 @@ function pubsubhubbub_init($conf) */ function hook_pubsubhubbub_render_feed($data, $conf) { - $feedType = $data['_PAGE_'] == Router::$PAGE_FEED_RSS ? FeedBuilder::$FEED_RSS : FeedBuilder::$FEED_ATOM; + $feedType = $data['_PAGE_'] == TemplatePage::FEED_RSS ? FeedBuilder::$FEED_RSS : FeedBuilder::$FEED_ATOM; $template = file_get_contents(PluginManager::$PLUGINS_PATH . '/pubsubhubbub/hub.'. $feedType .'.xml'); $data['feed_plugins_header'][] = sprintf($template, $conf->get('plugins.PUBSUBHUB_URL')); diff --git a/plugins/qrcode/qrcode.php b/plugins/qrcode/qrcode.php index c1d237d5..2ec0cb65 100644 --- a/plugins/qrcode/qrcode.php +++ b/plugins/qrcode/qrcode.php @@ -6,7 +6,7 @@ */ use Shaarli\Plugin\PluginManager; -use Shaarli\Router; +use Shaarli\Render\TemplatePage; /** * Add qrcode icon to link_plugin when rendering linklist. @@ -40,7 +40,7 @@ function hook_qrcode_render_linklist($data) */ function hook_qrcode_render_footer($data) { - if ($data['_PAGE_'] == Router::$PAGE_LINKLIST) { + if ($data['_PAGE_'] == TemplatePage::LINKLIST) { $data['js_files'][] = PluginManager::$PLUGINS_PATH . '/qrcode/shaarli-qrcode.js'; } @@ -56,7 +56,7 @@ function hook_qrcode_render_footer($data) */ function hook_qrcode_render_includes($data) { - if ($data['_PAGE_'] == Router::$PAGE_LINKLIST) { + if ($data['_PAGE_'] == TemplatePage::LINKLIST) { $data['css_files'][] = PluginManager::$PLUGINS_PATH . '/qrcode/qrcode.css'; } -- cgit v1.2.3 From 9fbc42294e7667c5ef19cafa0d1fcfbc1c0f36a9 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sun, 26 Jul 2020 14:43:10 +0200 Subject: New basePath: fix officiel plugin paths and vintage template --- plugins/addlink_toolbar/addlink_toolbar.php | 2 +- plugins/archiveorg/archiveorg.html | 2 +- plugins/archiveorg/archiveorg.php | 3 ++- plugins/demo_plugin/demo_plugin.php | 2 +- plugins/isso/isso_button.html | 5 ----- plugins/qrcode/qrcode.php | 5 +++-- plugins/qrcode/shaarli-qrcode.js | 15 ++++++++------- plugins/wallabag/wallabag.php | 4 +++- 8 files changed, 19 insertions(+), 19 deletions(-) delete mode 100644 plugins/isso/isso_button.html (limited to 'plugins') diff --git a/plugins/addlink_toolbar/addlink_toolbar.php b/plugins/addlink_toolbar/addlink_toolbar.php index c3e7abaf..ab6ed6de 100644 --- a/plugins/addlink_toolbar/addlink_toolbar.php +++ b/plugins/addlink_toolbar/addlink_toolbar.php @@ -20,7 +20,7 @@ function hook_addlink_toolbar_render_header($data) $form = array( 'attr' => array( 'method' => 'GET', - 'action' => '', + 'action' => $data['_BASE_PATH_'] . '/admin/shaare', 'name' => 'addform', 'class' => 'addform', ), diff --git a/plugins/archiveorg/archiveorg.html b/plugins/archiveorg/archiveorg.html index ad501f47..e37d887e 100644 --- a/plugins/archiveorg/archiveorg.html +++ b/plugins/archiveorg/archiveorg.html @@ -1,5 +1,5 @@ - archive.org + archive.org diff --git a/plugins/archiveorg/archiveorg.php b/plugins/archiveorg/archiveorg.php index 0ee1c73c..f26e6129 100644 --- a/plugins/archiveorg/archiveorg.php +++ b/plugins/archiveorg/archiveorg.php @@ -17,12 +17,13 @@ use Shaarli\Plugin\PluginManager; function hook_archiveorg_render_linklist($data) { $archive_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/archiveorg/archiveorg.html'); + $path = ($data['_BASE_PATH_'] ?? '') . '/' . PluginManager::$PLUGINS_PATH; foreach ($data['links'] as &$value) { 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')); + $archive = sprintf($archive_html, $value['url'], $path, t('View on archive.org')); $value['link_plugin'][] = $archive; } diff --git a/plugins/demo_plugin/demo_plugin.php b/plugins/demo_plugin/demo_plugin.php index dd73d6a2..defb01f7 100644 --- a/plugins/demo_plugin/demo_plugin.php +++ b/plugins/demo_plugin/demo_plugin.php @@ -118,7 +118,7 @@ function hook_demo_plugin_render_header($data) $form = array( 'attr' => array( 'method' => 'GET', - 'action' => '?', + 'action' => $data['_BASE_PATH_'] . '/', 'class' => 'addform', ), 'inputs' => array( diff --git a/plugins/isso/isso_button.html b/plugins/isso/isso_button.html deleted file mode 100644 index 3f828480..00000000 --- a/plugins/isso/isso_button.html +++ /dev/null @@ -1,5 +0,0 @@ - - - archive.org - - diff --git a/plugins/qrcode/qrcode.php b/plugins/qrcode/qrcode.php index 2ec0cb65..3b5dae34 100644 --- a/plugins/qrcode/qrcode.php +++ b/plugins/qrcode/qrcode.php @@ -19,11 +19,12 @@ function hook_qrcode_render_linklist($data) { $qrcode_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/qrcode/qrcode.html'); + $path = ($data['_BASE_PATH_'] ?? '') . '/' . PluginManager::$PLUGINS_PATH; foreach ($data['links'] as &$value) { $qrcode = sprintf( $qrcode_html, $value['url'], - PluginManager::$PLUGINS_PATH + $path ); $value['link_plugin'][] = $qrcode; } @@ -41,7 +42,7 @@ function hook_qrcode_render_linklist($data) function hook_qrcode_render_footer($data) { if ($data['_PAGE_'] == TemplatePage::LINKLIST) { - $data['js_files'][] = PluginManager::$PLUGINS_PATH . '/qrcode/shaarli-qrcode.js'; + $data['js_files'][] = PluginManager::$PLUGINS_PATH . '/qrcode/shaarli-qrcode.js'; } return $data; diff --git a/plugins/qrcode/shaarli-qrcode.js b/plugins/qrcode/shaarli-qrcode.js index fe77c4cd..3316d6f6 100644 --- a/plugins/qrcode/shaarli-qrcode.js +++ b/plugins/qrcode/shaarli-qrcode.js @@ -28,14 +28,15 @@ // Show the QR-Code of a permalink (when the QR-Code icon is clicked). function showQrCode(caller,loading) -{ +{ // Dynamic javascript lib loading: We only load qr.js if the QR code icon is clicked: if (typeof(qr) == 'undefined') // Load qr.js only if not present. { if (!loading) // If javascript lib is still loading, do not append script to body. { - var element = document.createElement("script"); - element.src = "plugins/qrcode/qr-1.1.3.min.js"; + var basePath = document.querySelector('input[name="js_base_path"]').value; + var element = document.createElement("script"); + element.src = basePath + "/plugins/qrcode/qr-1.1.3.min.js"; document.body.appendChild(element); } setTimeout(function() { showQrCode(caller,true);}, 200); // Retry in 200 milliseconds. @@ -44,7 +45,7 @@ function showQrCode(caller,loading) // Remove previous qrcode if present. removeQrcode(); - + // Build the div which contains the QR-Code: var element = document.createElement('div'); element.id = 'permalinkQrcode'; @@ -57,11 +58,11 @@ function showQrCode(caller,loading) // Damn IE element.setAttribute('onclick', 'this.parentNode.removeChild(this);' ); } - + // Build the QR-Code: var image = qr.image({size: 8,value: caller.dataset.permalink}); if (image) - { + { element.appendChild(image); element.innerHTML += "
Click to close"; caller.parentNode.appendChild(element); @@ -87,4 +88,4 @@ function removeQrcode() elem.parentNode.removeChild(elem); } return false; -} \ No newline at end of file +} diff --git a/plugins/wallabag/wallabag.php b/plugins/wallabag/wallabag.php index bc35df08..805c1ad9 100644 --- a/plugins/wallabag/wallabag.php +++ b/plugins/wallabag/wallabag.php @@ -45,12 +45,14 @@ function hook_wallabag_render_linklist($data, $conf) $wallabagHtml = file_get_contents(PluginManager::$PLUGINS_PATH . '/wallabag/wallabag.html'); $linkTitle = t('Save to wallabag'); + $path = ($data['_BASE_PATH_'] ?? '') . '/' . PluginManager::$PLUGINS_PATH; + foreach ($data['links'] as &$value) { $wallabag = sprintf( $wallabagHtml, $wallabagInstance->getWallabagUrl(), urlencode($value['url']), - PluginManager::$PLUGINS_PATH, + $path, $linkTitle ); $value['link_plugin'][] = $wallabag; -- cgit v1.2.3