mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-09-20 07:35:55 +08:00
*.jsx -> *.js
This commit is contained in:
parent
0a2b826f71
commit
e88c193334
|
@ -26,7 +26,7 @@ window.progressJs.onbeforeend(() => {
|
|||
require('json3');
|
||||
require('../vendors/modernizr/modernizr-custom.js');
|
||||
|
||||
require('Common/Booter.jsx');
|
||||
require('Common/Booter');
|
||||
|
||||
if (window.__runBoot)
|
||||
{
|
0
dev/bootstrap.jsx → dev/bootstrap.js
vendored
0
dev/bootstrap.jsx → dev/bootstrap.js
vendored
12
gulpfile.js
12
gulpfile.js
|
@ -185,11 +185,8 @@ function signFileTask(callback) {
|
|||
}
|
||||
};
|
||||
|
||||
cfg.paths.globjs = 'dev/**/*.{js,jsx,html,css}';
|
||||
cfg.paths.globjsonly = 'dev/**/*.js';
|
||||
cfg.paths.globjsxonly = 'dev/**/*.jsx';
|
||||
cfg.paths.globjsall = 'dev/**/*.{js,jsx}';
|
||||
cfg.paths.globtsonly = 'dev/**/*.ts';
|
||||
cfg.paths.globall = 'dev/**/*.{js,html,css}';
|
||||
cfg.paths.globjs = 'dev/**/*.{js}';
|
||||
cfg.paths.static = 'rainloop/v/' + cfg.devVersion + '/static/';
|
||||
cfg.paths.staticJS = 'rainloop/v/' + cfg.devVersion + '/static/js/';
|
||||
cfg.paths.staticMinJS = 'rainloop/v/' + cfg.devVersion + '/static/js/min/';
|
||||
|
@ -445,6 +442,7 @@ gulp.task('js:min', ['js:app', 'js:admin', 'js:validate'], function() {
|
|||
return gulp.src(cfg.paths.staticJS + '*.js')
|
||||
.pipe(ignore.exclude('*.next.js'))
|
||||
.pipe(replace(/"rainloop\/v\/([^\/]+)\/static\/js\/"/g, '"rainloop/v/$1/static/js/min/"'))
|
||||
.pipe(rename({suffix: '.min'}))
|
||||
.pipe(uglify({
|
||||
mangle: true,
|
||||
compress: true
|
||||
|
@ -456,7 +454,7 @@ gulp.task('js:min', ['js:app', 'js:admin', 'js:validate'], function() {
|
|||
|
||||
// lint
|
||||
gulp.task('js:eslint', function() {
|
||||
return gulp.src(cfg.paths.globjsall)
|
||||
return gulp.src(cfg.paths.globjs)
|
||||
.pipe(cache('eslint'))
|
||||
.pipe(eslint())
|
||||
.pipe(gulpif(cfg.watch, plumber({errorHandler: notify.onError("Error: <%= error.message %>")})))
|
||||
|
@ -684,7 +682,7 @@ gulp.task('watch', ['fast'], function() {
|
|||
cfg.watch = true;
|
||||
livereload.listen();
|
||||
gulp.watch(cfg.paths.globjs, {interval: cfg.watchInterval}, ['js:app', 'js:admin']);
|
||||
gulp.watch(cfg.paths.globjsall, {interval: cfg.watchInterval}, ['js:validate']);
|
||||
gulp.watch(cfg.paths.globjs, {interval: cfg.watchInterval}, ['js:validate']);
|
||||
gulp.watch(cfg.paths.less.main.watch, {interval: cfg.watchInterval}, ['css:main']);
|
||||
});
|
||||
|
||||
|
|
|
@ -1945,8 +1945,11 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
|
|||
|
||||
$bAppJsDebug = !!$this->Config()->Get('labs', 'use_app_debug_js', false);
|
||||
|
||||
$aResult['StaticLibJsLink'] = $this->StaticPath('js/'.($bAppJsDebug ? '' : 'min/').'libs.js');
|
||||
$aResult['StaticAppJsLink'] = $this->StaticPath('js/'.($bAppJsDebug ? '' : 'min/').($bAdmin ? 'admin' : 'app').'.js');
|
||||
$aResult['StaticLibJsLink'] = $this->StaticPath('js/'.($bAppJsDebug ? '' : 'min/').
|
||||
'libs'.($bAppJsDebug ? '' : '.min').'.js');
|
||||
$aResult['StaticAppJsLink'] = $this->StaticPath('js/'.($bAppJsDebug ? '' : 'min/').
|
||||
($bAdmin ? 'admin' : 'app').($bAppJsDebug ? '' : '.min').'.js');
|
||||
|
||||
$aResult['StaticAppJsNextLink'] = $this->StaticPath('js/'.($bAdmin ? 'admin' : 'app').'.next.js'); // todo min
|
||||
$aResult['StaticEditorJsLink'] = $this->StaticPath('ckeditor/ckeditor.js');
|
||||
|
||||
|
|
|
@ -1,323 +1,323 @@
|
|||
<?php
|
||||
|
||||
namespace RainLoop;
|
||||
|
||||
class Service
|
||||
{
|
||||
/**
|
||||
* @var \MailSo\Base\Http
|
||||
*/
|
||||
private $oHttp;
|
||||
|
||||
/**
|
||||
* @var \RainLoop\Actions
|
||||
*/
|
||||
private $oActions;
|
||||
|
||||
/**
|
||||
* @var \RainLoop\ServiceActions
|
||||
*/
|
||||
private $oServiceActions;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
private function __construct()
|
||||
{
|
||||
$this->oHttp = \MailSo\Base\Http::SingletonInstance();
|
||||
$this->oActions = \RainLoop\Api::Actions();
|
||||
|
||||
$this->oServiceActions = new \RainLoop\ServiceActions($this->oHttp, $this->oActions);
|
||||
|
||||
if ($this->oActions->Config()->Get('debug', 'enable', false))
|
||||
{
|
||||
\error_reporting(E_ALL);
|
||||
\ini_set('display_errors', 1);
|
||||
}
|
||||
|
||||
$sServer = \trim($this->oActions->Config()->Get('security', 'custom_server_signature', ''));
|
||||
if (0 < \strlen($sServer))
|
||||
{
|
||||
@\header('Server: '.$sServer, true);
|
||||
}
|
||||
|
||||
$sXFrameOptionsHeader = \trim($this->oActions->Config()->Get('security', 'x_frame_options_header', ''));
|
||||
if (0 < \strlen($sXFrameOptionsHeader))
|
||||
{
|
||||
@\header('X-Frame-Options: '.$sXFrameOptionsHeader, true);
|
||||
}
|
||||
|
||||
if ($this->oActions->Config()->Get('labs', 'force_https', false) && !$this->oHttp->IsSecure())
|
||||
{
|
||||
@\header('Location: https://'.$this->oHttp->GetHost(false, false).$this->oHttp->GetUrl(), true);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
$this->localHandle();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function RunResult()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @staticvar bool $bOne
|
||||
* @return bool
|
||||
*/
|
||||
public static function Handle()
|
||||
{
|
||||
static $bOne = null;
|
||||
if (null === $bOne)
|
||||
{
|
||||
$oService = null;
|
||||
if (\class_exists('MailSo\Version'))
|
||||
{
|
||||
$oService = new self();
|
||||
}
|
||||
|
||||
$bOne = $oService->RunResult();
|
||||
}
|
||||
|
||||
return $bOne;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \RainLoop\Service
|
||||
*/
|
||||
private function localHandle()
|
||||
{
|
||||
if (!\class_exists('MailSo\Version'))
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->oActions->BootStart();
|
||||
|
||||
$sResult = '';
|
||||
$bCached = false;
|
||||
|
||||
$sQuery = $this->oActions->ParseQueryAuthString();
|
||||
|
||||
$this->oActions->Plugins()->RunHook('filter.http-query', array(&$sQuery));
|
||||
$aPaths = \explode('/', $sQuery);
|
||||
$this->oActions->Plugins()->RunHook('filter.http-paths', array(&$aPaths));
|
||||
|
||||
$bAdmin = false;
|
||||
$sAdminPanelHost = $this->oActions->Config()->Get('security', 'admin_panel_host', '');
|
||||
if (empty($sAdminPanelHost))
|
||||
{
|
||||
$sAdminPanelKey = \strtolower($this->oActions->Config()->Get('security', 'admin_panel_key', 'admin'));
|
||||
$bAdmin = !empty($aPaths[0]) && \strtolower($aPaths[0]) === $sAdminPanelKey;
|
||||
}
|
||||
else if (empty($aPaths[0]) &&
|
||||
\MailSo\Base\Utils::StrToLowerIfAscii($sAdminPanelHost) === \MailSo\Base\Utils::StrToLowerIfAscii($this->oHttp->GetHost()))
|
||||
{
|
||||
$bAdmin = true;
|
||||
}
|
||||
|
||||
if ($this->oHttp->IsPost())
|
||||
{
|
||||
$this->oHttp->ServerNoCache();
|
||||
}
|
||||
|
||||
if ($bAdmin && !$this->oActions->Config()->Get('security', 'allow_admin_panel', true))
|
||||
{
|
||||
echo $this->oServiceActions->ErrorTemplates('Access Denied.',
|
||||
'Access to the RainLoop Webmail Admin Panel is not allowed!', true);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
$bIndex = true;
|
||||
if (0 < \count($aPaths) && !empty($aPaths[0]) && !$bAdmin && 'index' !== \strtolower($aPaths[0]))
|
||||
{
|
||||
$bIndex = false;
|
||||
$sMethodName = 'Service'.\preg_replace('/@.+$/', '', $aPaths[0]);
|
||||
$sMethodExtra = 0 < \strpos($aPaths[0], '@') ? \preg_replace('/^[^@]+@/', '', $aPaths[0]) : '';
|
||||
|
||||
if (\method_exists($this->oServiceActions, $sMethodName) &&
|
||||
\is_callable(array($this->oServiceActions, $sMethodName)))
|
||||
{
|
||||
$this->oServiceActions->SetQuery($sQuery)->SetPaths($aPaths);
|
||||
$sResult = \call_user_func(array($this->oServiceActions, $sMethodName), $sMethodExtra);
|
||||
}
|
||||
else if (!$this->oActions->Plugins()->RunAdditionalPart($aPaths[0], $aPaths))
|
||||
{
|
||||
$bIndex = true;
|
||||
}
|
||||
}
|
||||
|
||||
$bMobile = false;
|
||||
$bMobileDevice = false;
|
||||
|
||||
if ($this->oActions->Config()->Get('labs', 'allow_mobile_version', false))
|
||||
{
|
||||
$oMobileDetect = new \Detection\MobileDetect();
|
||||
$bMobileDevice = $oMobileDetect->isMobile() && !$oMobileDetect->isTablet();
|
||||
|
||||
$bMobile = (0 < \count($aPaths) && !empty($aPaths[0]) && 'mobile' === \strtolower($aPaths[0]));
|
||||
}
|
||||
|
||||
if ($bIndex && !$bMobile)
|
||||
{
|
||||
$iMobileKey = (int) \RainLoop\Utils::GetCookie(\RainLoop\Actions::RL_SKIP_MOBILE_KEY, 0);
|
||||
if (1 !== $iMobileKey)
|
||||
{
|
||||
if ($bMobileDevice)
|
||||
{
|
||||
$this->oActions->Location('./?/Mobile/');
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($bIndex)
|
||||
{
|
||||
@\header('Content-Security-Policy:');
|
||||
@\header_remove('Content-Security-Policy');
|
||||
|
||||
@header('Content-Type: text/html; charset=utf-8');
|
||||
$this->oHttp->ServerNoCache();
|
||||
|
||||
if (!@\is_dir(APP_DATA_FOLDER_PATH) || !@\is_writable(APP_DATA_FOLDER_PATH))
|
||||
{
|
||||
echo $this->oServiceActions->ErrorTemplates(
|
||||
'Permission denied!',
|
||||
'RainLoop Webmail cannot access to the data folder "'.APP_DATA_FOLDER_PATH.'"'
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
$aTemplateParameters = $this->indexTemplateParameters($bAdmin, $bMobile, $bMobileDevice);
|
||||
|
||||
$sCacheFileName = '';
|
||||
if ($this->oActions->Config()->Get('labs', 'cache_system_data', true) && !empty($aTemplateParameters['{{BaseHash}}']))
|
||||
{
|
||||
$sCacheFileName = 'TMPL:'.$aTemplateParameters['{{BaseHash}}'];
|
||||
$sResult = $this->oActions->Cacher()->Get($sCacheFileName);
|
||||
}
|
||||
|
||||
if (0 === \strlen($sResult))
|
||||
{
|
||||
// $aTemplateParameters['{{BaseTemplates}}'] = $this->oServiceActions->compileTemplates($bAdmin, false);
|
||||
$sResult = \strtr(\file_get_contents(APP_VERSION_ROOT_PATH.'app/templates/Index.html'), $aTemplateParameters);
|
||||
|
||||
$sResult = \RainLoop\Utils::ClearHtmlOutput($sResult);
|
||||
if (0 < \strlen($sCacheFileName))
|
||||
{
|
||||
$this->oActions->Cacher()->Set($sCacheFileName, $sResult);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$bCached = true;
|
||||
}
|
||||
|
||||
$sResult .= '<!--';
|
||||
$sResult .= '[time:'.\substr(\microtime(true) - APP_START, 0, 6);
|
||||
|
||||
// $sResult .= '][version:'.APP_VERSION;
|
||||
if ($this->oActions->IsOpen())
|
||||
{
|
||||
$sResult .= '][AGPLv3';
|
||||
}
|
||||
|
||||
$sResult .= '][cached:'.($bCached ? 'true' : 'false');
|
||||
// $sResult .= '][hash:'.$aTemplateParameters['{{BaseHash}}'];
|
||||
// $sResult .= '][session:'.\md5(\RainLoop\Utils::GetShortToken());
|
||||
|
||||
if ($bMobile)
|
||||
{
|
||||
$sResult .= '][mobile:true';
|
||||
}
|
||||
|
||||
if (\RainLoop\Utils::IsOwnCloud())
|
||||
{
|
||||
$sResult .= '][owncloud:true';
|
||||
}
|
||||
|
||||
$sResult .= ']-->';
|
||||
}
|
||||
|
||||
// Output result
|
||||
echo $sResult;
|
||||
unset($sResult);
|
||||
|
||||
$this->oActions->BootEnd();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sPath
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function staticPath($sPath)
|
||||
{
|
||||
return $this->oActions->StaticPath($sPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bAdmin = false
|
||||
* @param bool $bMobile = false
|
||||
* @param bool $bMobileDevice = false
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function indexTemplateParameters($bAdmin = false, $bMobile = false, $bMobileDevice = false)
|
||||
{
|
||||
$sLanguage = 'en';
|
||||
$sTheme = 'Default';
|
||||
|
||||
list($sLanguage, $sTheme) = $this->oActions->GetLanguageAndTheme($bAdmin, $bMobile);
|
||||
|
||||
$bAppJsDebug = !!$this->oActions->Config()->Get('labs', 'use_app_debug_js', false);
|
||||
$bAppCssDebug = !!$this->oActions->Config()->Get('labs', 'use_app_debug_css', false);
|
||||
|
||||
$sFaviconUrl = (string) $this->oActions->Config()->Get('webmail', 'favicon_url', '');
|
||||
|
||||
$sFaviconPngLink = $sFaviconUrl ? $sFaviconUrl : $this->staticPath('apple-touch-icon.png');
|
||||
$sAppleTouchLink = $sFaviconUrl ? '' : $this->staticPath('apple-touch-icon.png');
|
||||
|
||||
$sContentSecurityPolicy = $this->oActions->Config()->Get('security', 'content_security_policy', '');
|
||||
|
||||
$aTemplateParameters = array(
|
||||
'{{BaseAppFaviconPngLinkTag}}' => $sFaviconPngLink ? '<link type="image/png" rel="shortcut icon" href="'.$sFaviconPngLink.'" />' : '',
|
||||
'{{BaseAppFaviconTouchLinkTag}}' => $sAppleTouchLink ? '<link type="image/png" rel="apple-touch-icon" href="'.$sAppleTouchLink.'" />' : '',
|
||||
'{{BaseAppMainCssLink}}' => $this->staticPath('css/app'.($bAppCssDebug ? '' : '.min').'.css'),
|
||||
'{{BaseAppThemeCssLink}}' => $this->oActions->ThemeLink($sTheme, $bAdmin),
|
||||
'{{BaseAppBootScriptLink}}' => $this->staticPath('js/'.($bAppJsDebug ? '' : 'min/').'boot.js'),
|
||||
'{{BaseViewport}}' => $bMobile ? 'width=device-width,initial-scale=1,user-scalable=no' : 'width=950,maximum-scale=2',
|
||||
'{{BaseContentSecurityPolicy}}' => $sContentSecurityPolicy ?
|
||||
'<meta http-equiv="Content-Security-Policy" content="'.$sContentSecurityPolicy.'" />' : '',
|
||||
'{{BaseDir}}' => false && \in_array($sLanguage, array('ar', 'he', 'ur')) ? 'rtl' : 'ltr',
|
||||
'{{BaseAppManifestLink}}' => $this->staticPath('manifest.json')
|
||||
);
|
||||
|
||||
$aTemplateParameters['{{RainloopBootData}}'] = \json_encode(array(
|
||||
'admin' => $bAdmin,
|
||||
'language' => $sLanguage,
|
||||
'theme' => $sTheme,
|
||||
'mobile' => $bMobile,
|
||||
'mobileDevice' => $bMobileDevice
|
||||
));
|
||||
|
||||
$aTemplateParameters['{{BaseHash}}'] = \md5(
|
||||
\implode('~', array(
|
||||
$bAdmin ? '1' : '0',
|
||||
\md5($this->oActions->Config()->Get('cache', 'index', '')),
|
||||
$this->oActions->Plugins()->Hash(),
|
||||
\RainLoop\Utils::WebVersionPath(),
|
||||
APP_VERSION,
|
||||
)).
|
||||
\implode('~', $aTemplateParameters)
|
||||
);
|
||||
|
||||
return $aTemplateParameters;
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace RainLoop;
|
||||
|
||||
class Service
|
||||
{
|
||||
/**
|
||||
* @var \MailSo\Base\Http
|
||||
*/
|
||||
private $oHttp;
|
||||
|
||||
/**
|
||||
* @var \RainLoop\Actions
|
||||
*/
|
||||
private $oActions;
|
||||
|
||||
/**
|
||||
* @var \RainLoop\ServiceActions
|
||||
*/
|
||||
private $oServiceActions;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
private function __construct()
|
||||
{
|
||||
$this->oHttp = \MailSo\Base\Http::SingletonInstance();
|
||||
$this->oActions = \RainLoop\Api::Actions();
|
||||
|
||||
$this->oServiceActions = new \RainLoop\ServiceActions($this->oHttp, $this->oActions);
|
||||
|
||||
if ($this->oActions->Config()->Get('debug', 'enable', false))
|
||||
{
|
||||
\error_reporting(E_ALL);
|
||||
\ini_set('display_errors', 1);
|
||||
}
|
||||
|
||||
$sServer = \trim($this->oActions->Config()->Get('security', 'custom_server_signature', ''));
|
||||
if (0 < \strlen($sServer))
|
||||
{
|
||||
@\header('Server: '.$sServer, true);
|
||||
}
|
||||
|
||||
$sXFrameOptionsHeader = \trim($this->oActions->Config()->Get('security', 'x_frame_options_header', ''));
|
||||
if (0 < \strlen($sXFrameOptionsHeader))
|
||||
{
|
||||
@\header('X-Frame-Options: '.$sXFrameOptionsHeader, true);
|
||||
}
|
||||
|
||||
if ($this->oActions->Config()->Get('labs', 'force_https', false) && !$this->oHttp->IsSecure())
|
||||
{
|
||||
@\header('Location: https://'.$this->oHttp->GetHost(false, false).$this->oHttp->GetUrl(), true);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
$this->localHandle();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function RunResult()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @staticvar bool $bOne
|
||||
* @return bool
|
||||
*/
|
||||
public static function Handle()
|
||||
{
|
||||
static $bOne = null;
|
||||
if (null === $bOne)
|
||||
{
|
||||
$oService = null;
|
||||
if (\class_exists('MailSo\Version'))
|
||||
{
|
||||
$oService = new self();
|
||||
}
|
||||
|
||||
$bOne = $oService->RunResult();
|
||||
}
|
||||
|
||||
return $bOne;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \RainLoop\Service
|
||||
*/
|
||||
private function localHandle()
|
||||
{
|
||||
if (!\class_exists('MailSo\Version'))
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->oActions->BootStart();
|
||||
|
||||
$sResult = '';
|
||||
$bCached = false;
|
||||
|
||||
$sQuery = $this->oActions->ParseQueryAuthString();
|
||||
|
||||
$this->oActions->Plugins()->RunHook('filter.http-query', array(&$sQuery));
|
||||
$aPaths = \explode('/', $sQuery);
|
||||
$this->oActions->Plugins()->RunHook('filter.http-paths', array(&$aPaths));
|
||||
|
||||
$bAdmin = false;
|
||||
$sAdminPanelHost = $this->oActions->Config()->Get('security', 'admin_panel_host', '');
|
||||
if (empty($sAdminPanelHost))
|
||||
{
|
||||
$sAdminPanelKey = \strtolower($this->oActions->Config()->Get('security', 'admin_panel_key', 'admin'));
|
||||
$bAdmin = !empty($aPaths[0]) && \strtolower($aPaths[0]) === $sAdminPanelKey;
|
||||
}
|
||||
else if (empty($aPaths[0]) &&
|
||||
\MailSo\Base\Utils::StrToLowerIfAscii($sAdminPanelHost) === \MailSo\Base\Utils::StrToLowerIfAscii($this->oHttp->GetHost()))
|
||||
{
|
||||
$bAdmin = true;
|
||||
}
|
||||
|
||||
if ($this->oHttp->IsPost())
|
||||
{
|
||||
$this->oHttp->ServerNoCache();
|
||||
}
|
||||
|
||||
if ($bAdmin && !$this->oActions->Config()->Get('security', 'allow_admin_panel', true))
|
||||
{
|
||||
echo $this->oServiceActions->ErrorTemplates('Access Denied.',
|
||||
'Access to the RainLoop Webmail Admin Panel is not allowed!', true);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
$bIndex = true;
|
||||
if (0 < \count($aPaths) && !empty($aPaths[0]) && !$bAdmin && 'index' !== \strtolower($aPaths[0]))
|
||||
{
|
||||
$bIndex = false;
|
||||
$sMethodName = 'Service'.\preg_replace('/@.+$/', '', $aPaths[0]);
|
||||
$sMethodExtra = 0 < \strpos($aPaths[0], '@') ? \preg_replace('/^[^@]+@/', '', $aPaths[0]) : '';
|
||||
|
||||
if (\method_exists($this->oServiceActions, $sMethodName) &&
|
||||
\is_callable(array($this->oServiceActions, $sMethodName)))
|
||||
{
|
||||
$this->oServiceActions->SetQuery($sQuery)->SetPaths($aPaths);
|
||||
$sResult = \call_user_func(array($this->oServiceActions, $sMethodName), $sMethodExtra);
|
||||
}
|
||||
else if (!$this->oActions->Plugins()->RunAdditionalPart($aPaths[0], $aPaths))
|
||||
{
|
||||
$bIndex = true;
|
||||
}
|
||||
}
|
||||
|
||||
$bMobile = false;
|
||||
$bMobileDevice = false;
|
||||
|
||||
if ($this->oActions->Config()->Get('labs', 'allow_mobile_version', false))
|
||||
{
|
||||
$oMobileDetect = new \Detection\MobileDetect();
|
||||
$bMobileDevice = $oMobileDetect->isMobile() && !$oMobileDetect->isTablet();
|
||||
|
||||
$bMobile = (0 < \count($aPaths) && !empty($aPaths[0]) && 'mobile' === \strtolower($aPaths[0]));
|
||||
}
|
||||
|
||||
if ($bIndex && !$bMobile)
|
||||
{
|
||||
$iMobileKey = (int) \RainLoop\Utils::GetCookie(\RainLoop\Actions::RL_SKIP_MOBILE_KEY, 0);
|
||||
if (1 !== $iMobileKey)
|
||||
{
|
||||
if ($bMobileDevice)
|
||||
{
|
||||
$this->oActions->Location('./?/Mobile/');
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($bIndex)
|
||||
{
|
||||
@\header('Content-Security-Policy:');
|
||||
@\header_remove('Content-Security-Policy');
|
||||
|
||||
@header('Content-Type: text/html; charset=utf-8');
|
||||
$this->oHttp->ServerNoCache();
|
||||
|
||||
if (!@\is_dir(APP_DATA_FOLDER_PATH) || !@\is_writable(APP_DATA_FOLDER_PATH))
|
||||
{
|
||||
echo $this->oServiceActions->ErrorTemplates(
|
||||
'Permission denied!',
|
||||
'RainLoop Webmail cannot access to the data folder "'.APP_DATA_FOLDER_PATH.'"'
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
$aTemplateParameters = $this->indexTemplateParameters($bAdmin, $bMobile, $bMobileDevice);
|
||||
|
||||
$sCacheFileName = '';
|
||||
if ($this->oActions->Config()->Get('labs', 'cache_system_data', true) && !empty($aTemplateParameters['{{BaseHash}}']))
|
||||
{
|
||||
$sCacheFileName = 'TMPL:'.$aTemplateParameters['{{BaseHash}}'];
|
||||
$sResult = $this->oActions->Cacher()->Get($sCacheFileName);
|
||||
}
|
||||
|
||||
if (0 === \strlen($sResult))
|
||||
{
|
||||
// $aTemplateParameters['{{BaseTemplates}}'] = $this->oServiceActions->compileTemplates($bAdmin, false);
|
||||
$sResult = \strtr(\file_get_contents(APP_VERSION_ROOT_PATH.'app/templates/Index.html'), $aTemplateParameters);
|
||||
|
||||
$sResult = \RainLoop\Utils::ClearHtmlOutput($sResult);
|
||||
if (0 < \strlen($sCacheFileName))
|
||||
{
|
||||
$this->oActions->Cacher()->Set($sCacheFileName, $sResult);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$bCached = true;
|
||||
}
|
||||
|
||||
$sResult .= '<!--';
|
||||
$sResult .= '[time:'.\substr(\microtime(true) - APP_START, 0, 6);
|
||||
|
||||
// $sResult .= '][version:'.APP_VERSION;
|
||||
if ($this->oActions->IsOpen())
|
||||
{
|
||||
$sResult .= '][AGPLv3';
|
||||
}
|
||||
|
||||
$sResult .= '][cached:'.($bCached ? 'true' : 'false');
|
||||
// $sResult .= '][hash:'.$aTemplateParameters['{{BaseHash}}'];
|
||||
// $sResult .= '][session:'.\md5(\RainLoop\Utils::GetShortToken());
|
||||
|
||||
if ($bMobile)
|
||||
{
|
||||
$sResult .= '][mobile:true';
|
||||
}
|
||||
|
||||
if (\RainLoop\Utils::IsOwnCloud())
|
||||
{
|
||||
$sResult .= '][owncloud:true';
|
||||
}
|
||||
|
||||
$sResult .= ']-->';
|
||||
}
|
||||
|
||||
// Output result
|
||||
echo $sResult;
|
||||
unset($sResult);
|
||||
|
||||
$this->oActions->BootEnd();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sPath
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function staticPath($sPath)
|
||||
{
|
||||
return $this->oActions->StaticPath($sPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bAdmin = false
|
||||
* @param bool $bMobile = false
|
||||
* @param bool $bMobileDevice = false
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function indexTemplateParameters($bAdmin = false, $bMobile = false, $bMobileDevice = false)
|
||||
{
|
||||
$sLanguage = 'en';
|
||||
$sTheme = 'Default';
|
||||
|
||||
list($sLanguage, $sTheme) = $this->oActions->GetLanguageAndTheme($bAdmin, $bMobile);
|
||||
|
||||
$bAppJsDebug = !!$this->oActions->Config()->Get('labs', 'use_app_debug_js', false);
|
||||
$bAppCssDebug = !!$this->oActions->Config()->Get('labs', 'use_app_debug_css', false);
|
||||
|
||||
$sFaviconUrl = (string) $this->oActions->Config()->Get('webmail', 'favicon_url', '');
|
||||
|
||||
$sFaviconPngLink = $sFaviconUrl ? $sFaviconUrl : $this->staticPath('apple-touch-icon.png');
|
||||
$sAppleTouchLink = $sFaviconUrl ? '' : $this->staticPath('apple-touch-icon.png');
|
||||
|
||||
$sContentSecurityPolicy = $this->oActions->Config()->Get('security', 'content_security_policy', '');
|
||||
|
||||
$aTemplateParameters = array(
|
||||
'{{BaseAppFaviconPngLinkTag}}' => $sFaviconPngLink ? '<link type="image/png" rel="shortcut icon" href="'.$sFaviconPngLink.'" />' : '',
|
||||
'{{BaseAppFaviconTouchLinkTag}}' => $sAppleTouchLink ? '<link type="image/png" rel="apple-touch-icon" href="'.$sAppleTouchLink.'" />' : '',
|
||||
'{{BaseAppMainCssLink}}' => $this->staticPath('css/app'.($bAppCssDebug ? '' : '.min').'.css'),
|
||||
'{{BaseAppThemeCssLink}}' => $this->oActions->ThemeLink($sTheme, $bAdmin),
|
||||
'{{BaseAppBootScriptLink}}' => $this->staticPath('js/'.($bAppJsDebug ? '' : 'min/').'boot'.($bAppJsDebug ? '' : '.min').'.js'),
|
||||
'{{BaseViewport}}' => $bMobile ? 'width=device-width,initial-scale=1,user-scalable=no' : 'width=950,maximum-scale=2',
|
||||
'{{BaseContentSecurityPolicy}}' => $sContentSecurityPolicy ?
|
||||
'<meta http-equiv="Content-Security-Policy" content="'.$sContentSecurityPolicy.'" />' : '',
|
||||
'{{BaseDir}}' => false && \in_array($sLanguage, array('ar', 'he', 'ur')) ? 'rtl' : 'ltr',
|
||||
'{{BaseAppManifestLink}}' => $this->staticPath('manifest.json')
|
||||
);
|
||||
|
||||
$aTemplateParameters['{{RainloopBootData}}'] = \json_encode(array(
|
||||
'admin' => $bAdmin,
|
||||
'language' => $sLanguage,
|
||||
'theme' => $sTheme,
|
||||
'mobile' => $bMobile,
|
||||
'mobileDevice' => $bMobileDevice
|
||||
));
|
||||
|
||||
$aTemplateParameters['{{BaseHash}}'] = \md5(
|
||||
\implode('~', array(
|
||||
$bAdmin ? '1' : '0',
|
||||
\md5($this->oActions->Config()->Get('cache', 'index', '')),
|
||||
$this->oActions->Plugins()->Hash(),
|
||||
\RainLoop\Utils::WebVersionPath(),
|
||||
APP_VERSION,
|
||||
)).
|
||||
\implode('~', $aTemplateParameters)
|
||||
);
|
||||
|
||||
return $aTemplateParameters;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,12 +7,12 @@ var
|
|||
module.exports = function(es6) {
|
||||
return {
|
||||
entry: es6 ? {
|
||||
'app.next': __dirname + '/dev/app.jsx',
|
||||
'admin.next': __dirname + '/dev/admin.jsx'
|
||||
'app.next': __dirname + '/dev/app.js',
|
||||
'admin.next': __dirname + '/dev/admin.js'
|
||||
} : {
|
||||
'boot': __dirname + '/dev/boot.jsx',
|
||||
'app': __dirname + '/dev/app.jsx',
|
||||
'admin': __dirname + '/dev/admin.jsx'
|
||||
'boot': __dirname + '/dev/boot.js',
|
||||
'app': __dirname + '/dev/app.js',
|
||||
'admin': __dirname + '/dev/admin.js'
|
||||
},
|
||||
output: {
|
||||
pathinfo: true,
|
||||
|
@ -25,7 +25,7 @@ module.exports = function(es6) {
|
|||
],
|
||||
resolve: {
|
||||
modules: [devPath, 'node_modules'],
|
||||
extensions: ['', '.js', '.jsx'],
|
||||
extensions: ['', '.js'],
|
||||
alias: {
|
||||
'Opentip': __dirname + '/dev/External/Opentip.js',
|
||||
'ko': __dirname + '/dev/External/ko.js'
|
||||
|
@ -121,5 +121,5 @@ module.exports = function(es6) {
|
|||
'Promise': 'window.Promise',
|
||||
'$': 'window.jQuery'
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue