From 48bde6e48d0ff10503042b10627cb579ae190ca1 Mon Sep 17 00:00:00 2001 From: Dale Davies Date: Thu, 30 Jun 2022 14:59:41 +0100 Subject: [PATCH] Issue #35: Add optional WWWURL config param --- jumpapp/classes/Config.php | 4 ++++ jumpapp/classes/Pages/ErrorPage.php | 3 ++- jumpapp/classes/Pages/HomePage.php | 3 +++ jumpapp/classes/Pages/TagPage.php | 3 +++ jumpapp/config.php | 2 ++ jumpapp/templates/errorpage.mustache | 4 ++-- jumpapp/templates/footer.mustache | 6 +++--- jumpapp/templates/header.mustache | 8 ++++---- jumpapp/templates/sites.mustache | 2 +- 9 files changed, 24 insertions(+), 11 deletions(-) diff --git a/jumpapp/classes/Config.php b/jumpapp/classes/Config.php index 533346b..387b83a 100644 --- a/jumpapp/classes/Config.php +++ b/jumpapp/classes/Config.php @@ -120,4 +120,8 @@ class Config { return filter_var($input,FILTER_VALIDATE_BOOLEAN,FILTER_NULL_ON_FAILURE); } + public function get_wwwurl() { + return rtrim($this->config->get('wwwurl', false), '/'); + } + } diff --git a/jumpapp/classes/Pages/ErrorPage.php b/jumpapp/classes/Pages/ErrorPage.php index 7c76dcb..410438d 100644 --- a/jumpapp/classes/Pages/ErrorPage.php +++ b/jumpapp/classes/Pages/ErrorPage.php @@ -14,7 +14,8 @@ class ErrorPage { $template = $this->mustache->loadTemplate('errorpage'); return $template->render([ 'code' => $httpcode, - 'message' => $message + 'message' => $message, + 'wwwurl' => $this->config->get_wwwurl(), ]); }); } diff --git a/jumpapp/classes/Pages/HomePage.php b/jumpapp/classes/Pages/HomePage.php index a5d2453..13583d3 100644 --- a/jumpapp/classes/Pages/HomePage.php +++ b/jumpapp/classes/Pages/HomePage.php @@ -22,6 +22,7 @@ class HomePage extends AbstractPage { 'ampmclock' => $this->config->parse_bool($this->config->get('ampmclock', false)), 'unsplash' => !!$this->config->get('unsplashapikey', false), 'unsplashcolor' => $unsplashdata?->color, + 'wwwurl' => $this->config->get_wwwurl(), ]; if ($this->config->parse_bool($this->config->get('showsearch', false))) { $templatecontext = array_merge($templatecontext, [ @@ -40,6 +41,7 @@ class HomePage extends AbstractPage { 'hassites' => !empty($sites->get_sites()), 'sites' => $sites->get_sites_by_tag('home'), 'altlayout' => $this->config->parse_bool($this->config->get('altlayout', false)), + 'wwwurl' => $this->config->get_wwwurl(), ]); }); } @@ -54,6 +56,7 @@ class HomePage extends AbstractPage { 'tags' => $tags, 'showclock' => $this->config->parse_bool($this->config->get('showclock')), 'showsearch' => $this->config->parse_bool($this->config->get('showsearch', false)), + 'wwwurl' => $this->config->get_wwwurl(), ]); }); } diff --git a/jumpapp/classes/Pages/TagPage.php b/jumpapp/classes/Pages/TagPage.php index 0fe9f87..f2256c8 100644 --- a/jumpapp/classes/Pages/TagPage.php +++ b/jumpapp/classes/Pages/TagPage.php @@ -22,6 +22,7 @@ class TagPage extends AbstractPage { 'ampmclock' => $this->config->parse_bool($this->config->get('ampmclock', false)), 'unsplash' => !!$this->config->get('unsplashapikey', false), 'unsplashcolor' => $unsplashdata?->color, + 'url' => $this->config->get('url', false), ]; if ($this->config->parse_bool($this->config->get('showsearch', false))) { $templatecontext = array_merge($templatecontext, [ @@ -47,6 +48,7 @@ class TagPage extends AbstractPage { 'hassites' => !empty($taggedsites), 'sites' => $taggedsites, 'altlayout' => $this->config->parse_bool($this->config->get('altlayout', false)), + 'wwwurl' => $this->config->get_wwwurl(), ]); }); } @@ -61,6 +63,7 @@ class TagPage extends AbstractPage { 'tags' => $tags, 'showclock' => $this->config->parse_bool($this->config->get('showclock')), 'showsearch' => $this->config->parse_bool($this->config->get('showsearch', false)), + 'wwwurl' => $this->config->get_wwwurl(), ]); }); } diff --git a/jumpapp/config.php b/jumpapp/config.php index 3d1b0e1..7f10b8a 100644 --- a/jumpapp/config.php +++ b/jumpapp/config.php @@ -11,6 +11,8 @@ return [ 'sitename' => getenv('SITENAME') ?: 'Jump', // Where on the this code is located. 'wwwroot' => getenv('WWWROOT') ?: '/var/www/html', + // URL - might help if just is hosted in a subdirectory. + 'wwwurl' => getenv('URL') ?: '', // Stop retrieving items from the cache, useful for testing. 'cachebypass' => getenv('CACHEBYPASS') ?: false, diff --git a/jumpapp/templates/errorpage.mustache b/jumpapp/templates/errorpage.mustache index 520b32f..20ac6f4 100644 --- a/jumpapp/templates/errorpage.mustache +++ b/jumpapp/templates/errorpage.mustache @@ -3,8 +3,8 @@ - - + + {{message}} diff --git a/jumpapp/templates/footer.mustache b/jumpapp/templates/footer.mustache index 473cd1f..e52c257 100644 --- a/jumpapp/templates/footer.mustache +++ b/jumpapp/templates/footer.mustache @@ -26,13 +26,13 @@
Tags
{{/ hastags}}
- + diff --git a/jumpapp/templates/header.mustache b/jumpapp/templates/header.mustache index 2545eb2..7bde618 100644 --- a/jumpapp/templates/header.mustache +++ b/jumpapp/templates/header.mustache @@ -4,10 +4,10 @@ {{# noindex}}{{/ noindex}} - - - - + + + + {{title}}