From 4cf3564d28dc8e4d08a3e64f09ad045ffbde97ae Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Fri, 25 Sep 2020 13:29:36 +0200 Subject: Add a setting to retrieve bookmark metadata asynchrounously - There is a new standalone script (metadata.js) which requests a new controller to get bookmark metadata and fill the form async - This feature is enabled with the new setting: general.enable_async_metadata (enabled by default) - general.retrieve_description is now enabled by default - A small rotating loader animation has a been added to bookmark inputs when metadata is being retrieved (default template) - Custom JS htmlentities has been removed and mathiasbynens/he library is used instead Fixes #1563 --- application/config/ConfigManager.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'application/config') diff --git a/application/config/ConfigManager.php b/application/config/ConfigManager.php index 4c98be30..fb085023 100644 --- a/application/config/ConfigManager.php +++ b/application/config/ConfigManager.php @@ -366,7 +366,8 @@ class ConfigManager $this->setEmpty('general.links_per_page', 20); $this->setEmpty('general.enabled_plugins', self::$DEFAULT_PLUGINS); $this->setEmpty('general.default_note_title', 'Note: '); - $this->setEmpty('general.retrieve_description', false); + $this->setEmpty('general.retrieve_description', true); + $this->setEmpty('general.enable_async_metadata', true); $this->setEmpty('updates.check_updates', false); $this->setEmpty('updates.check_updates_branch', 'stable'); -- cgit v1.2.3 From 42a72c02fa4b6a5eb9d26a7a3a990e497fc10df3 Mon Sep 17 00:00:00 2001 From: Ganesh Kandu Date: Tue, 27 Oct 2020 17:42:35 +0530 Subject: Replaced PHP_EOL to "\n" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit i was getting error ``` An error occurred while parsing JSON configuration file (data/config.json.php): error code #4 ➜ Syntax error Please check your JSON syntax (without PHP comment tags) using a JSON lint tool such as jsonlint.com. ``` after debug i found ```php $data = str_replace(self::getPhpHeaders(), '', $data); $data = str_replace(self::getPhpSuffix(), '', $data); ``` doesn't removing php header and php suffix cause of this issue was PHP_EOL represents the endline character for the current system. if my ```config.json.php``` was encoded with unix ( LF ) and php running on windows windows encoding ( CR LF ) is not same as unix encoding ( LF ) so ```str_replace``` doesn't replace strin then it causes issue. --- application/config/ConfigJson.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'application/config') diff --git a/application/config/ConfigJson.php b/application/config/ConfigJson.php index c0c0dab9..eaa4ee3f 100644 --- a/application/config/ConfigJson.php +++ b/application/config/ConfigJson.php @@ -73,7 +73,7 @@ class ConfigJson implements ConfigIO */ public static function getPhpHeaders() { - return ''; + return "\n" . '*/ ?>'; } } -- cgit v1.2.3 From e69e3fef7bbdc7299ae01aa0e0258395d2e49818 Mon Sep 17 00:00:00 2001 From: Ganesh Kandu Date: Tue, 27 Oct 2020 18:08:14 +0530 Subject: Removed PHP_EOL just replace "*/ ?>" and "'; + return '*/ ?>'; } } -- cgit v1.2.3 From b3bd8c3e8d367975980043e772f7cd78b7f96bc6 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Thu, 22 Oct 2020 16:21:03 +0200 Subject: Feature: support any tag separator So it allows to have multiple words tags. Breaking change: commas ',' are no longer a default separator. Fixes #594 --- application/config/ConfigManager.php | 1 + 1 file changed, 1 insertion(+) (limited to 'application/config') diff --git a/application/config/ConfigManager.php b/application/config/ConfigManager.php index fb085023..a035baae 100644 --- a/application/config/ConfigManager.php +++ b/application/config/ConfigManager.php @@ -368,6 +368,7 @@ class ConfigManager $this->setEmpty('general.default_note_title', 'Note: '); $this->setEmpty('general.retrieve_description', true); $this->setEmpty('general.enable_async_metadata', true); + $this->setEmpty('general.tags_separator', ' '); $this->setEmpty('updates.check_updates', false); $this->setEmpty('updates.check_updates_branch', 'stable'); -- cgit v1.2.3 From 53054b2bf6a919fd4ff9b44b6ad1986f21f488b6 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 22 Sep 2020 20:25:47 +0200 Subject: Apply PHP Code Beautifier on source code for linter automatic fixes --- application/config/ConfigIO.php | 1 + application/config/ConfigManager.php | 13 +++++----- application/config/ConfigPhp.php | 28 ++++++++++++---------- application/config/ConfigPlugin.php | 8 +++---- .../exception/MissingFieldConfigException.php | 1 - .../exception/UnauthorizedConfigException.php | 1 - 6 files changed, 27 insertions(+), 25 deletions(-) (limited to 'application/config') diff --git a/application/config/ConfigIO.php b/application/config/ConfigIO.php index 3efe5b6f..a623bc8b 100644 --- a/application/config/ConfigIO.php +++ b/application/config/ConfigIO.php @@ -1,4 +1,5 @@ getConfigFileExt()) && !$isLoggedIn) { @@ -392,7 +393,7 @@ class ConfigManager $this->setEmpty('translation.mode', 'php'); $this->setEmpty('translation.extensions', []); - $this->setEmpty('plugins', array()); + $this->setEmpty('plugins', []); $this->setEmpty('formatter', 'markdown'); } diff --git a/application/config/ConfigPhp.php b/application/config/ConfigPhp.php index cad34594..53d6a7a3 100644 --- a/application/config/ConfigPhp.php +++ b/application/config/ConfigPhp.php @@ -1,4 +1,5 @@ legacy key. */ - public static $LEGACY_KEYS_MAPPING = array( + public static $LEGACY_KEYS_MAPPING = [ 'credentials.login' => 'login', 'credentials.hash' => 'hash', 'credentials.salt' => 'salt', @@ -68,7 +69,7 @@ class ConfigPhp implements ConfigIO 'privacy.hide_public_links' => 'config.HIDE_PUBLIC_LINKS', 'privacy.hide_timestamps' => 'config.HIDE_TIMESTAMPS', 'security.open_shaarli' => 'config.OPEN_SHAARLI', - ); + ]; /** * @inheritdoc @@ -76,12 +77,12 @@ class ConfigPhp implements ConfigIO public function read($filepath) { if (! file_exists($filepath) || ! is_readable($filepath)) { - return array(); + return []; } include $filepath; - $out = array(); + $out = []; foreach (self::$ROOT_KEYS as $key) { $out[$key] = isset($GLOBALS[$key]) ? $GLOBALS[$key] : ''; } @@ -95,7 +96,7 @@ class ConfigPhp implements ConfigIO */ public function write($filepath, $conf) { - $configStr = ' $value) { $configStr .= '$GLOBALS[\'config\'][\'' . $key - .'\'] = ' - .var_export($conf['config'][$key], true).';' + . '\'] = ' + . var_export($conf['config'][$key], true) . ';' . PHP_EOL; } @@ -115,18 +116,19 @@ class ConfigPhp implements ConfigIO foreach ($conf['plugins'] as $key => $value) { $configStr .= '$GLOBALS[\'plugins\'][\'' . $key - .'\'] = ' - .var_export($conf['plugins'][$key], true).';' + . '\'] = ' + . var_export($conf['plugins'][$key], true) . ';' . PHP_EOL; } } - if (!file_put_contents($filepath, $configStr) + if ( + !file_put_contents($filepath, $configStr) || strcmp(file_get_contents($filepath), $configStr) != 0 ) { throw new \Shaarli\Exceptions\IOException( $filepath, - t('Shaarli could not create the config file. '. + t('Shaarli could not create the config file. ' . 'Please make sure Shaarli has the right to write in the folder is it installed in.') ); } diff --git a/application/config/ConfigPlugin.php b/application/config/ConfigPlugin.php index ea8dfbda..6cadef12 100644 --- a/application/config/ConfigPlugin.php +++ b/application/config/ConfigPlugin.php @@ -39,8 +39,8 @@ function save_plugin_config($formData) throw new PluginConfigOrderException(); } - $plugins = array(); - $newEnabledPlugins = array(); + $plugins = []; + $newEnabledPlugins = []; foreach ($formData as $key => $data) { if (startsWith($key, 'order')) { continue; @@ -62,7 +62,7 @@ function save_plugin_config($formData) throw new PluginConfigOrderException(); } - $finalPlugins = array(); + $finalPlugins = []; // Make plugins order continuous. foreach ($plugins as $plugin) { $finalPlugins[] = $plugin; @@ -81,7 +81,7 @@ function save_plugin_config($formData) */ function validate_plugin_order($formData) { - $orders = array(); + $orders = []; foreach ($formData as $key => $value) { // No duplicate order allowed. if (in_array($value, $orders, true)) { diff --git a/application/config/exception/MissingFieldConfigException.php b/application/config/exception/MissingFieldConfigException.php index 9e0a9359..a5f4356a 100644 --- a/application/config/exception/MissingFieldConfigException.php +++ b/application/config/exception/MissingFieldConfigException.php @@ -1,6 +1,5 @@ Date: Mon, 9 Nov 2020 14:37:45 +0100 Subject: Server admin: do not retrieve latest version without update_check If the setting 'updates.check_updates' is disabled, do not retrieve the latest version on server administration page. Additionally, updated default values for - updates.check_updates from false to true - updates.check_updates_branch from stable to latest --- application/config/ConfigManager.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'application/config') diff --git a/application/config/ConfigManager.php b/application/config/ConfigManager.php index a035baae..3260d7c0 100644 --- a/application/config/ConfigManager.php +++ b/application/config/ConfigManager.php @@ -370,8 +370,8 @@ class ConfigManager $this->setEmpty('general.enable_async_metadata', true); $this->setEmpty('general.tags_separator', ' '); - $this->setEmpty('updates.check_updates', false); - $this->setEmpty('updates.check_updates_branch', 'stable'); + $this->setEmpty('updates.check_updates', true); + $this->setEmpty('updates.check_updates_branch', 'latest'); $this->setEmpty('updates.check_updates_interval', 86400); $this->setEmpty('feed.rss_permalinks', true); -- cgit v1.2.3