|
|
@@ -40,7 +40,8 @@ module.exports = function(crowi) {
|
|
|
/**
|
|
|
* default values when migrated from Official Crowi
|
|
|
*/
|
|
|
- function getDefaultCrowiConfigs() {
|
|
|
+ function getDefaultCrowiConfigs()
|
|
|
+ {
|
|
|
return {
|
|
|
//'app:installed' : "0.0.0",
|
|
|
'app:title': 'Crowi',
|
|
|
@@ -98,7 +99,7 @@ module.exports = function(crowi) {
|
|
|
return {
|
|
|
'markdown:isEnabledLinebreaks': true,
|
|
|
'markdown:isEnabledLinebreaksInComments': true,
|
|
|
- };
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
function getValueForCrowiNS(config, key) {
|
|
|
@@ -110,7 +111,8 @@ module.exports = function(crowi) {
|
|
|
return config.crowi[key];
|
|
|
}
|
|
|
|
|
|
- configSchema.statics.getRestrictGuestModeLabels = function() {
|
|
|
+ configSchema.statics.getRestrictGuestModeLabels = function()
|
|
|
+ {
|
|
|
var labels = {};
|
|
|
labels[SECURITY_RESTRICT_GUEST_MODE_DENY] = 'アカウントを持たないユーザーはアクセス不可';
|
|
|
labels[SECURITY_RESTRICT_GUEST_MODE_READONLY] = '閲覧のみ許可';
|
|
|
@@ -118,7 +120,8 @@ module.exports = function(crowi) {
|
|
|
return labels;
|
|
|
};
|
|
|
|
|
|
- configSchema.statics.getRegistrationModeLabels = function() {
|
|
|
+ configSchema.statics.getRegistrationModeLabels = function()
|
|
|
+ {
|
|
|
var labels = {};
|
|
|
labels[SECURITY_REGISTRATION_MODE_OPEN] = '公開 (だれでも登録可能)';
|
|
|
labels[SECURITY_REGISTRATION_MODE_RESTRICTED] = '制限 (登録完了には管理者の承認が必要)';
|
|
|
@@ -127,7 +130,8 @@ module.exports = function(crowi) {
|
|
|
return labels;
|
|
|
};
|
|
|
|
|
|
- configSchema.statics.updateConfigCache = function(ns, config) {
|
|
|
+ configSchema.statics.updateConfigCache = function(ns, config)
|
|
|
+ {
|
|
|
var originalConfig = crowi.getConfig();
|
|
|
var newNSConfig = originalConfig[ns] || {};
|
|
|
Object.keys(config).forEach(function(key) {
|
|
|
@@ -145,9 +149,10 @@ module.exports = function(crowi) {
|
|
|
};
|
|
|
|
|
|
// Execute only once for installing application
|
|
|
- configSchema.statics.applicationInstall = function(callback) {
|
|
|
+ configSchema.statics.applicationInstall = function(callback)
|
|
|
+ {
|
|
|
var Config = this;
|
|
|
- Config.count({ ns: 'crowi' }, function(err, count) {
|
|
|
+ Config.count({ ns: 'crowi' }, function (err, count) {
|
|
|
if (count > 0) {
|
|
|
return callback(new Error('Application already installed'), null);
|
|
|
}
|
|
|
@@ -159,7 +164,8 @@ module.exports = function(crowi) {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
- configSchema.statics.setupCofigFormData = function(ns, config) {
|
|
|
+ configSchema.statics.setupCofigFormData = function(ns, config)
|
|
|
+ {
|
|
|
var defaultConfig = {};
|
|
|
|
|
|
// set Default Settings
|
|
|
@@ -173,7 +179,7 @@ module.exports = function(crowi) {
|
|
|
if (!defaultConfig[ns]) {
|
|
|
defaultConfig[ns] = {};
|
|
|
}
|
|
|
- Object.keys(config[ns] || {}).forEach(function(key) {
|
|
|
+ Object.keys(config[ns] || {}).forEach(function (key) {
|
|
|
if (config[ns][key] !== undefined) {
|
|
|
defaultConfig[key] = config[ns][key];
|
|
|
}
|
|
|
@@ -182,43 +188,47 @@ module.exports = function(crowi) {
|
|
|
};
|
|
|
|
|
|
|
|
|
- configSchema.statics.updateNamespaceByArray = function(ns, configs, callback) {
|
|
|
+ configSchema.statics.updateNamespaceByArray = function(ns, configs, callback)
|
|
|
+ {
|
|
|
var Config = this;
|
|
|
if (configs.length < 0) {
|
|
|
return callback(new Error('Argument #1 is not array.'), null);
|
|
|
}
|
|
|
|
|
|
- Object.keys(configs).forEach(function(key) {
|
|
|
+ Object.keys(configs).forEach(function (key) {
|
|
|
var value = configs[key];
|
|
|
|
|
|
Config.findOneAndUpdate(
|
|
|
{ ns: ns, key: key },
|
|
|
{ ns: ns, key: key, value: JSON.stringify(value) },
|
|
|
{ upsert: true, },
|
|
|
- function(err, config) {
|
|
|
+ function (err, config) {
|
|
|
debug('Config.findAndUpdate', err, config);
|
|
|
- });
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
return callback(null, configs);
|
|
|
};
|
|
|
|
|
|
- configSchema.statics.findAndUpdate = function(ns, key, value, callback) {
|
|
|
+ configSchema.statics.findAndUpdate = function(ns, key, value, callback)
|
|
|
+ {
|
|
|
var Config = this;
|
|
|
Config.findOneAndUpdate(
|
|
|
{ ns: ns, key: key },
|
|
|
{ ns: ns, key: key, value: JSON.stringify(value) },
|
|
|
{ upsert: true, },
|
|
|
- function(err, config) {
|
|
|
+ function (err, config) {
|
|
|
debug('Config.findAndUpdate', err, config);
|
|
|
callback(err, config);
|
|
|
- });
|
|
|
+ });
|
|
|
};
|
|
|
|
|
|
- configSchema.statics.getConfig = function(callback) {
|
|
|
+ configSchema.statics.getConfig = function(callback)
|
|
|
+ {
|
|
|
};
|
|
|
|
|
|
- configSchema.statics.loadAllConfig = function(callback) {
|
|
|
+ configSchema.statics.loadAllConfig = function(callback)
|
|
|
+ {
|
|
|
var Config = this
|
|
|
, config = {};
|
|
|
config.crowi = {}; // crowi namespace
|
|
|
@@ -244,7 +254,8 @@ module.exports = function(crowi) {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
- configSchema.statics.isEnabledPassport = function(config) {
|
|
|
+ configSchema.statics.isEnabledPassport = function(config)
|
|
|
+ {
|
|
|
// always true if crowi-plus installed cleanly
|
|
|
if (Object.keys(config.crowi).length == 0) {
|
|
|
return true;
|
|
|
@@ -254,16 +265,18 @@ module.exports = function(crowi) {
|
|
|
return getValueForCrowiNS(config, key);
|
|
|
};
|
|
|
|
|
|
- configSchema.statics.isEnabledPassportLdap = function(config) {
|
|
|
+ configSchema.statics.isEnabledPassportLdap = function(config)
|
|
|
+ {
|
|
|
const key = 'security:passport-ldap:isEnabled';
|
|
|
return getValueForCrowiNS(config, key);
|
|
|
};
|
|
|
|
|
|
- configSchema.statics.isUploadable = function(config) {
|
|
|
+ configSchema.statics.isUploadable = function(config)
|
|
|
+ {
|
|
|
var method = crowi.env.FILE_UPLOAD || 'aws';
|
|
|
|
|
|
if (method == 'aws' && (
|
|
|
- !config.crowi['aws:accessKeyId'] ||
|
|
|
+ !config.crowi['aws:accessKeyId'] ||
|
|
|
!config.crowi['aws:secretAccessKey'] ||
|
|
|
!config.crowi['aws:region'] ||
|
|
|
!config.crowi['aws:bucket'])) {
|
|
|
@@ -273,7 +286,8 @@ module.exports = function(crowi) {
|
|
|
return method != 'none';
|
|
|
};
|
|
|
|
|
|
- configSchema.statics.isGuesstAllowedToRead = function(config) {
|
|
|
+ configSchema.statics.isGuesstAllowedToRead = function(config)
|
|
|
+ {
|
|
|
// return false if undefined
|
|
|
if (undefined === config.crowi || undefined === config.crowi['security:restrictGuestMode']) {
|
|
|
return false;
|
|
|
@@ -282,12 +296,14 @@ module.exports = function(crowi) {
|
|
|
return SECURITY_RESTRICT_GUEST_MODE_READONLY === config.crowi['security:restrictGuestMode'];
|
|
|
};
|
|
|
|
|
|
- configSchema.statics.isEnabledPlugins = function(config) {
|
|
|
+ configSchema.statics.isEnabledPlugins = function(config)
|
|
|
+ {
|
|
|
const key = 'plugin:isEnabledPlugins';
|
|
|
return getValueForCrowiNS(config, key);
|
|
|
};
|
|
|
|
|
|
- configSchema.statics.isEnabledLinebreaks = function(config) {
|
|
|
+ configSchema.statics.isEnabledLinebreaks = function(config)
|
|
|
+ {
|
|
|
const key = 'markdown:isEnabledLinebreaks';
|
|
|
|
|
|
// return default value if undefined
|
|
|
@@ -298,7 +314,8 @@ module.exports = function(crowi) {
|
|
|
return config.markdown[key];
|
|
|
};
|
|
|
|
|
|
- configSchema.statics.isEnabledLinebreaksInComments = function(config) {
|
|
|
+ configSchema.statics.isEnabledLinebreaksInComments = function(config)
|
|
|
+ {
|
|
|
const key = 'markdown:isEnabledLinebreaksInComments';
|
|
|
|
|
|
// return default value if undefined
|
|
|
@@ -312,69 +329,82 @@ module.exports = function(crowi) {
|
|
|
/**
|
|
|
* initialize custom css strings
|
|
|
*/
|
|
|
- configSchema.statics.initCustomCss = function(config) {
|
|
|
+ configSchema.statics.initCustomCss = function(config)
|
|
|
+ {
|
|
|
const key = 'customize:css';
|
|
|
const rawCss = getValueForCrowiNS(config, key);
|
|
|
// uglify and store
|
|
|
this._customCss = uglifycss.processString(rawCss);
|
|
|
- };
|
|
|
+ }
|
|
|
|
|
|
- configSchema.statics.customCss = function(config) {
|
|
|
+ configSchema.statics.customCss = function(config)
|
|
|
+ {
|
|
|
return this._customCss;
|
|
|
- };
|
|
|
+ }
|
|
|
|
|
|
- configSchema.statics.initCustomScript = function(config) {
|
|
|
+ configSchema.statics.initCustomScript = function(config)
|
|
|
+ {
|
|
|
const key = 'customize:script';
|
|
|
const rawScript = getValueForCrowiNS(config, key);
|
|
|
// store as is
|
|
|
this._customScript = rawScript;
|
|
|
- };
|
|
|
+ }
|
|
|
|
|
|
- configSchema.statics.customScript = function(config) {
|
|
|
+ configSchema.statics.customScript = function(config)
|
|
|
+ {
|
|
|
return this._customScript;
|
|
|
- };
|
|
|
+ }
|
|
|
|
|
|
- configSchema.statics.customHeader = function(config) {
|
|
|
+ configSchema.statics.customHeader = function(config)
|
|
|
+ {
|
|
|
const key = 'customize:header';
|
|
|
return getValueForCrowiNS(config, key);
|
|
|
- };
|
|
|
+ }
|
|
|
|
|
|
- configSchema.statics.customTitle = function(config) {
|
|
|
+ configSchema.statics.customTitle = function(config)
|
|
|
+ {
|
|
|
const key = 'customize:title';
|
|
|
return getValueForCrowiNS(config, key);
|
|
|
- };
|
|
|
+ }
|
|
|
|
|
|
- configSchema.statics.behaviorType = function(config) {
|
|
|
+ configSchema.statics.behaviorType = function(config)
|
|
|
+ {
|
|
|
const key = 'customize:behavior';
|
|
|
return getValueForCrowiNS(config, key);
|
|
|
- };
|
|
|
+ }
|
|
|
|
|
|
- configSchema.statics.layoutType = function(config) {
|
|
|
+ configSchema.statics.layoutType = function(config)
|
|
|
+ {
|
|
|
const key = 'customize:layout';
|
|
|
return getValueForCrowiNS(config, key);
|
|
|
- };
|
|
|
+ }
|
|
|
|
|
|
- configSchema.statics.highlightJsStyle = function(config) {
|
|
|
+ configSchema.statics.highlightJsStyle = function(config)
|
|
|
+ {
|
|
|
const key = 'customize:highlightJsStyle';
|
|
|
return getValueForCrowiNS(config, key);
|
|
|
- };
|
|
|
+ }
|
|
|
|
|
|
- configSchema.statics.highlightJsStyleBorder = function(config) {
|
|
|
+ configSchema.statics.highlightJsStyleBorder = function(config)
|
|
|
+ {
|
|
|
const key = 'customize:highlightJsStyleBorder';
|
|
|
return getValueForCrowiNS(config, key);
|
|
|
- };
|
|
|
+ }
|
|
|
|
|
|
- configSchema.statics.isEnabledTimeline = function(config) {
|
|
|
+ configSchema.statics.isEnabledTimeline = function(config)
|
|
|
+ {
|
|
|
const key = 'customize:isEnabledTimeline';
|
|
|
return getValueForCrowiNS(config, key);
|
|
|
- };
|
|
|
+ }
|
|
|
|
|
|
- configSchema.statics.isSavedStatesOfTabChanges = function(config) {
|
|
|
+ configSchema.statics.isSavedStatesOfTabChanges = function(config)
|
|
|
+ {
|
|
|
const key = 'customize:isSavedStatesOfTabChanges';
|
|
|
return getValueForCrowiNS(config, key);
|
|
|
- };
|
|
|
+ }
|
|
|
|
|
|
- configSchema.statics.fileUploadEnabled = function(config) {
|
|
|
+ configSchema.statics.fileUploadEnabled = function(config)
|
|
|
+ {
|
|
|
const Config = this;
|
|
|
|
|
|
if (!Config.isUploadable(config)) {
|
|
|
@@ -385,11 +415,13 @@ module.exports = function(crowi) {
|
|
|
return !!config.crowi['app:fileUpload'];
|
|
|
};
|
|
|
|
|
|
- configSchema.statics.hasSlackConfig = function(config) {
|
|
|
+ configSchema.statics.hasSlackConfig = function(config)
|
|
|
+ {
|
|
|
return Config.hasSlackWebClientConfig(config) || Config.hasSlackIwhUrl(config);
|
|
|
};
|
|
|
|
|
|
- configSchema.statics.hasSlackWebClientConfig = function(config) {
|
|
|
+ configSchema.statics.hasSlackWebClientConfig = function(config)
|
|
|
+ {
|
|
|
if (!config.notification) {
|
|
|
return false;
|
|
|
}
|
|
|
@@ -404,21 +436,24 @@ module.exports = function(crowi) {
|
|
|
/**
|
|
|
* for Slack Incoming Webhooks
|
|
|
*/
|
|
|
- configSchema.statics.hasSlackIwhUrl = function(config) {
|
|
|
+ configSchema.statics.hasSlackIwhUrl = function(config)
|
|
|
+ {
|
|
|
if (!config.notification) {
|
|
|
return false;
|
|
|
}
|
|
|
return config.notification['slack:incomingWebhookUrl'];
|
|
|
};
|
|
|
|
|
|
- configSchema.statics.isIncomingWebhookPrioritized = function(config) {
|
|
|
+ configSchema.statics.isIncomingWebhookPrioritized = function(config)
|
|
|
+ {
|
|
|
if (!config.notification) {
|
|
|
return false;
|
|
|
}
|
|
|
return config.notification['slack:isIncomingWebhookPrioritized'];
|
|
|
};
|
|
|
|
|
|
- configSchema.statics.hasSlackToken = function(config) {
|
|
|
+ configSchema.statics.hasSlackToken = function(config)
|
|
|
+ {
|
|
|
if (!this.hasSlackWebClientConfig(config)) {
|
|
|
return false;
|
|
|
}
|
|
|
@@ -430,7 +465,8 @@ module.exports = function(crowi) {
|
|
|
return true;
|
|
|
};
|
|
|
|
|
|
- configSchema.statics.getLocalconfig = function(config) {
|
|
|
+ configSchema.statics.getLocalconfig = function(config)
|
|
|
+ {
|
|
|
const Config = this;
|
|
|
const env = crowi.getEnv();
|
|
|
|
|
|
@@ -454,7 +490,7 @@ module.exports = function(crowi) {
|
|
|
};
|
|
|
|
|
|
return local_config;
|
|
|
- };
|
|
|
+ }
|
|
|
|
|
|
/*
|
|
|
configSchema.statics.isInstalled = function(config)
|