From 538f752fbea067fd4c1b4a4e4e9868b5ca733e57 Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Fri, 4 Nov 2022 16:56:43 +0100 Subject: [PATCH] Make 'snappymail/v/' path dynamic for cleaner Nextcloud paths --- build/nextcloud.php | 6 ++++-- dev/Common/Links.js | 15 +++++++-------- .../v/0.0.0/app/libraries/RainLoop/Actions.php | 3 ++- .../v/0.0.0/app/libraries/RainLoop/Utils.php | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/build/nextcloud.php b/build/nextcloud.php index 7609e46e8..a9bdf7907 100755 --- a/build/nextcloud.php +++ b/build/nextcloud.php @@ -13,8 +13,9 @@ $nc_tar->buildFromDirectory('./integrations/nextcloud', "@integrations/nextcloud $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator('snappymail/v'), RecursiveIteratorIterator::SELF_FIRST); foreach ($files as $file) { if (is_file($file)) { - $file = str_replace('\\', '/', $file); - $nc_tar->addFile($file, "snappymail/app/{$file}"); + $newFile = str_replace('\\', '/', $file); + $newFile = str_replace("'snappymail/v/'.", '', $newFile); + $nc_tar->addFile($file, "snappymail/app/{$newFile}"); } } /* @@ -27,6 +28,7 @@ $nc_tar->addFile('.htaccess', 'snappymail/app/.htaccess'); $index = file_get_contents('index.php'); $index = str_replace('0.0.0', $package->version, $index); +$index = str_replace('snappymail/v/', '', $index); $nc_tar->addFromString('snappymail/app/index.php', $index); $nc_tar->addFile('README.md', 'snappymail/app/README.md'); $nc_tar->addFile('CHANGELOG.md', 'snappymail/CHANGELOG.md'); diff --git a/dev/Common/Links.js b/dev/Common/Links.js index 38ca6a434..8a265e5c8 100644 --- a/dev/Common/Links.js +++ b/dev/Common/Links.js @@ -4,8 +4,6 @@ import { Settings } from 'Common/Globals'; const HASH_PREFIX = '#/', SERVER_PREFIX = './?', - VERSION = Settings.app('version'), - VERSION_PREFIX = 'snappymail/v/' + VERSION + '/', adminPath = () => rl.adminArea() && !Settings.app('adminHostUse'), @@ -62,26 +60,27 @@ export const * @returns {string} */ langLink = (lang, isAdmin) => - SERVER_PREFIX + '/Lang/0/' + (isAdmin ? 'Admin' : 'App') + '/' + encodeURI(lang) + '/' + VERSION + '/', + SERVER_PREFIX + '/Lang/0/' + (isAdmin ? 'Admin' : 'App') + + '/' + encodeURI(lang) + + '/' + Settings.app('version') + '/', /** * @param {string} path * @returns {string} */ - staticLink = path => Settings.app('webPath') + VERSION_PREFIX + 'static/' + path, + staticLink = path => Settings.app('webVersionPath') + 'static/' + path, /** * @param {string} theme * @returns {string} */ themePreviewLink = theme => { - let prefix = VERSION_PREFIX; + let path = 'webVersionPath'; if (theme.endsWith('@custom')) { theme = theme.slice(0, theme.length - 7).trim(); - prefix = ''; + path = 'webPath'; } - - return Settings.app('webPath') + prefix + 'themes/' + encodeURI(theme) + '/images/preview.png'; + return Settings.app(path) + 'themes/' + encodeURI(theme) + '/images/preview.png'; }, /** diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php index 72f3b8209..0f7884f17 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php @@ -611,7 +611,8 @@ class Actions 'version' => APP_VERSION, 'token' => $oConfig->Get('security', 'csrf_protection', false) ? Utils::GetCsrfToken() : '', 'languages' => \SnappyMail\L10n::getLanguages(false), - 'webPath' => \RainLoop\Utils::WebPath() + 'webPath' => \RainLoop\Utils::WebPath(), + 'webVersionPath' => \RainLoop\Utils::WebVersionPath() ), $bAdmin ? array( 'adminHostUse' => '' !== $oConfig->Get('security', 'admin_panel_host', ''), 'adminPath' => $oConfig->Get('security', 'admin_panel_key', '') ?: 'admin', diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Utils.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Utils.php index 9ec081335..1d79c5564 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Utils.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Utils.php @@ -202,7 +202,7 @@ class Utils public static function WebVersionPath() : string { - return self::WebPath().'snappymail/v/'.APP_VERSION.'/'; + return self::WebPath() . \str_replace(APP_INDEX_ROOT_PATH, '', APP_VERSION_ROOT_PATH); } public static function WebStaticPath(string $path = '') : string