From 7f5250421be4832b9679d8140bc4a71c8005dfa3 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Fri, 16 Oct 2020 12:47:11 +0200 Subject: Support using Shaarli without URL rewriting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Shaarli can be fully used by prefixing any URL with /index.php/ - {$base_path} used in templates already works with this configuration - Assets path (outside of theme's assets) must be prefixed with {$root_url}/ - Documentation section in « Server configuration » Fixes #1590 --- application/render/PageBuilder.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'application/render/PageBuilder.php') diff --git a/application/render/PageBuilder.php b/application/render/PageBuilder.php index 41b357dd..2d6d2dbe 100644 --- a/application/render/PageBuilder.php +++ b/application/render/PageBuilder.php @@ -174,10 +174,12 @@ class PageBuilder } } + $rootPath = preg_replace('#/index\.php$#', '', $basePath); $this->assign('base_path', $basePath); + $this->assign('root_path', $rootPath); $this->assign( 'asset_path', - $basePath . '/' . + $rootPath . '/' . rtrim($this->conf->get('resource.raintpl_tpl', 'tpl'), '/') . '/' . $this->conf->get('resource.theme', 'default') ); -- cgit v1.2.3 From b38a1b0209f546d4824a0db81a34c4e30fcdebaf Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 20 Oct 2020 11:47:07 +0200 Subject: Use PSR-3 logger for login attempts Fixes #1122 --- application/render/PageBuilder.php | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'application/render/PageBuilder.php') diff --git a/application/render/PageBuilder.php b/application/render/PageBuilder.php index 2d6d2dbe..512bb79e 100644 --- a/application/render/PageBuilder.php +++ b/application/render/PageBuilder.php @@ -3,7 +3,7 @@ namespace Shaarli\Render; use Exception; -use exceptions\MissingBasePathException; +use Psr\Log\LoggerInterface; use RainTPL; use Shaarli\ApplicationUtils; use Shaarli\Bookmark\BookmarkServiceInterface; @@ -35,6 +35,9 @@ class PageBuilder */ protected $session; + /** @var LoggerInterface */ + protected $logger; + /** * @var BookmarkServiceInterface $bookmarkService instance. */ @@ -54,17 +57,25 @@ class PageBuilder * PageBuilder constructor. * $tpl is initialized at false for lazy loading. * - * @param ConfigManager $conf Configuration Manager instance (reference). - * @param array $session $_SESSION array - * @param BookmarkServiceInterface $linkDB instance. - * @param string $token Session token - * @param bool $isLoggedIn + * @param ConfigManager $conf Configuration Manager instance (reference). + * @param array $session $_SESSION array + * @param LoggerInterface $logger + * @param null $linkDB instance. + * @param null $token Session token + * @param bool $isLoggedIn */ - public function __construct(&$conf, $session, $linkDB = null, $token = null, $isLoggedIn = false) - { + public function __construct( + ConfigManager &$conf, + array $session, + LoggerInterface $logger, + $linkDB = null, + $token = null, + $isLoggedIn = false + ) { $this->tpl = false; $this->conf = $conf; $this->session = $session; + $this->logger = $logger; $this->bookmarkService = $linkDB; $this->token = $token; $this->isLoggedIn = $isLoggedIn; @@ -98,7 +109,7 @@ class PageBuilder $this->tpl->assign('newVersion', escape($version)); $this->tpl->assign('versionError', ''); } catch (Exception $exc) { - logm($this->conf->get('resource.log'), $_SERVER['REMOTE_ADDR'], $exc->getMessage()); + $this->logger->error(format_log('Error: ' . $exc->getMessage(), client_ip_id($_SERVER))); $this->tpl->assign('newVersion', ''); $this->tpl->assign('versionError', escape($exc->getMessage())); } -- cgit v1.2.3 From c2cd15dac2bfaebe6d32f7649fbdedc07400fa08 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Fri, 16 Oct 2020 13:34:59 +0200 Subject: Move utils classes to Shaarli\Helper namespace and folder --- application/render/PageBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'application/render/PageBuilder.php') diff --git a/application/render/PageBuilder.php b/application/render/PageBuilder.php index 512bb79e..25e0e284 100644 --- a/application/render/PageBuilder.php +++ b/application/render/PageBuilder.php @@ -5,9 +5,9 @@ namespace Shaarli\Render; use Exception; use Psr\Log\LoggerInterface; use RainTPL; -use Shaarli\ApplicationUtils; use Shaarli\Bookmark\BookmarkServiceInterface; use Shaarli\Config\ConfigManager; +use Shaarli\Helper\ApplicationUtils; use Shaarli\Security\SessionManager; use Shaarli\Thumbnailer; -- cgit v1.2.3 From d3f6d525253eb7bb041d9436cbf213c10524a85c Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Wed, 28 Oct 2020 14:02:08 +0100 Subject: Fix compatiliby issue on login with PHP 7.1 session_set_cookie_params does not return any value in PHP 7.1 --- application/render/PageBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'application/render/PageBuilder.php') diff --git a/application/render/PageBuilder.php b/application/render/PageBuilder.php index 25e0e284..c2fae705 100644 --- a/application/render/PageBuilder.php +++ b/application/render/PageBuilder.php @@ -160,7 +160,7 @@ class PageBuilder $this->tpl->assign('formatter', $this->conf->get('formatter', 'default')); - $this->tpl->assign('links_per_page', $this->session['LINKS_PER_PAGE']); + $this->tpl->assign('links_per_page', $this->session['LINKS_PER_PAGE'] ?? 20); // To be removed with a proper theme configuration. $this->tpl->assign('conf', $this->conf); -- cgit v1.2.3 From b3bd8c3e8d367975980043e772f7cd78b7f96bc6 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Thu, 22 Oct 2020 16:21:03 +0200 Subject: Feature: support any tag separator So it allows to have multiple words tags. Breaking change: commas ',' are no longer a default separator. Fixes #594 --- application/render/PageBuilder.php | 1 + 1 file changed, 1 insertion(+) (limited to 'application/render/PageBuilder.php') diff --git a/application/render/PageBuilder.php b/application/render/PageBuilder.php index c2fae705..bf0ae326 100644 --- a/application/render/PageBuilder.php +++ b/application/render/PageBuilder.php @@ -161,6 +161,7 @@ class PageBuilder $this->tpl->assign('formatter', $this->conf->get('formatter', 'default')); $this->tpl->assign('links_per_page', $this->session['LINKS_PER_PAGE'] ?? 20); + $this->tpl->assign('tags_separator', $this->conf->get('general.tags_separator', ' ')); // To be removed with a proper theme configuration. $this->tpl->assign('conf', $this->conf); -- cgit v1.2.3