Make 'snappymail/v/' path dynamic for cleaner Nextcloud paths

This commit is contained in:
the-djmaze
2022-11-04 16:56:43 +01:00
parent 35f37381ae
commit 538f752fbe
4 changed files with 14 additions and 12 deletions

View File

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

View File

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

View File

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

View File

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