diff options
author | ArthurHoaro <arthur.hoareau@wizacha.com> | 2020-07-23 16:41:32 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2020-07-23 21:19:21 +0200 |
commit | 3ee8351e438f13ccf36062ce956e0b4a4d5f4a29 (patch) | |
tree | 5c5ea281a072e4dffe0b97c12269278c999710df | |
parent | fabff3835da26e6c95cea56b2a01a03749dec7c8 (diff) | |
download | Shaarli-3ee8351e438f13ccf36062ce956e0b4a4d5f4a29.tar.gz Shaarli-3ee8351e438f13ccf36062ce956e0b4a4d5f4a29.tar.zst Shaarli-3ee8351e438f13ccf36062ce956e0b4a4d5f4a29.zip |
Multiple small fixes
-rw-r--r-- | application/config/ConfigManager.php | 4 | ||||
-rw-r--r-- | application/container/ContainerBuilder.php | 1 | ||||
-rw-r--r-- | application/front/ShaarliMiddleware.php | 2 | ||||
-rw-r--r-- | application/front/controller/admin/ConfigureController.php | 17 | ||||
-rw-r--r-- | application/front/controller/visitor/InstallController.php | 13 | ||||
-rw-r--r-- | application/front/controller/visitor/TagController.php | 2 | ||||
-rw-r--r-- | application/legacy/LegacyUpdater.php | 3 | ||||
-rw-r--r-- | index.php | 4 | ||||
-rw-r--r-- | tests/front/controller/admin/PluginsControllerTest.php | 2 | ||||
-rw-r--r-- | tests/front/controller/visitor/InstallControllerTest.php | 1 | ||||
-rw-r--r-- | tpl/default/picwall.html | 3 |
11 files changed, 26 insertions, 26 deletions
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; | |||
3 | 3 | ||
4 | use Shaarli\Config\Exception\MissingFieldConfigException; | 4 | use Shaarli\Config\Exception\MissingFieldConfigException; |
5 | use Shaarli\Config\Exception\UnauthorizedConfigException; | 5 | use Shaarli\Config\Exception\UnauthorizedConfigException; |
6 | use Shaarli\Thumbnailer; | ||
6 | 7 | ||
7 | /** | 8 | /** |
8 | * Class ConfigManager | 9 | * Class ConfigManager |
@@ -361,7 +362,7 @@ class ConfigManager | |||
361 | $this->setEmpty('security.open_shaarli', false); | 362 | $this->setEmpty('security.open_shaarli', false); |
362 | $this->setEmpty('security.allowed_protocols', ['ftp', 'ftps', 'magnet']); | 363 | $this->setEmpty('security.allowed_protocols', ['ftp', 'ftps', 'magnet']); |
363 | 364 | ||
364 | $this->setEmpty('general.header_link', '?'); | 365 | $this->setEmpty('general.header_link', '/'); |
365 | $this->setEmpty('general.links_per_page', 20); | 366 | $this->setEmpty('general.links_per_page', 20); |
366 | $this->setEmpty('general.enabled_plugins', self::$DEFAULT_PLUGINS); | 367 | $this->setEmpty('general.enabled_plugins', self::$DEFAULT_PLUGINS); |
367 | $this->setEmpty('general.default_note_title', 'Note: '); | 368 | $this->setEmpty('general.default_note_title', 'Note: '); |
@@ -381,6 +382,7 @@ class ConfigManager | |||
381 | // default state of the 'remember me' checkbox of the login form | 382 | // default state of the 'remember me' checkbox of the login form |
382 | $this->setEmpty('privacy.remember_user_default', true); | 383 | $this->setEmpty('privacy.remember_user_default', true); |
383 | 384 | ||
385 | $this->setEmpty('thumbnails.mode', Thumbnailer::MODE_ALL); | ||
384 | $this->setEmpty('thumbnails.width', '125'); | 386 | $this->setEmpty('thumbnails.width', '125'); |
385 | $this->setEmpty('thumbnails.height', '90'); | 387 | $this->setEmpty('thumbnails.height', '90'); |
386 | 388 | ||
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 | |||
99 | $container['pluginManager'] = function (ShaarliContainer $container): PluginManager { | 99 | $container['pluginManager'] = function (ShaarliContainer $container): PluginManager { |
100 | $pluginManager = new PluginManager($container->conf); | 100 | $pluginManager = new PluginManager($container->conf); |
101 | 101 | ||
102 | // FIXME! Configuration is already injected | ||
103 | $pluginManager->load($container->conf->get('general.enabled_plugins')); | 102 | $pluginManager->load($container->conf->get('general.enabled_plugins')); |
104 | 103 | ||
105 | return $pluginManager; | 104 | 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 | |||
56 | } catch (ShaarliFrontException $e) { | 56 | } catch (ShaarliFrontException $e) { |
57 | // Possible functional error | 57 | // Possible functional error |
58 | $this->container->pageBuilder->reset(); | 58 | $this->container->pageBuilder->reset(); |
59 | $this->container->pageBuilder->assign('message', $e->getMessage()); | 59 | $this->container->pageBuilder->assign('message', nl2br($e->getMessage())); |
60 | 60 | ||
61 | $response = $response->withStatus($e->getCode()); | 61 | $response = $response->withStatus($e->getCode()); |
62 | 62 | ||
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 | |||
98 | if ($thumbnailsMode !== Thumbnailer::MODE_NONE | 98 | if ($thumbnailsMode !== Thumbnailer::MODE_NONE |
99 | && $thumbnailsMode !== $this->container->conf->get('thumbnails.mode', Thumbnailer::MODE_NONE) | 99 | && $thumbnailsMode !== $this->container->conf->get('thumbnails.mode', Thumbnailer::MODE_NONE) |
100 | ) { | 100 | ) { |
101 | $this->saveWarningMessage(t( | 101 | $this->saveWarningMessage( |
102 | 'You have enabled or changed thumbnails mode. ' | 102 | t('You have enabled or changed thumbnails mode.') . |
103 | .'<a href="'. $this->container->basePath .'/admin/thumbnails">Please synchronize them</a>.' | 103 | '<a href="'. $this->container->basePath .'/admin/thumbnails">' . t('Please synchronize them.') .'</a>' |
104 | )); | 104 | ); |
105 | } | 105 | } |
106 | $this->container->conf->set('thumbnails.mode', $thumbnailsMode); | 106 | $this->container->conf->set('thumbnails.mode', $thumbnailsMode); |
107 | 107 | ||
@@ -110,8 +110,13 @@ class ConfigureController extends ShaarliAdminController | |||
110 | $this->container->history->updateSettings(); | 110 | $this->container->history->updateSettings(); |
111 | $this->container->pageCacheManager->invalidateCaches(); | 111 | $this->container->pageCacheManager->invalidateCaches(); |
112 | } catch (Throwable $e) { | 112 | } catch (Throwable $e) { |
113 | // TODO: translation + stacktrace | 113 | $this->assignView('message', t('Error while writing config file after configuration update.')); |
114 | $this->saveErrorMessage('ERROR while writing config file after configuration update.'); | 114 | |
115 | if ($this->container->conf->get('dev.debug', false)) { | ||
116 | $this->assignView('stacktrace', $e->getMessage() . PHP_EOL . $e->getTraceAsString()); | ||
117 | } | ||
118 | |||
119 | return $response->write($this->render('error')); | ||
115 | } | 120 | } |
116 | 121 | ||
117 | $this->saveSuccessMessage(t('Configuration was saved.')); | 122 | $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 | |||
128 | $this->container->conf->get('credentials.salt') | 128 | $this->container->conf->get('credentials.salt') |
129 | ) | 129 | ) |
130 | ); | 130 | ); |
131 | $this->container->conf->set('general.header_link', $this->container->basePath); | ||
131 | 132 | ||
132 | try { | 133 | try { |
133 | // Everything is ok, let's create config file. | 134 | // Everything is ok, let's create config file. |
134 | $this->container->conf->write($this->container->loginManager->isLoggedIn()); | 135 | $this->container->conf->write($this->container->loginManager->isLoggedIn()); |
135 | } catch (\Exception $e) { | 136 | } catch (\Exception $e) { |
136 | $this->assignView('message', $e->getMessage()); | 137 | $this->assignView('message', t('Error while writing config file after configuration update.')); |
137 | $this->assignView('stacktrace', $e->getTraceAsString()); | 138 | $this->assignView('stacktrace', $e->getMessage() . PHP_EOL . $e->getTraceAsString()); |
138 | 139 | ||
139 | return $response->write($this->render('error')); | 140 | return $response->write($this->render('error')); |
140 | } | 141 | } |
@@ -155,18 +156,14 @@ class InstallController extends ShaarliVisitorController | |||
155 | { | 156 | { |
156 | // Ensure Shaarli has proper access to its resources | 157 | // Ensure Shaarli has proper access to its resources |
157 | $errors = ApplicationUtils::checkResourcePermissions($this->container->conf); | 158 | $errors = ApplicationUtils::checkResourcePermissions($this->container->conf); |
158 | |||
159 | if (empty($errors)) { | 159 | if (empty($errors)) { |
160 | return true; | 160 | return true; |
161 | } | 161 | } |
162 | 162 | ||
163 | // FIXME! Do not insert HTML here. | 163 | $message = t('Insufficient permissions:') . PHP_EOL; |
164 | $message = '<p>'. t('Insufficient permissions:') .'</p><ul>'; | ||
165 | |||
166 | foreach ($errors as $error) { | 164 | foreach ($errors as $error) { |
167 | $message .= '<li>'.$error.'</li>'; | 165 | $message .= PHP_EOL . $error; |
168 | } | 166 | } |
169 | $message .= '</ul>'; | ||
170 | 167 | ||
171 | throw new ResourcePermissionException($message); | 168 | throw new ResourcePermissionException($message); |
172 | } | 169 | } |
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; | |||
11 | * Class TagController | 11 | * Class TagController |
12 | * | 12 | * |
13 | * Slim controller handle tags. | 13 | * Slim controller handle tags. |
14 | * | ||
15 | * TODO: check redirections with new helper | ||
16 | */ | 14 | */ |
17 | class TagController extends ShaarliVisitorController | 15 | class TagController extends ShaarliVisitorController |
18 | { | 16 | { |
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 | |||
534 | 534 | ||
535 | if ($thumbnailsEnabled) { | 535 | if ($thumbnailsEnabled) { |
536 | $this->session['warnings'][] = t( | 536 | $this->session['warnings'][] = t( |
537 | 'You have enabled or changed thumbnails mode. <a href="./admin/thumbnails">Please synchronize them</a>.' | 537 | t('You have enabled or changed thumbnails mode.') . |
538 | '<a href="./admin/thumbnails">' . t('Please synchronize them.') . '</a>' | ||
538 | ); | 539 | ); |
539 | } | 540 | } |
540 | 541 | ||
@@ -28,7 +28,6 @@ require_once __DIR__ . '/init.php'; | |||
28 | use Shaarli\Config\ConfigManager; | 28 | use Shaarli\Config\ConfigManager; |
29 | use Shaarli\Container\ContainerBuilder; | 29 | use Shaarli\Container\ContainerBuilder; |
30 | use Shaarli\Languages; | 30 | use Shaarli\Languages; |
31 | use Shaarli\Plugin\PluginManager; | ||
32 | use Shaarli\Security\CookieManager; | 31 | use Shaarli\Security\CookieManager; |
33 | use Shaarli\Security\LoginManager; | 32 | use Shaarli\Security\LoginManager; |
34 | use Shaarli\Security\SessionManager; | 33 | use Shaarli\Security\SessionManager; |
@@ -65,9 +64,6 @@ $conf->setEmpty('general.title', t('Shared bookmarks on '). escape(index_url($_S | |||
65 | RainTPL::$tpl_dir = $conf->get('resource.raintpl_tpl').'/'.$conf->get('resource.theme').'/'; // template directory | 64 | RainTPL::$tpl_dir = $conf->get('resource.raintpl_tpl').'/'.$conf->get('resource.theme').'/'; // template directory |
66 | RainTPL::$cache_dir = $conf->get('resource.raintpl_tmp'); // cache directory | 65 | RainTPL::$cache_dir = $conf->get('resource.raintpl_tmp'); // cache directory |
67 | 66 | ||
68 | $pluginManager = new PluginManager($conf); | ||
69 | $pluginManager->load($conf->get('general.enabled_plugins')); | ||
70 | |||
71 | date_default_timezone_set($conf->get('general.timezone', 'UTC')); | 67 | date_default_timezone_set($conf->get('general.timezone', 'UTC')); |
72 | 68 | ||
73 | $loginManager->checkLoginState(client_ip_id($_SERVER)); | 69 | $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 | |||
162 | ->method('setSessionParameter') | 162 | ->method('setSessionParameter') |
163 | ->with( | 163 | ->with( |
164 | SessionManager::KEY_ERROR_MESSAGES, | 164 | SessionManager::KEY_ERROR_MESSAGES, |
165 | ['ERROR while saving plugin configuration: ' . PHP_EOL . $message] | 165 | ['Error while saving plugin configuration: ' . PHP_EOL . $message] |
166 | ) | 166 | ) |
167 | ; | 167 | ; |
168 | 168 | ||
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 | |||
189 | 'updates.check_updates' => true, | 189 | 'updates.check_updates' => true, |
190 | 'api.enabled' => true, | 190 | 'api.enabled' => true, |
191 | 'api.secret' => '_NOT_EMPTY', | 191 | 'api.secret' => '_NOT_EMPTY', |
192 | 'general.header_link' => '/subfolder', | ||
192 | ]; | 193 | ]; |
193 | 194 | ||
194 | $request = $this->createMock(Request::class); | 195 | $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 @@ | |||
9 | {if="count($linksToDisplay)===0 && $is_logged_in"} | 9 | {if="count($linksToDisplay)===0 && $is_logged_in"} |
10 | <div class="pure-g pure-alert pure-alert-warning page-single-alert"> | 10 | <div class="pure-g pure-alert pure-alert-warning page-single-alert"> |
11 | <div class="pure-u-1 center"> | 11 | <div class="pure-u-1 center"> |
12 | {'There is no cached thumbnail. Try to <a href="{$base_path}/admin/thumbnails">synchronize them</a>.'|t} | 12 | {'There is no cached thumbnail.'|t} |
13 | <a href="{$base_path}/admin/thumbnails">{'Try to synchronize them.'|t}</a> | ||
13 | </div> | 14 | </div> |
14 | </div> | 15 | </div> |
15 | {/if} | 16 | {/if} |