|
|
@@ -42,6 +42,7 @@ function Crowi (rootdir, env)
|
|
|
this.config = {};
|
|
|
this.searcher = null;
|
|
|
this.mailer = {};
|
|
|
+ this.interceptorManager = {};
|
|
|
|
|
|
this.tokens = null;
|
|
|
|
|
|
@@ -89,6 +90,8 @@ Crowi.prototype.init = function() {
|
|
|
return self.setupSearcher();
|
|
|
}).then(function() {
|
|
|
return self.setupMailer();
|
|
|
+ }).then(function() {
|
|
|
+ return self.setupInterceptorManager();
|
|
|
}).then(function() {
|
|
|
return self.setupSlack();
|
|
|
}).then(function() {
|
|
|
@@ -241,6 +244,10 @@ Crowi.prototype.getMailer = function() {
|
|
|
return this.mailer;
|
|
|
};
|
|
|
|
|
|
+Crowi.prototype.getInterceptorManager = function() {
|
|
|
+ return this.interceptorManager;
|
|
|
+}
|
|
|
+
|
|
|
Crowi.prototype.setupSearcher = function() {
|
|
|
var self = this;
|
|
|
var searcherUri = this.env.ELASTICSEARCH_URI
|
|
|
@@ -269,6 +276,31 @@ Crowi.prototype.setupMailer = function() {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
+Crowi.prototype.setupInterceptorManager = function() {
|
|
|
+ var self = this;
|
|
|
+ return new Promise(function(resolve, reject) {
|
|
|
+ self.interceptorManager = require('../util/interceptorManager')(self);
|
|
|
+
|
|
|
+ self.interceptorManager.addInterceptor({
|
|
|
+ isInterceptWhen: (contextName) => {
|
|
|
+ // implement this
|
|
|
+ return true;
|
|
|
+ },
|
|
|
+ isProcessableParallel: () => {
|
|
|
+ // implement this
|
|
|
+ return true;
|
|
|
+ },
|
|
|
+ process: (contextName, ...args) => {
|
|
|
+ console.log(args[0][0].page);
|
|
|
+ args[0][0].page.revision.body += 'hogehogefugafuga';
|
|
|
+ Promise.resolve(args[0]);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ resolve();
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
Crowi.prototype.setupSlack = function() {
|
|
|
var self = this;
|
|
|
var config = this.getConfig();
|
|
|
@@ -334,7 +366,7 @@ Crowi.prototype.buildServer = function() {
|
|
|
}
|
|
|
|
|
|
require('../routes')(this, app);
|
|
|
-
|
|
|
+
|
|
|
if (env == 'development') {
|
|
|
//swig.setDefaults({ cache: false });
|
|
|
app.use(errorHandler({ dumpExceptions: true, showStack: true }));
|
|
|
@@ -355,10 +387,10 @@ Crowi.prototype.buildServer = function() {
|
|
|
|
|
|
/**
|
|
|
* require API for plugins
|
|
|
- *
|
|
|
+ *
|
|
|
* @param {string} modulePath
|
|
|
* @return {module}
|
|
|
- *
|
|
|
+ *
|
|
|
* @memberof Crowi
|
|
|
*/
|
|
|
Crowi.prototype.require = function(modulePath) {
|