diff --git a/application/config/ConfigManager.php b/application/config/ConfigManager.php index e45bb4c3..4c98be30 100644 --- a/application/config/ConfigManager.php +++ b/application/config/ConfigManager.php @@ -3,6 +3,7 @@ use Shaarli\Config\Exception\MissingFieldConfigException; use Shaarli\Config\Exception\UnauthorizedConfigException; +use Shaarli\Thumbnailer; /** * Class ConfigManager @@ -361,7 +362,7 @@ protected function setDefaultValues() $this->setEmpty('security.open_shaarli', false); $this->setEmpty('security.allowed_protocols', ['ftp', 'ftps', 'magnet']); - $this->setEmpty('general.header_link', '?'); + $this->setEmpty('general.header_link', '/'); $this->setEmpty('general.links_per_page', 20); $this->setEmpty('general.enabled_plugins', self::$DEFAULT_PLUGINS); $this->setEmpty('general.default_note_title', 'Note: '); @@ -381,6 +382,7 @@ protected function setDefaultValues() // default state of the 'remember me' checkbox of the login form $this->setEmpty('privacy.remember_user_default', true); + $this->setEmpty('thumbnails.mode', Thumbnailer::MODE_ALL); $this->setEmpty('thumbnails.width', '125'); $this->setEmpty('thumbnails.height', '90'); diff --git a/application/container/ContainerBuilder.php b/application/container/ContainerBuilder.php index 593aafb7..bfe93501 100644 --- a/application/container/ContainerBuilder.php +++ b/application/container/ContainerBuilder.php @@ -99,7 +99,6 @@ public function build(): ShaarliContainer $container['pluginManager'] = function (ShaarliContainer $container): PluginManager { $pluginManager = new PluginManager($container->conf); - // FIXME! Configuration is already injected $pluginManager->load($container->conf->get('general.enabled_plugins')); return $pluginManager; diff --git a/application/front/ShaarliMiddleware.php b/application/front/ShaarliMiddleware.php index e9f5552d..fd978e99 100644 --- a/application/front/ShaarliMiddleware.php +++ b/application/front/ShaarliMiddleware.php @@ -56,7 +56,7 @@ public function __invoke(Request $request, Response $response, callable $next): } catch (ShaarliFrontException $e) { // Possible functional error $this->container->pageBuilder->reset(); - $this->container->pageBuilder->assign('message', $e->getMessage()); + $this->container->pageBuilder->assign('message', nl2br($e->getMessage())); $response = $response->withStatus($e->getCode()); diff --git a/application/front/controller/admin/ConfigureController.php b/application/front/controller/admin/ConfigureController.php index 865fc2b0..e675fcca 100644 --- a/application/front/controller/admin/ConfigureController.php +++ b/application/front/controller/admin/ConfigureController.php @@ -98,10 +98,10 @@ public function save(Request $request, Response $response): Response if ($thumbnailsMode !== Thumbnailer::MODE_NONE && $thumbnailsMode !== $this->container->conf->get('thumbnails.mode', Thumbnailer::MODE_NONE) ) { - $this->saveWarningMessage(t( - 'You have enabled or changed thumbnails mode. ' - .'Please synchronize them.' - )); + $this->saveWarningMessage( + t('You have enabled or changed thumbnails mode.') . + '' . t('Please synchronize them.') .'' + ); } $this->container->conf->set('thumbnails.mode', $thumbnailsMode); @@ -110,8 +110,13 @@ public function save(Request $request, Response $response): Response $this->container->history->updateSettings(); $this->container->pageCacheManager->invalidateCaches(); } catch (Throwable $e) { - // TODO: translation + stacktrace - $this->saveErrorMessage('ERROR while writing config file after configuration update.'); + $this->assignView('message', t('Error while writing config file after configuration update.')); + + if ($this->container->conf->get('dev.debug', false)) { + $this->assignView('stacktrace', $e->getMessage() . PHP_EOL . $e->getTraceAsString()); + } + + return $response->write($this->render('error')); } $this->saveSuccessMessage(t('Configuration was saved.')); diff --git a/application/front/controller/visitor/InstallController.php b/application/front/controller/visitor/InstallController.php index aa032860..94ebb4ae 100644 --- a/application/front/controller/visitor/InstallController.php +++ b/application/front/controller/visitor/InstallController.php @@ -128,13 +128,14 @@ public function save(Request $request, Response $response): Response $this->container->conf->get('credentials.salt') ) ); + $this->container->conf->set('general.header_link', $this->container->basePath); try { // Everything is ok, let's create config file. $this->container->conf->write($this->container->loginManager->isLoggedIn()); } catch (\Exception $e) { - $this->assignView('message', $e->getMessage()); - $this->assignView('stacktrace', $e->getTraceAsString()); + $this->assignView('message', t('Error while writing config file after configuration update.')); + $this->assignView('stacktrace', $e->getMessage() . PHP_EOL . $e->getTraceAsString()); return $response->write($this->render('error')); } @@ -155,18 +156,14 @@ protected function checkPermissions(): bool { // Ensure Shaarli has proper access to its resources $errors = ApplicationUtils::checkResourcePermissions($this->container->conf); - if (empty($errors)) { return true; } - // FIXME! Do not insert HTML here. - $message = '
'. t('Insufficient permissions:') .'