Issue #35: Add optional WWWURL config param

This commit is contained in:
Dale Davies
2022-06-30 14:59:41 +01:00
parent 064af3b747
commit 48bde6e48d
9 changed files with 24 additions and 11 deletions

View File

@@ -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), '/');
}
}

View File

@@ -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(),
]);
});
}

View File

@@ -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(),
]);
});
}

View File

@@ -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(),
]);
});
}

View File

@@ -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,

View File

@@ -3,8 +3,8 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/assets/css/styles.css">
<link rel="stylesheet" href="/background-css.php">
<link rel="stylesheet" href="{{{wwwurl}}}/assets/css/styles.css">
<link rel="stylesheet" href="{{{wwwurl}}}/background-css.php">
<link rel="icon" type="image/png" href="/favicon.png">
<title>{{message}}</title>
</head>

View File

@@ -26,13 +26,13 @@
<div id="tags" class="tags">
<span class="header">Tags<span class="close"></span></span>
<ul>
<li><a href="/">home</a></li>
{{# tags}}<li><a href="/tag/{{.}}/">{{.}}</a></li>{{/ tags}}
<li><a href="{{{wwwurl}}}/">home</a></li>
{{# tags}}<li><a href="{{{wwwurl}}}/tag/{{.}}/">{{.}}</a></li>{{/ tags}}
</ul>
</div>
{{/ hastags}}
<span class="unsplash"></span>
<div class="background fixed"></div>
<script defer src="/assets/js/index.c63595ee13b76dab6fb3.min.js"></script>
<script defer src="{{{wwwurl}}}/assets/js/index.c63595ee13b76dab6fb3.min.js"></script>
</body>
</html>

View File

@@ -4,10 +4,10 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
{{# noindex}}<meta name="robots" content="noindex">{{/ noindex}}
<link rel="stylesheet" href="/assets/css/styles.efdc3d1d099422476385.min.css">
<link rel="stylesheet" href="/background-css.php">
<link rel="stylesheet" href="/assets/css/weather-icons.min.css">
<link rel="icon" type="image/png" href="/favicon.png">
<link rel="stylesheet" href="{{{wwwurl}}}/assets/css/styles.efdc3d1d099422476385.min.css">
<link rel="stylesheet" href="{{{wwwurl}}}/background-css.php">
<link rel="stylesheet" href="{{{wwwurl}}}/assets/css/weather-icons.min.css">
<link rel="icon" type="image/png" href="{{{wwwurl}}}/favicon.png">
<title>{{title}}</title>
<script>
const JUMP = {

View File

@@ -2,7 +2,7 @@
<ul class="sites {{# altlayout}}alternate{{/ altlayout}}">
{{# sites}}<li><a {{# newtab}}target="_blank"{{/ newtab}} rel="{{# nofollow}}nofollow {{/ nofollow}}{{# newtab}}noopener{{/ newtab}}" title="{{description}}" href="{{url}}">
<span class="icon">
<img src="/api/icon.php?siteurl={{#urlencode}}{{url}}{{/urlencode}}">
<img src="{{{wwwurl}}}/api/icon.php?siteurl={{#urlencode}}{{url}}{{/urlencode}}">
</span>
<span class="name">{{name}}</span>
</a></li>{{/ sites}}