|
|
@@ -1,5 +1,5 @@
|
|
|
module.exports = function(crowi, app, req, locals) {
|
|
|
- var debug = require('debug')('growi:lib:swigFunctions')
|
|
|
+ const debug = require('debug')('growi:lib:swigFunctions')
|
|
|
, stringWidth = require('string-width')
|
|
|
, Page = crowi.model('Page')
|
|
|
, Config = crowi.model('Config')
|
|
|
@@ -45,15 +45,15 @@ module.exports = function(crowi, app, req, locals) {
|
|
|
* return app title
|
|
|
*/
|
|
|
locals.appTitle = function() {
|
|
|
- var config = crowi.getConfig();
|
|
|
- return Config.appTitle(config);
|
|
|
+ const config = crowi.getConfig();
|
|
|
+ return crowi.xss.process(Config.appTitle(config));
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* return true if enabled
|
|
|
*/
|
|
|
locals.isEnabledPassport = function() {
|
|
|
- var config = crowi.getConfig();
|
|
|
+ const config = crowi.getConfig();
|
|
|
return Config.isEnabledPassport(config);
|
|
|
};
|
|
|
|
|
|
@@ -69,7 +69,7 @@ module.exports = function(crowi, app, req, locals) {
|
|
|
* return true if enabled and strategy has been setup successfully
|
|
|
*/
|
|
|
locals.isLdapSetup = function() {
|
|
|
- var config = crowi.getConfig();
|
|
|
+ let config = crowi.getConfig();
|
|
|
return Config.isEnabledPassport(config) && Config.isEnabledPassportLdap(config) && passportService.isLdapStrategySetup;
|
|
|
};
|
|
|
|
|
|
@@ -77,7 +77,7 @@ module.exports = function(crowi, app, req, locals) {
|
|
|
* return true if enabled but strategy has some problem
|
|
|
*/
|
|
|
locals.isLdapSetupFailed = function() {
|
|
|
- var config = crowi.getConfig();
|
|
|
+ let config = crowi.getConfig();
|
|
|
return Config.isEnabledPassport(config) && Config.isEnabledPassportLdap(config) && !passportService.isLdapStrategySetup;
|
|
|
};
|
|
|
|
|
|
@@ -88,17 +88,17 @@ module.exports = function(crowi, app, req, locals) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- var config = crowi.getConfig();
|
|
|
+ let config = crowi.getConfig();
|
|
|
return config.crowi['google:clientId'] && config.crowi['google:clientSecret'];
|
|
|
};
|
|
|
|
|
|
locals.passportGoogleLoginEnabled = function() {
|
|
|
- var config = crowi.getConfig();
|
|
|
+ let config = crowi.getConfig();
|
|
|
return locals.isEnabledPassport() && config.crowi['security:passport-google:isEnabled'];
|
|
|
};
|
|
|
|
|
|
locals.passportGitHubLoginEnabled = function() {
|
|
|
- var config = crowi.getConfig();
|
|
|
+ let config = crowi.getConfig();
|
|
|
return locals.isEnabledPassport() && config.crowi['security:passport-github:isEnabled'];
|
|
|
};
|
|
|
|
|
|
@@ -110,17 +110,17 @@ module.exports = function(crowi, app, req, locals) {
|
|
|
};
|
|
|
|
|
|
locals.isEnabledPlugins = function() {
|
|
|
- var config = crowi.getConfig();
|
|
|
+ let config = crowi.getConfig();
|
|
|
return Config.isEnabledPlugins(config);
|
|
|
};
|
|
|
|
|
|
locals.isEnabledLinebreaks = function() {
|
|
|
- var config = crowi.getConfig();
|
|
|
+ let config = crowi.getConfig();
|
|
|
return Config.isEnabledLinebreaks(config);
|
|
|
};
|
|
|
|
|
|
locals.isEnabledLinebreaksInComments = function() {
|
|
|
- var config = crowi.getConfig();
|
|
|
+ let config = crowi.getConfig();
|
|
|
return Config.isEnabledLinebreaksInComments(config);
|
|
|
};
|
|
|
|
|
|
@@ -133,12 +133,12 @@ module.exports = function(crowi, app, req, locals) {
|
|
|
};
|
|
|
|
|
|
locals.customHeader = function() {
|
|
|
- var config = crowi.getConfig();
|
|
|
+ let config = crowi.getConfig();
|
|
|
return Config.customHeader(config);
|
|
|
};
|
|
|
|
|
|
locals.theme = function() {
|
|
|
- var config = crowi.getConfig();
|
|
|
+ let config = crowi.getConfig();
|
|
|
return Config.theme(config);
|
|
|
};
|
|
|
|
|
|
@@ -148,37 +148,37 @@ module.exports = function(crowi, app, req, locals) {
|
|
|
};
|
|
|
|
|
|
locals.behaviorType = function() {
|
|
|
- var config = crowi.getConfig();
|
|
|
+ let config = crowi.getConfig();
|
|
|
return Config.behaviorType(config);
|
|
|
};
|
|
|
|
|
|
locals.layoutType = function() {
|
|
|
- var config = crowi.getConfig();
|
|
|
+ let config = crowi.getConfig();
|
|
|
return Config.layoutType(config);
|
|
|
};
|
|
|
|
|
|
locals.highlightJsStyle = function() {
|
|
|
- var config = crowi.getConfig();
|
|
|
+ let config = crowi.getConfig();
|
|
|
return Config.highlightJsStyle(config);
|
|
|
};
|
|
|
|
|
|
locals.highlightJsStyleBorder = function() {
|
|
|
- var config = crowi.getConfig();
|
|
|
+ let config = crowi.getConfig();
|
|
|
return Config.highlightJsStyleBorder(config);
|
|
|
};
|
|
|
|
|
|
locals.isEnabledTimeline = function() {
|
|
|
- var config = crowi.getConfig();
|
|
|
+ let config = crowi.getConfig();
|
|
|
return Config.isEnabledTimeline(config);
|
|
|
};
|
|
|
|
|
|
locals.isUploadable = function() {
|
|
|
- var config = crowi.getConfig();
|
|
|
+ let config = crowi.getConfig();
|
|
|
return Config.isUploadable(config);
|
|
|
};
|
|
|
|
|
|
locals.isEnabledAttachTitleHeader = function() {
|
|
|
- var config = crowi.getConfig();
|
|
|
+ let config = crowi.getConfig();
|
|
|
return Config.isEnabledAttachTitleHeader(config);
|
|
|
};
|
|
|
|
|
|
@@ -203,7 +203,7 @@ module.exports = function(crowi, app, req, locals) {
|
|
|
};
|
|
|
|
|
|
locals.isTopPage = function() {
|
|
|
- var path = req.path || '';
|
|
|
+ let path = req.path || '';
|
|
|
if (path === '/') {
|
|
|
return true;
|
|
|
}
|
|
|
@@ -212,7 +212,7 @@ module.exports = function(crowi, app, req, locals) {
|
|
|
};
|
|
|
|
|
|
locals.isTrashPage = function() {
|
|
|
- var path = req.path || '';
|
|
|
+ let path = req.path || '';
|
|
|
if (path.match(/^\/trash\/.*/)) {
|
|
|
return true;
|
|
|
}
|
|
|
@@ -221,8 +221,8 @@ module.exports = function(crowi, app, req, locals) {
|
|
|
};
|
|
|
|
|
|
locals.isDeletablePage = function() {
|
|
|
- var Page = crowi.model('Page');
|
|
|
- var path = req.path || '';
|
|
|
+ let Page = crowi.model('Page');
|
|
|
+ let path = req.path || '';
|
|
|
|
|
|
return Page.isDeletableName(path);
|
|
|
};
|