From 1f063df81260072ce942d4ad28ab109997c100c1 Mon Sep 17 00:00:00 2001 From: Dan Untenzu Date: Wed, 18 Jan 2017 19:32:37 +0100 Subject: [PATCH] [FEATURE] Autogenerate prefix for absolute links Add a helping variable to build absolute links to the root of the domain without handling the URL scheme. This way all links could get rid of the host & domain part, and just build absolute links to the root instead. (Replace "[https://example.com/foo/] + [functions.js]" with "[/foo/] + [functions.js]") Refs #79 --- lib/settings.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/settings.php b/lib/settings.php index da0d9db..33c76da 100644 --- a/lib/settings.php +++ b/lib/settings.php @@ -42,6 +42,15 @@ define ('VAR_LINKS', $cfg['var_root'] . 'links/'); define ('VAR_ASYNC', $cfg['var_root'] . 'async/'); define ('VAR_ALIAS', $cfg['var_root'] . 'alias/'); +// helping variable to build absolute link to +// root of the domain without handling the URL scheme +$absPrefix = parse_url($cfg['web_root'], PHP_URL_PATH); +if(true === empty($absPrefix)) { + // fallback if installation isnt done yet: relative links to same level on the current page + $absPrefix = './'; +} +define ('JIRAFEAU_ABSPREFIX', $absPrefix); + /* Useful constants. */ if (!defined ('NL')) { define ('NL', "\n"); -- 2.34.1