]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Multiple small fixes
authorArthurHoaro <arthur.hoareau@wizacha.com>
Thu, 23 Jul 2020 14:41:32 +0000 (16:41 +0200)
committerArthurHoaro <arthur@hoa.ro>
Thu, 23 Jul 2020 19:19:21 +0000 (21:19 +0200)
application/config/ConfigManager.php
application/container/ContainerBuilder.php
application/front/ShaarliMiddleware.php
application/front/controller/admin/ConfigureController.php
application/front/controller/visitor/InstallController.php
application/front/controller/visitor/TagController.php
application/legacy/LegacyUpdater.php
index.php
tests/front/controller/admin/PluginsControllerTest.php
tests/front/controller/visitor/InstallControllerTest.php
tpl/default/picwall.html

index e45bb4c391a21d1c5d14ec00007bf830788ba144..4c98be3051e3fafa7f9aa7b0891392a2c116f7db 100644 (file)
@@ -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');
 
index 593aafb79fa7114ef63b0aa46567cb749595e577..bfe93501c1ccd831a655dbb0e9540a525ab25fef 100644 (file)
@@ -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;
index e9f5552d850aead4aabe515f43521bd08087667e..fd978e997eea34b1a4d23b6452450bfff19fe8e4 100644 (file)
@@ -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());
 
index 865fc2b08c212f22b1d516e110dbf55a722a7657..e675fccabad0eacf408acc0901c113d0e777a5c9 100644 (file)
@@ -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. '
-                .'<a href="'. $this->container->basePath .'/admin/thumbnails">Please synchronize them</a>.'
-            ));
+            $this->saveWarningMessage(
+                t('You have enabled or changed thumbnails mode.') .
+                '<a href="'. $this->container->basePath .'/admin/thumbnails">' . t('Please synchronize them.') .'</a>'
+            );
         }
         $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.'));
index aa0328604950f466f9c09b34b0234fdbbf87a095..94ebb4ae2e30bfc8320cc0d272c972f93eb10c31 100644 (file)
@@ -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 = '<p>'. t('Insufficient permissions:') .'</p><ul>';
-
+        $message = t('Insufficient permissions:') . PHP_EOL;
         foreach ($errors as $error) {
-            $message .= '<li>'.$error.'</li>';
+            $message .= PHP_EOL . $error;
         }
-        $message .= '</ul>';
 
         throw new ResourcePermissionException($message);
     }
index c176f43f78307bbcc42a204d57e3efcbd4313727..de4e7ea28861daabb8c742aeeddd7725930cb95f 100644 (file)
@@ -11,8 +11,6 @@ use Slim\Http\Response;
  * Class TagController
  *
  * Slim controller handle tags.
- *
- * TODO: check redirections with new helper
  */
 class TagController extends ShaarliVisitorController
 {
index cbf6890f42cfa7508e69628c847bd15d0dee18a1..0ab3a55bd572898b07e51099fc8bd7ae23f5d7fe 100644 (file)
@@ -534,7 +534,8 @@ class LegacyUpdater
 
         if ($thumbnailsEnabled) {
             $this->session['warnings'][] = t(
-                'You have enabled or changed thumbnails mode. <a href="./admin/thumbnails">Please synchronize them</a>.'
+                t('You have enabled or changed thumbnails mode.') .
+                '<a href="./admin/thumbnails">' . t('Please synchronize them.') . '</a>'
             );
         }
 
index 42b853a465f4095fb1e26df9b7bfc82575d9ab84..26e8da8e98e5a08215c8d4a434256b75be8485b3 100644 (file)
--- 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));
index 700a0df2670939f3e8f364cd1711e01fd0dfaa6d..ad0cda70ad501d7a513eff2c9eddac812e6f013e 100644 (file)
@@ -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]
             )
         ;
 
index 6871fdd9d829bf4792e5068afef0572441d3901a..29c4d7a04ba7f10465efd4a3e39271b0e8d473e3 100644 (file)
@@ -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);
index 3b5fccc33175a590d673dc92f39b234d13f8a096..b7a56c89b17fb56540e1127acff994122286d035 100644 (file)
@@ -9,7 +9,8 @@
 {if="count($linksToDisplay)===0 && $is_logged_in"}
   <div class="pure-g pure-alert pure-alert-warning page-single-alert">
     <div class="pure-u-1 center">
-      {'There is no cached thumbnail. Try to <a href="{$base_path}/admin/thumbnails">synchronize them</a>.'|t}
+      {'There is no cached thumbnail.'|t}
+      <a href="{$base_path}/admin/thumbnails">{'Try to synchronize them.'|t}</a>
     </div>
   </div>
 {/if}