Multiple small fixes
This commit is contained in:
parent
fabff3835d
commit
3ee8351e43
11 changed files with 26 additions and 26 deletions
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
use Shaarli\Config\Exception\MissingFieldConfigException;
|
use Shaarli\Config\Exception\MissingFieldConfigException;
|
||||||
use Shaarli\Config\Exception\UnauthorizedConfigException;
|
use Shaarli\Config\Exception\UnauthorizedConfigException;
|
||||||
|
use Shaarli\Thumbnailer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ConfigManager
|
* Class ConfigManager
|
||||||
|
@ -361,7 +362,7 @@ protected function setDefaultValues()
|
||||||
$this->setEmpty('security.open_shaarli', false);
|
$this->setEmpty('security.open_shaarli', false);
|
||||||
$this->setEmpty('security.allowed_protocols', ['ftp', 'ftps', 'magnet']);
|
$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.links_per_page', 20);
|
||||||
$this->setEmpty('general.enabled_plugins', self::$DEFAULT_PLUGINS);
|
$this->setEmpty('general.enabled_plugins', self::$DEFAULT_PLUGINS);
|
||||||
$this->setEmpty('general.default_note_title', 'Note: ');
|
$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
|
// default state of the 'remember me' checkbox of the login form
|
||||||
$this->setEmpty('privacy.remember_user_default', true);
|
$this->setEmpty('privacy.remember_user_default', true);
|
||||||
|
|
||||||
|
$this->setEmpty('thumbnails.mode', Thumbnailer::MODE_ALL);
|
||||||
$this->setEmpty('thumbnails.width', '125');
|
$this->setEmpty('thumbnails.width', '125');
|
||||||
$this->setEmpty('thumbnails.height', '90');
|
$this->setEmpty('thumbnails.height', '90');
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,6 @@ public function build(): ShaarliContainer
|
||||||
$container['pluginManager'] = function (ShaarliContainer $container): PluginManager {
|
$container['pluginManager'] = function (ShaarliContainer $container): PluginManager {
|
||||||
$pluginManager = new PluginManager($container->conf);
|
$pluginManager = new PluginManager($container->conf);
|
||||||
|
|
||||||
// FIXME! Configuration is already injected
|
|
||||||
$pluginManager->load($container->conf->get('general.enabled_plugins'));
|
$pluginManager->load($container->conf->get('general.enabled_plugins'));
|
||||||
|
|
||||||
return $pluginManager;
|
return $pluginManager;
|
||||||
|
|
|
@ -56,7 +56,7 @@ public function __invoke(Request $request, Response $response, callable $next):
|
||||||
} catch (ShaarliFrontException $e) {
|
} catch (ShaarliFrontException $e) {
|
||||||
// Possible functional error
|
// Possible functional error
|
||||||
$this->container->pageBuilder->reset();
|
$this->container->pageBuilder->reset();
|
||||||
$this->container->pageBuilder->assign('message', $e->getMessage());
|
$this->container->pageBuilder->assign('message', nl2br($e->getMessage()));
|
||||||
|
|
||||||
$response = $response->withStatus($e->getCode());
|
$response = $response->withStatus($e->getCode());
|
||||||
|
|
||||||
|
|
|
@ -98,10 +98,10 @@ public function save(Request $request, Response $response): Response
|
||||||
if ($thumbnailsMode !== Thumbnailer::MODE_NONE
|
if ($thumbnailsMode !== Thumbnailer::MODE_NONE
|
||||||
&& $thumbnailsMode !== $this->container->conf->get('thumbnails.mode', Thumbnailer::MODE_NONE)
|
&& $thumbnailsMode !== $this->container->conf->get('thumbnails.mode', Thumbnailer::MODE_NONE)
|
||||||
) {
|
) {
|
||||||
$this->saveWarningMessage(t(
|
$this->saveWarningMessage(
|
||||||
'You have enabled or changed thumbnails mode. '
|
t('You have enabled or changed thumbnails mode.') .
|
||||||
.'<a href="'. $this->container->basePath .'/admin/thumbnails">Please synchronize them</a>.'
|
'<a href="'. $this->container->basePath .'/admin/thumbnails">' . t('Please synchronize them.') .'</a>'
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
$this->container->conf->set('thumbnails.mode', $thumbnailsMode);
|
$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->history->updateSettings();
|
||||||
$this->container->pageCacheManager->invalidateCaches();
|
$this->container->pageCacheManager->invalidateCaches();
|
||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
// TODO: translation + stacktrace
|
$this->assignView('message', t('Error while writing config file after configuration update.'));
|
||||||
$this->saveErrorMessage('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.'));
|
$this->saveSuccessMessage(t('Configuration was saved.'));
|
||||||
|
|
|
@ -128,13 +128,14 @@ public function save(Request $request, Response $response): Response
|
||||||
$this->container->conf->get('credentials.salt')
|
$this->container->conf->get('credentials.salt')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
$this->container->conf->set('general.header_link', $this->container->basePath);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Everything is ok, let's create config file.
|
// Everything is ok, let's create config file.
|
||||||
$this->container->conf->write($this->container->loginManager->isLoggedIn());
|
$this->container->conf->write($this->container->loginManager->isLoggedIn());
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->assignView('message', $e->getMessage());
|
$this->assignView('message', t('Error while writing config file after configuration update.'));
|
||||||
$this->assignView('stacktrace', $e->getTraceAsString());
|
$this->assignView('stacktrace', $e->getMessage() . PHP_EOL . $e->getTraceAsString());
|
||||||
|
|
||||||
return $response->write($this->render('error'));
|
return $response->write($this->render('error'));
|
||||||
}
|
}
|
||||||
|
@ -155,18 +156,14 @@ protected function checkPermissions(): bool
|
||||||
{
|
{
|
||||||
// Ensure Shaarli has proper access to its resources
|
// Ensure Shaarli has proper access to its resources
|
||||||
$errors = ApplicationUtils::checkResourcePermissions($this->container->conf);
|
$errors = ApplicationUtils::checkResourcePermissions($this->container->conf);
|
||||||
|
|
||||||
if (empty($errors)) {
|
if (empty($errors)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME! Do not insert HTML here.
|
$message = t('Insufficient permissions:') . PHP_EOL;
|
||||||
$message = '<p>'. t('Insufficient permissions:') .'</p><ul>';
|
|
||||||
|
|
||||||
foreach ($errors as $error) {
|
foreach ($errors as $error) {
|
||||||
$message .= '<li>'.$error.'</li>';
|
$message .= PHP_EOL . $error;
|
||||||
}
|
}
|
||||||
$message .= '</ul>';
|
|
||||||
|
|
||||||
throw new ResourcePermissionException($message);
|
throw new ResourcePermissionException($message);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,6 @@
|
||||||
* Class TagController
|
* Class TagController
|
||||||
*
|
*
|
||||||
* Slim controller handle tags.
|
* Slim controller handle tags.
|
||||||
*
|
|
||||||
* TODO: check redirections with new helper
|
|
||||||
*/
|
*/
|
||||||
class TagController extends ShaarliVisitorController
|
class TagController extends ShaarliVisitorController
|
||||||
{
|
{
|
||||||
|
|
|
@ -534,7 +534,8 @@ public function updateMethodWebThumbnailer()
|
||||||
|
|
||||||
if ($thumbnailsEnabled) {
|
if ($thumbnailsEnabled) {
|
||||||
$this->session['warnings'][] = t(
|
$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>'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
use Shaarli\Container\ContainerBuilder;
|
use Shaarli\Container\ContainerBuilder;
|
||||||
use Shaarli\Languages;
|
use Shaarli\Languages;
|
||||||
use Shaarli\Plugin\PluginManager;
|
|
||||||
use Shaarli\Security\CookieManager;
|
use Shaarli\Security\CookieManager;
|
||||||
use Shaarli\Security\LoginManager;
|
use Shaarli\Security\LoginManager;
|
||||||
use Shaarli\Security\SessionManager;
|
use Shaarli\Security\SessionManager;
|
||||||
|
@ -65,9 +64,6 @@
|
||||||
RainTPL::$tpl_dir = $conf->get('resource.raintpl_tpl').'/'.$conf->get('resource.theme').'/'; // template directory
|
RainTPL::$tpl_dir = $conf->get('resource.raintpl_tpl').'/'.$conf->get('resource.theme').'/'; // template directory
|
||||||
RainTPL::$cache_dir = $conf->get('resource.raintpl_tmp'); // cache 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'));
|
date_default_timezone_set($conf->get('general.timezone', 'UTC'));
|
||||||
|
|
||||||
$loginManager->checkLoginState(client_ip_id($_SERVER));
|
$loginManager->checkLoginState(client_ip_id($_SERVER));
|
||||||
|
|
|
@ -162,7 +162,7 @@ public function testSaveWithError(): void
|
||||||
->method('setSessionParameter')
|
->method('setSessionParameter')
|
||||||
->with(
|
->with(
|
||||||
SessionManager::KEY_ERROR_MESSAGES,
|
SessionManager::KEY_ERROR_MESSAGES,
|
||||||
['ERROR while saving plugin configuration: ' . PHP_EOL . $message]
|
['Error while saving plugin configuration: ' . PHP_EOL . $message]
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
|
@ -189,6 +189,7 @@ public function testSaveInstallValid(): void
|
||||||
'updates.check_updates' => true,
|
'updates.check_updates' => true,
|
||||||
'api.enabled' => true,
|
'api.enabled' => true,
|
||||||
'api.secret' => '_NOT_EMPTY',
|
'api.secret' => '_NOT_EMPTY',
|
||||||
|
'general.header_link' => '/subfolder',
|
||||||
];
|
];
|
||||||
|
|
||||||
$request = $this->createMock(Request::class);
|
$request = $this->createMock(Request::class);
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
{if="count($linksToDisplay)===0 && $is_logged_in"}
|
{if="count($linksToDisplay)===0 && $is_logged_in"}
|
||||||
<div class="pure-g pure-alert pure-alert-warning page-single-alert">
|
<div class="pure-g pure-alert pure-alert-warning page-single-alert">
|
||||||
<div class="pure-u-1 center">
|
<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>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
Loading…
Reference in a new issue