From: ArthurHoaro Date: Thu, 23 Jul 2020 14:41:32 +0000 (+0200) Subject: Multiple small fixes X-Git-Tag: v0.12.0-beta~4^2~14 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=3ee8351e438f13ccf36062ce956e0b4a4d5f4a29;p=github%2Fshaarli%2FShaarli.git Multiple small fixes --- 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 @@ namespace Shaarli\Config; use Shaarli\Config\Exception\MissingFieldConfigException; use Shaarli\Config\Exception\UnauthorizedConfigException; +use Shaarli\Thumbnailer; /** * Class ConfigManager @@ -361,7 +362,7 @@ class ConfigManager $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 @@ class ConfigManager // 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 @@ class ContainerBuilder $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 @@ class ShaarliMiddleware } 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 @@ class ConfigureController extends ShaarliAdminController 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 @@ class ConfigureController extends ShaarliAdminController $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 @@ class InstallController extends ShaarliVisitorController $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 @@ class InstallController extends ShaarliVisitorController { // 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:') .'

'; throw new ResourcePermissionException($message); } diff --git a/application/front/controller/visitor/TagController.php b/application/front/controller/visitor/TagController.php index c176f43f..de4e7ea2 100644 --- a/application/front/controller/visitor/TagController.php +++ b/application/front/controller/visitor/TagController.php @@ -11,8 +11,6 @@ use Slim\Http\Response; * Class TagController * * Slim controller handle tags. - * - * TODO: check redirections with new helper */ class TagController extends ShaarliVisitorController { diff --git a/application/legacy/LegacyUpdater.php b/application/legacy/LegacyUpdater.php index cbf6890f..0ab3a55b 100644 --- a/application/legacy/LegacyUpdater.php +++ b/application/legacy/LegacyUpdater.php @@ -534,7 +534,8 @@ class LegacyUpdater if ($thumbnailsEnabled) { $this->session['warnings'][] = t( - 'You have enabled or changed thumbnails mode. Please synchronize them.' + t('You have enabled or changed thumbnails mode.') . + '' . t('Please synchronize them.') . '' ); } diff --git a/index.php b/index.php index 42b853a4..26e8da8e 100644 --- a/index.php +++ b/index.php @@ -28,7 +28,6 @@ require_once __DIR__ . '/init.php'; use Shaarli\Config\ConfigManager; use Shaarli\Container\ContainerBuilder; use Shaarli\Languages; -use Shaarli\Plugin\PluginManager; use Shaarli\Security\CookieManager; use Shaarli\Security\LoginManager; use Shaarli\Security\SessionManager; @@ -65,9 +64,6 @@ $conf->setEmpty('general.title', t('Shared bookmarks on '). escape(index_url($_S RainTPL::$tpl_dir = $conf->get('resource.raintpl_tpl').'/'.$conf->get('resource.theme').'/'; // template directory RainTPL::$cache_dir = $conf->get('resource.raintpl_tmp'); // cache directory -$pluginManager = new PluginManager($conf); -$pluginManager->load($conf->get('general.enabled_plugins')); - date_default_timezone_set($conf->get('general.timezone', 'UTC')); $loginManager->checkLoginState(client_ip_id($_SERVER)); diff --git a/tests/front/controller/admin/PluginsControllerTest.php b/tests/front/controller/admin/PluginsControllerTest.php index 700a0df2..ad0cda70 100644 --- a/tests/front/controller/admin/PluginsControllerTest.php +++ b/tests/front/controller/admin/PluginsControllerTest.php @@ -162,7 +162,7 @@ class PluginsControllerTest extends TestCase ->method('setSessionParameter') ->with( SessionManager::KEY_ERROR_MESSAGES, - ['ERROR while saving plugin configuration: ' . PHP_EOL . $message] + ['Error while saving plugin configuration: ' . PHP_EOL . $message] ) ; diff --git a/tests/front/controller/visitor/InstallControllerTest.php b/tests/front/controller/visitor/InstallControllerTest.php index 6871fdd9..29c4d7a0 100644 --- a/tests/front/controller/visitor/InstallControllerTest.php +++ b/tests/front/controller/visitor/InstallControllerTest.php @@ -189,6 +189,7 @@ class InstallControllerTest extends TestCase 'updates.check_updates' => true, 'api.enabled' => true, 'api.secret' => '_NOT_EMPTY', + 'general.header_link' => '/subfolder', ]; $request = $this->createMock(Request::class); diff --git a/tpl/default/picwall.html b/tpl/default/picwall.html index 3b5fccc3..b7a56c89 100644 --- a/tpl/default/picwall.html +++ b/tpl/default/picwall.html @@ -9,7 +9,8 @@ {if="count($linksToDisplay)===0 && $is_logged_in"}
- {'There is no cached thumbnail. Try to synchronize them.'|t} + {'There is no cached thumbnail.'|t} + {'Try to synchronize them.'|t}
{/if}