Full minification support in all languages.
Ylian Saint-Hilaire committed
May 2, 2020 at 23:49 UTC
aece58b0f9409334d650c095742a442711ed5a4b
3 files changed
+44
-34
package.json
+1
-1
@@ -1,6 +1,6 @@
1
{
2
"name": "meshcentral",
3
- "version": "0.5.20",
3
+ "version": "0.5.21",
4
"keywords": [
5
"Remote Management",
6
"Intel AMT",
translate/translate.js
+11
-3
@@ -175,6 +175,9 @@ function startEx(argv) {
175
log(' TRANSLATEALL (languagefile) (language code)');
176
log(' Translate all MeshCentral strings using the languages.json file.');
177
log('');
178
+ log(' MINIFY [sourcefile]');
179
+ log(' Minify a single file.');
180
+ log('');
181
log(' MINIFYALL');
182
log(' Minify the main MeshCentral english web pages.');
183
log('');
@@ -336,7 +339,7 @@ function startEx(argv) {
339
var inFile = fs.readFileSync(outname).toString();
340
341
// Perform minification pre-processing
339
- if (outname.indexOf('default.handlebars') >= 0) { inFile = inFile.split('{{{pluginHandler}}}').join('"{{{pluginHandler}}}"'); }
342
+ if (outname.endsWith('.handlebars') >= 0) { inFile = inFile.split('{{{pluginHandler}}}').join('"{{{pluginHandler}}}"'); }
343
if (outname.endsWith('.js')) { inFile = '<script>' + inFile + '</script>'; }
344
345
var minifiedOut = minify(inFile, {
@@ -358,7 +361,7 @@ function startEx(argv) {
361
362
// Perform minification post-processing
363
if (outname.endsWith('.js')) { minifiedOut = minifiedOut.substring(8, minifiedOut.length - 9); }
361
- if (outname.indexOf('default.handlebars') >= 0) { minifiedOut = minifiedOut.split('"{{{pluginHandler}}}"').join('{{{pluginHandler}}}'); }
364
+ if (outname.endsWith('.handlebars') >= 0) { minifiedOut = minifiedOut.split('"{{{pluginHandler}}}"').join('{{{pluginHandler}}}'); }
365
366
fs.writeFileSync(outnamemin, minifiedOut, { flag: 'w+' });
367
}
@@ -381,7 +384,9 @@ function startEx(argv) {
384
385
// Minify the file
386
if (minifyLib = 2) {
384
- var minifiedOut = minify(fs.readFileSync(outname).toString(), {
387
+ var inFile = fs.readFileSync(outname).toString()
388
+ if (outname.endsWith('.handlebars') >= 0) { inFile = inFile.split('{{{pluginHandler}}}').join('"{{{pluginHandler}}}"'); }
389
+ var minifiedOut = minify(inFile, {
390
collapseBooleanAttributes: true,
391
collapseInlineTagWhitespace: false, // This is not good.
392
collapseWhitespace: true,
@@ -397,6 +402,7 @@ function startEx(argv) {
402
preserveLineBreaks: false,
403
useShortDoctype: true
404
});
405
+ if (outname.endsWith('.handlebars') >= 0) { minifiedOut = minifiedOut.split('"{{{pluginHandler}}}"').join('{{{pluginHandler}}}'); }
406
fs.writeFileSync(outnamemin, minifiedOut, { flag: 'w+' });
407
}
408
}
@@ -758,6 +764,7 @@ function translateFromHtml(lang, file, createSubDir) {
764
765
// Minify the file
766
if (minifyLib = 2) {
767
+ if (outnamemin.endsWith('.handlebars') >= 0) { out = out.split('{{{pluginHandler}}}').join('"{{{pluginHandler}}}"'); }
768
var minifiedOut = minify(out, {
769
collapseBooleanAttributes: true,
770
collapseInlineTagWhitespace: false, // This is not good.
@@ -774,6 +781,7 @@ function translateFromHtml(lang, file, createSubDir) {
781
preserveLineBreaks: false,
782
useShortDoctype: true
783
});
784
+ if (outnamemin.endsWith('.handlebars') >= 0) { minifiedOut = minifiedOut.split('"{{{pluginHandler}}}"').join('{{{pluginHandler}}}'); }
785
fs.writeFileSync(outnamemin, minifiedOut, { flag: 'w+' });
786
}
787
}
webserver.js
+32
-30
@@ -1376,28 +1376,28 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
1376
var idsplit = cookie.u.split('/');
1377
if ((idsplit.length != 2) || (idsplit[0] != domain.id)) {
1378
parent.debug('web', 'handleCheckMailRequest: Invalid domain.');
1379
- render(req, res, getRenderPage('message', req, domain), getRenderArgs({ titleid: 1, msgid: 1, domainurl: encodeURIComponent(domain.url) }, domain));
1379
+ render(req, res, getRenderPage('message', req, domain), getRenderArgs({ titleid: 1, msgid: 1, domainurl: encodeURIComponent(domain.url) }, req, domain));
1380
} else {
1381
obj.db.Get('user/' + cookie.u.toLowerCase(), function (err, docs) {
1382
if (docs.length == 0) {
1383
parent.debug('web', 'handleCheckMailRequest: Invalid username.');
1384
- render(req, res, getRenderPage('message', req, domain), getRenderArgs({ titleid: 1, msgid: 2, domainurl: encodeURIComponent(domain.url), arg1: encodeURIComponent(idsplit[1]) }, domain));
1384
+ render(req, res, getRenderPage('message', req, domain), getRenderArgs({ titleid: 1, msgid: 2, domainurl: encodeURIComponent(domain.url), arg1: encodeURIComponent(idsplit[1]) }, req, domain));
1385
} else {
1386
var user = docs[0];
1387
if (user.email != cookie.e) {
1388
parent.debug('web', 'handleCheckMailRequest: Invalid e-mail.');
1389
- render(req, res, getRenderPage('message', req, domain), getRenderArgs({ titleid: 1, msgid: 3, domainurl: encodeURIComponent(domain.url), arg1: encodeURIComponent(user.email), arg2: encodeURIComponent(user.name) }, domain));
1389
+ render(req, res, getRenderPage('message', req, domain), getRenderArgs({ titleid: 1, msgid: 3, domainurl: encodeURIComponent(domain.url), arg1: encodeURIComponent(user.email), arg2: encodeURIComponent(user.name) }, req, domain));
1390
} else {
1391
if (cookie.a == 1) {
1392
// Account email verification
1393
if (user.emailVerified == true) {
1394
parent.debug('web', 'handleCheckMailRequest: email already verified.');
1395
- render(req, res, getRenderPage('message', req, domain), getRenderArgs({ titleid: 1, msgid: 4, domainurl: encodeURIComponent(domain.url), arg1: encodeURIComponent(user.email), arg2: encodeURIComponent(user.name) }, domain));
1395
+ render(req, res, getRenderPage('message', req, domain), getRenderArgs({ titleid: 1, msgid: 4, domainurl: encodeURIComponent(domain.url), arg1: encodeURIComponent(user.email), arg2: encodeURIComponent(user.name) }, req, domain));
1396
} else {
1397
obj.db.GetUserWithVerifiedEmail(domain.id, user.email, function (err, docs) {
1398
if (docs.length > 0) {
1399
parent.debug('web', 'handleCheckMailRequest: email already in use.');
1400
- render(req, res, getRenderPage('message', req, domain), getRenderArgs({ titleid: 1, msgid: 5, domainurl: encodeURIComponent(domain.url), arg1: encodeURIComponent(user.email) }, domain));
1400
+ render(req, res, getRenderPage('message', req, domain), getRenderArgs({ titleid: 1, msgid: 5, domainurl: encodeURIComponent(domain.url), arg1: encodeURIComponent(user.email) }, req, domain));
1401
} else {
1402
parent.debug('web', 'handleCheckMailRequest: email verification success.');
1403
@@ -1412,7 +1412,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
1412
obj.parent.DispatchEvent(['*', 'server-users', user._id], obj, event);
1413
1414
// Send the confirmation page
1415
- render(req, res, getRenderPage('message', req, domain), getRenderArgs({ titleid: 1, msgid: 6, domainurl: encodeURIComponent(domain.url), arg1: encodeURIComponent(user.email), arg2: encodeURIComponent(user.name) }, domain));
1415
+ render(req, res, getRenderPage('message', req, domain), getRenderArgs({ titleid: 1, msgid: 6, domainurl: encodeURIComponent(domain.url), arg1: encodeURIComponent(user.email), arg2: encodeURIComponent(user.name) }, req, domain));
1416
1417
// Send a notification
1418
obj.parent.DispatchEvent([user._id], obj, { action: 'notify', value: 'Email verified:<br /><b>' + EscapeHtml(user.email) + '</b>.', nolog: 1, id: Math.random() });
@@ -1426,7 +1426,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
1426
// Account reset
1427
if (user.emailVerified != true) {
1428
parent.debug('web', 'handleCheckMailRequest: email not verified.');
1429
- render(req, res, getRenderPage('message', req, domain), getRenderArgs({ titleid: 1, msgid: 7, domainurl: encodeURIComponent(domain.url), arg1: EscapeHtml(user.email), arg2: EscapeHtml(user.name) }, domain));
1429
+ render(req, res, getRenderPage('message', req, domain), getRenderArgs({ titleid: 1, msgid: 7, domainurl: encodeURIComponent(domain.url), arg1: EscapeHtml(user.email), arg2: EscapeHtml(user.name) }, req, domain));
1430
} else {
1431
// Set a temporary password
1432
obj.crypto.randomBytes(16, function (err, buf) {
@@ -1451,7 +1451,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
1451
obj.parent.DispatchEvent(['*', 'server-users', user._id], obj, event);
1452
1453
// Send the new password
1454
- render(req, res, getRenderPage('message', req, domain), getRenderArgs({ titleid: 1, msgid: 8, domainurl: encodeURIComponent(domain.url), arg1: EscapeHtml(user.name), arg2: EscapeHtml(newpass) }, domain));
1454
+ render(req, res, getRenderPage('message', req, domain), getRenderArgs({ titleid: 1, msgid: 8, domainurl: encodeURIComponent(domain.url), arg1: EscapeHtml(user.name), arg2: EscapeHtml(newpass) }, req, domain));
1455
parent.debug('web', 'handleCheckMailRequest: send temporary password.');
1456
1457
// Send to authlog
@@ -1460,14 +1460,14 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
1460
});
1461
}
1462
} else {
1463
- render(req, res, getRenderPage('message', req, domain), getRenderArgs({ titleid: 1, msgid: 9, domainurl: encodeURIComponent(domain.url) }, domain));
1463
+ render(req, res, getRenderPage('message', req, domain), getRenderArgs({ titleid: 1, msgid: 9, domainurl: encodeURIComponent(domain.url) }, req, domain));
1464
}
1465
}
1466
}
1467
});
1468
}
1469
} else {
1470
- render(req, res, getRenderPage('message', req, domain), getRenderArgs({ titleid: 1, msgid: 10, domainurl: encodeURIComponent(domain.url) }, domain));
1470
+ render(req, res, getRenderPage('message', req, domain), getRenderArgs({ titleid: 1, msgid: 10, domainurl: encodeURIComponent(domain.url) }, req, domain));
1471
}
1472
}
1473
}
@@ -1477,7 +1477,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
1477
const domain = getDomain(req);
1478
if (domain == null) { parent.debug('web', 'handleInviteRequest: failed checks.'); res.sendStatus(404); return; }
1479
if ((domain.loginkey != null) && (domain.loginkey.indexOf(req.query.key) == -1)) { res.sendStatus(404); return; } // Check 3FA URL key
1480
- if ((req.body.inviteCode == null) || (req.body.inviteCode == '')) { render(req, res, getRenderPage('invite', req, domain), getRenderArgs({ messageid: 0 }, domain)); return; } // No invitation code
1480
+ if ((req.body.inviteCode == null) || (req.body.inviteCode == '')) { render(req, res, getRenderPage('invite', req, domain), getRenderArgs({ messageid: 0 }, req, domain)); return; } // No invitation code
1481
1482
// Each for a device group that has this invite code.
1483
for (var i in obj.meshes) {
@@ -1488,7 +1488,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
1488
}
1489
}
1490
1491
- render(req, res, getRenderPage('invite', req, domain), getRenderArgs({ messageid: 100 }, domain)); // Bad invitation code
1491
+ render(req, res, getRenderPage('invite', req, domain), getRenderArgs({ messageid: 100 }, req, domain)); // Bad invitation code
1492
}
1493
1494
// Called to process an agent invite request
@@ -1506,7 +1506,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
1506
var installflags = cookie.f;
1507
if (typeof installflags != 'number') { installflags = 0; }
1508
parent.debug('web', 'handleAgentInviteRequest using cookie.');
1509
- render(req, res, getRenderPage('agentinvite', req, domain), getRenderArgs({ meshid: mesh._id.split('/')[2], serverport: ((args.aliasport != null) ? args.aliasport : args.port), serverhttps: ((args.notls == true) ? '0' : '1'), servernoproxy: ((domain.agentnoproxy === true) ? '1' : '0'), meshname: encodeURIComponent(mesh.name).split('\'').join('%27'), installflags: installflags }, domain));
1509
+ render(req, res, getRenderPage('agentinvite', req, domain), getRenderArgs({ meshid: mesh._id.split('/')[2], serverport: ((args.aliasport != null) ? args.aliasport : args.port), serverhttps: ((args.notls == true) ? '0' : '1'), servernoproxy: ((domain.agentnoproxy === true) ? '1' : '0'), meshname: encodeURIComponent(mesh.name).split('\'').join('%27'), installflags: installflags }, req, domain));
1510
} else if (req.query.m != null) {
1511
// The MeshId is specified in the query string, use that
1512
var mesh = obj.meshes['mesh/' + domain.id + '/' + req.query.m.toLowerCase()];
@@ -1515,7 +1515,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
1515
if (req.query.f) { installflags = parseInt(req.query.f); }
1516
if (typeof installflags != 'number') { installflags = 0; }
1517
parent.debug('web', 'handleAgentInviteRequest using meshid.');
1518
- render(req, res, getRenderPage('agentinvite', req, domain), getRenderArgs({ meshid: mesh._id.split('/')[2], serverport: ((args.aliasport != null) ? args.aliasport : args.port), serverhttps: ((args.notls == true) ? '0' : '1'), servernoproxy: ((domain.agentnoproxy === true) ? '1' : '0'), meshname: encodeURIComponent(mesh.name).split('\'').join('%27'), installflags: installflags }, domain));
1518
+ render(req, res, getRenderPage('agentinvite', req, domain), getRenderArgs({ meshid: mesh._id.split('/')[2], serverport: ((args.aliasport != null) ? args.aliasport : args.port), serverhttps: ((args.notls == true) ? '0' : '1'), servernoproxy: ((domain.agentnoproxy === true) ? '1' : '0'), meshname: encodeURIComponent(mesh.name).split('\'').join('%27'), installflags: installflags }, req, domain));
1519
}
1520
}
1521
@@ -1904,7 +1904,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
1904
for (var i in domain.forceduserwebstate) { webstate2[i] = domain.forceduserwebstate[i]; }
1905
webstate = JSON.stringify(webstate2);
1906
}
1907
- render(req, res, getRenderPage('default', req, domain), getRenderArgs({ authCookie: authCookie, authRelayCookie: authRelayCookie, viewmode: viewmode, currentNode: currentNode, logoutControls: encodeURIComponent(JSON.stringify(logoutcontrols)), domain: domain.id, debuglevel: parent.debugLevel, serverDnsName: obj.getWebServerName(domain), serverRedirPort: args.redirport, serverPublicPort: httpsPort, noServerBackup: (args.noserverbackup == 1 ? 1 : 0), features: features, sessiontime: args.sessiontime, mpspass: args.mpspass, passRequirements: passRequirements, webcerthash: Buffer.from(obj.webCertificateFullHashs[domain.id], 'binary').toString('base64').replace(/\+/g, '@').replace(/\//g, '$'), footer: (domain.footer == null) ? '' : domain.footer, webstate: encodeURIComponent(webstate), pluginHandler: (parent.pluginHandler == null) ? 'null' : parent.pluginHandler.prepExports() }, domain));
1907
+ render(req, res, getRenderPage('default', req, domain), getRenderArgs({ authCookie: authCookie, authRelayCookie: authRelayCookie, viewmode: viewmode, currentNode: currentNode, logoutControls: encodeURIComponent(JSON.stringify(logoutcontrols)), domain: domain.id, debuglevel: parent.debugLevel, serverDnsName: obj.getWebServerName(domain), serverRedirPort: args.redirport, serverPublicPort: httpsPort, noServerBackup: (args.noserverbackup == 1 ? 1 : 0), features: features, sessiontime: args.sessiontime, mpspass: args.mpspass, passRequirements: passRequirements, webcerthash: Buffer.from(obj.webCertificateFullHashs[domain.id], 'binary').toString('base64').replace(/\+/g, '@').replace(/\//g, '$'), footer: (domain.footer == null) ? '' : domain.footer, webstate: encodeURIComponent(webstate), pluginHandler: (parent.pluginHandler == null) ? 'null' : parent.pluginHandler.prepExports() }, req, domain));
1908
});
1909
} else {
1910
// Send back the login application
@@ -1981,7 +1981,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
1981
if (typeof domain.twofactorcookiedurationdays == 'number') { twoFactorCookieDays = domain.twofactorcookiedurationdays; }
1982
1983
// Render the login page
1984
- render(req, res, getRenderPage('login', req, domain), getRenderArgs({ loginmode: loginmode, rootCertLink: getRootCertLink(), newAccount: newAccountsAllowed, newAccountPass: (((domain.newaccountspass == null) || (domain.newaccountspass == '')) ? 0 : 1), serverDnsName: obj.getWebServerName(domain), serverPublicPort: httpsPort, emailcheck: emailcheck, features: features, sessiontime: args.sessiontime, passRequirements: passRequirements, footer: (domain.footer == null) ? '' : domain.footer, hkey: encodeURIComponent(hardwareKeyChallenge), messageid: msgid, passhint: passhint, welcometext: domain.welcometext ? encodeURIComponent(domain.welcometext).split('\'').join('\\\'') : null, hwstate: hwstate, otpemail: otpemail, otpsms: otpsms, twoFactorCookieDays: twoFactorCookieDays }, domain));
1984
+ render(req, res, getRenderPage('login', req, domain), getRenderArgs({ loginmode: loginmode, rootCertLink: getRootCertLink(), newAccount: newAccountsAllowed, newAccountPass: (((domain.newaccountspass == null) || (domain.newaccountspass == '')) ? 0 : 1), serverDnsName: obj.getWebServerName(domain), serverPublicPort: httpsPort, emailcheck: emailcheck, features: features, sessiontime: args.sessiontime, passRequirements: passRequirements, footer: (domain.footer == null) ? '' : domain.footer, hkey: encodeURIComponent(hardwareKeyChallenge), messageid: msgid, passhint: passhint, welcometext: domain.welcometext ? encodeURIComponent(domain.welcometext).split('\'').join('\\\'') : null, hwstate: hwstate, otpemail: otpemail, otpsms: otpsms, twoFactorCookieDays: twoFactorCookieDays }, req, domain));
1985
}
1986
1987
// Handle a post request on the root
@@ -2054,7 +2054,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
2054
const authCookie = obj.parent.encodeCookie({ userid: user._id, domainid: domain.id, ip: cleanRemoteAddr(req.ip) }, obj.parent.loginCookieEncryptionKey);
2055
const authRelayCookie = obj.parent.encodeCookie({ ruserid: user._id, domainid: domain.id }, obj.parent.loginCookieEncryptionKey);
2056
var httpsPort = ((obj.args.aliasport == null) ? obj.args.port : obj.args.aliasport); // Use HTTPS alias port is specified
2057
- render(req, res, getRenderPage('xterm', req, domain), getRenderArgs({ serverDnsName: obj.getWebServerName(domain), serverRedirPort: args.redirport, serverPublicPort: httpsPort, authCookie: authCookie, authRelayCookie: authRelayCookie, logoutControls: encodeURIComponent(JSON.stringify(logoutcontrols)), name: EscapeHtml(node.name) }, domain));
2057
+ render(req, res, getRenderPage('xterm', req, domain), getRenderArgs({ serverDnsName: obj.getWebServerName(domain), serverRedirPort: args.redirport, serverPublicPort: httpsPort, authCookie: authCookie, authRelayCookie: authRelayCookie, logoutControls: encodeURIComponent(JSON.stringify(logoutcontrols)), name: EscapeHtml(node.name) }, req, domain));
2058
});
2059
} else {
2060
res.redirect(domain.url + getQueryPortion(req));
@@ -2078,9 +2078,9 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
2078
var logoutcontrols = { name: user.name };
2079
var extras = (req.query.key != null) ? ('&key=' + req.query.key) : '';
2080
if ((domain.ldap == null) && (domain.sspi == null) && (obj.args.user == null) && (obj.args.nousers != true)) { logoutcontrols.logoutUrl = (domain.url + 'logout?' + Math.random() + extras); } // If a default user is in use or no user mode, don't display the logout button
2081
- render(req, res, getRenderPage('terms', req, domain), getRenderArgs({ terms: encodeURIComponent(parent.configurationFiles['terms.txt'].toString()).split('\'').join('\\\''), logoutControls: encodeURIComponent(JSON.stringify(logoutcontrols)) }, domain));
2081
+ render(req, res, getRenderPage('terms', req, domain), getRenderArgs({ terms: encodeURIComponent(parent.configurationFiles['terms.txt'].toString()).split('\'').join('\\\''), logoutControls: encodeURIComponent(JSON.stringify(logoutcontrols)) }, req, domain));
2082
} else {
2083
- render(req, res, getRenderPage('terms', req, domain), getRenderArgs({ terms: encodeURIComponent(parent.configurationFiles['terms.txt'].toString()).split('\'').join('\\\''), logoutControls: encodeURIComponent('{}') }, domain));
2083
+ render(req, res, getRenderPage('terms', req, domain), getRenderArgs({ terms: encodeURIComponent(parent.configurationFiles['terms.txt'].toString()).split('\'').join('\\\''), logoutControls: encodeURIComponent('{}') }, req, domain));
2084
}
2085
} else {
2086
// See if there is a terms.txt file in meshcentral-data
@@ -2097,9 +2097,9 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
2097
var logoutcontrols = { name: user.name };
2098
var extras = (req.query.key != null) ? ('&key=' + req.query.key) : '';
2099
if ((domain.ldap == null) && (domain.sspi == null) && (obj.args.user == null) && (obj.args.nousers != true)) { logoutcontrols.logoutUrl = (domain.url + 'logout?' + Math.random() + extras); } // If a default user is in use or no user mode, don't display the logout button
2100
- render(req, res, getRenderPage('terms', req, domain), getRenderArgs({ terms: encodeURIComponent(data).split('\'').join('\\\''), logoutControls: encodeURIComponent(JSON.stringify(logoutcontrols)) }, domain));
2100
+ render(req, res, getRenderPage('terms', req, domain), getRenderArgs({ terms: encodeURIComponent(data).split('\'').join('\\\''), logoutControls: encodeURIComponent(JSON.stringify(logoutcontrols)) }, req, domain));
2101
} else {
2102
- render(req, res, getRenderPage('terms', req, domain), getRenderArgs({ terms: encodeURIComponent(data).split('\'').join('\\\''), logoutControls: encodeURIComponent('{}') }, domain));
2102
+ render(req, res, getRenderPage('terms', req, domain), getRenderArgs({ terms: encodeURIComponent(data).split('\'').join('\\\''), logoutControls: encodeURIComponent('{}') }, req, domain));
2103
}
2104
});
2105
} else {
@@ -2112,9 +2112,9 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
2112
var logoutcontrols = { name: user.name };
2113
var extras = (req.query.key != null) ? ('&key=' + req.query.key) : '';
2114
if ((domain.ldap == null) && (domain.sspi == null) && (obj.args.user == null) && (obj.args.nousers != true)) { logoutcontrols.logoutUrl = (domain.url + 'logout?' + Math.random() + extras); } // If a default user is in use or no user mode, don't display the logout button
2115
- render(req, res, getRenderPage('terms', req, domain), getRenderArgs({ logoutControls: encodeURIComponent(JSON.stringify(logoutcontrols)) }, domain));
2115
+ render(req, res, getRenderPage('terms', req, domain), getRenderArgs({ logoutControls: encodeURIComponent(JSON.stringify(logoutcontrols)) }, req, domain));
2116
} else {
2117
- render(req, res, getRenderPage('terms', req, domain), getRenderArgs({ logoutControls: encodeURIComponent('{}') }, domain));
2117
+ render(req, res, getRenderPage('terms', req, domain), getRenderArgs({ logoutControls: encodeURIComponent('{}') }, req, domain));
2118
}
2119
}
2120
}
@@ -2129,7 +2129,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
2129
var webRtcConfig = null;
2130
if (obj.parent.config.settings && obj.parent.config.settings.webrtconfig && (typeof obj.parent.config.settings.webrtconfig == 'object')) { webRtcConfig = encodeURIComponent(JSON.stringify(obj.parent.config.settings.webrtconfig)); }
2131
res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0' });
2132
- render(req, res, getRenderPage('messenger', req, domain), getRenderArgs({ webrtconfig: webRtcConfig }, domain));
2132
+ render(req, res, getRenderPage('messenger', req, domain), getRenderArgs({ webrtconfig: webRtcConfig }, req, domain));
2133
}
2134
2135
// Returns the server root certificate encoded in base64
@@ -2290,10 +2290,10 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
2290
}
2291
try { res.sendFile(obj.path.resolve(__dirname, path)); } catch (e) { res.sendStatus(404); }
2292
} else {
2293
- render(req, res, getRenderPage('download', req, domain), getRenderArgs({ rootCertLink: getRootCertLink(), message: "<a href='" + req.path + "?download=1'>" + filename + "</a>, " + stat.size + " byte" + ((stat.size < 2) ? '' : 's') + "." }, domain));
2293
+ render(req, res, getRenderPage('download', req, domain), getRenderArgs({ rootCertLink: getRootCertLink(), message: "<a href='" + req.path + "?download=1'>" + filename + "</a>, " + stat.size + " byte" + ((stat.size < 2) ? '' : 's') + "." }, req, domain));
2294
}
2295
} else {
2296
- render(req, res, getRenderPage('download', req, domain), getRenderArgs({ rootCertLink: getRootCertLink(), message: "Invalid file link, please check the URL again." }, domain));
2296
+ render(req, res, getRenderPage('download', req, domain), getRenderArgs({ rootCertLink: getRootCertLink(), message: "Invalid file link, please check the URL again." }, req, domain));
2297
}
2298
}
2299
@@ -2442,7 +2442,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
2442
2443
parent.debug('web', 'handlePlayerRequest: sending player');
2444
res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0' });
2445
- render(req, res, getRenderPage('player', req, domain), getRenderArgs({}, domain));
2445
+ render(req, res, getRenderPage('player', req, domain), getRenderArgs({}, req, domain));
2446
}
2447
2448
// Handle domain redirection
@@ -4026,7 +4026,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
4026
var domain = getDomain(req);
4027
if ((domain == null) || (domain.auth == 'sspi')) { res.sendStatus(404); return; }
4028
if ((domain.loginkey != null) && (domain.loginkey.indexOf(req.query.key) == -1)) { res.sendStatus(404); return; } // Check 3FA URL key
4029
- res.status(404).render(getRenderPage('error404', req, domain), getRenderArgs({}, domain));
4029
+ res.status(404).render(getRenderPage('error404', req, domain), getRenderArgs({}, req, domain));
4030
});
4031
}
4032
@@ -4798,8 +4798,10 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
4798
}
4799
4800
// Return the correct render page arguments.
4801
- function getRenderArgs(xargs, domain) {
4802
- xargs.min = domain.minify?'-min':'';
4801
+ function getRenderArgs(xargs, req, domain) {
4802
+ var minify = (domain.minify == true);
4803
+ if (req.query.minify == '1') { minify = true; } else if (req.query.minify == '0') { minify = false; }
4804
+ xargs.min = minify ? '-min' : '';
4805
xargs.titlehtml = domain.titlehtml;
4806
xargs.title = (domain.title != null) ? domain.title : 'MeshCentral';
4807
if ((domain.titlepicture == null) && (domain.titlehtml == null)) {