From b5ebd0200b0bce8ccab41d2ea799444775093cf0 Mon Sep 17 00:00:00 2001 From: kirrg001 Date: Tue, 14 Jun 2016 13:49:40 +0200 Subject: [PATCH] post-scheduling: flat config for scheduling --- core/server/config/index.js | 19 ++++++++----------- core/server/scheduling/index.js | 5 ++--- .../scheduling/post-scheduling/index.js | 6 ++---- .../scheduling/post-scheduling/index_spec.js | 6 ++---- 4 files changed, 14 insertions(+), 22 deletions(-) diff --git a/core/server/config/index.js b/core/server/config/index.js index 879e1b7a98..4a956b2a19 100644 --- a/core/server/config/index.js +++ b/core/server/config/index.js @@ -94,10 +94,10 @@ ConfigManager.prototype.set = function (config) { defaultStorageAdapter = 'local-file-store', defaultSchedulingAdapter = 'SchedulingDefault', activeStorageAdapter, - activePostSchedulingAdapter, + activeSchedulingAdapter, contentPath, storagePath, - postSchedulingPath, + schedulingPath, subdir, assetHash; @@ -151,8 +151,7 @@ ConfigManager.prototype.set = function (config) { // read scheduling adapter(s) from config file or attach default adapter this._config.scheduling = this._config.scheduling || {}; - this._config.scheduling.postScheduling = this._config.scheduling.postScheduling || {}; - activePostSchedulingAdapter = this._config.scheduling.postScheduling.active || defaultSchedulingAdapter; + activeSchedulingAdapter = this._config.scheduling.active || defaultSchedulingAdapter; // we support custom adapters located in content folder if (activeStorageAdapter === defaultStorageAdapter) { @@ -161,10 +160,10 @@ ConfigManager.prototype.set = function (config) { storagePath = path.join(contentPath, 'storage'); } - if (activePostSchedulingAdapter === defaultSchedulingAdapter) { - postSchedulingPath = path.join(corePath, '/server/scheduling/'); + if (activeSchedulingAdapter === defaultSchedulingAdapter) { + schedulingPath = path.join(corePath, '/server/scheduling/'); } else { - postSchedulingPath = path.join(contentPath, '/scheduling/'); + schedulingPath = path.join(contentPath, '/scheduling/'); } _.merge(this._config, { @@ -193,10 +192,8 @@ ConfigManager.prototype.set = function (config) { clientAssets: path.join(corePath, '/built/assets/') }, scheduling: { - postScheduling: { - active: activePostSchedulingAdapter, - path: postSchedulingPath - } + active: activeSchedulingAdapter, + path: schedulingPath }, storage: { active: activeStorageAdapter diff --git a/core/server/scheduling/index.js b/core/server/scheduling/index.js index d7b7e7a143..15152b9948 100644 --- a/core/server/scheduling/index.js +++ b/core/server/scheduling/index.js @@ -1,5 +1,4 @@ -var _ = require('lodash'), - postScheduling = require(__dirname + '/post-scheduling'); +var postScheduling = require(__dirname + '/post-scheduling'); /** * scheduling modules: @@ -8,5 +7,5 @@ var _ = require('lodash'), exports.init = function init(options) { options = options || {}; - return postScheduling.init(_.pick(options, 'postScheduling', 'apiUrl')); + return postScheduling.init(options); }; diff --git a/core/server/scheduling/post-scheduling/index.js b/core/server/scheduling/post-scheduling/index.js index bd19a7b112..00e887b28b 100644 --- a/core/server/scheduling/post-scheduling/index.js +++ b/core/server/scheduling/post-scheduling/index.js @@ -36,10 +36,8 @@ _private.loadScheduledPosts = function () { }; exports.init = function init(options) { - options = options || {}; - - var config = options.postScheduling, - apiUrl = options.apiUrl, + var config = options || {}, + apiUrl = config.apiUrl, adapter = null, client = null; diff --git a/core/test/unit/scheduling/post-scheduling/index_spec.js b/core/test/unit/scheduling/post-scheduling/index_spec.js index 79ecf92f4f..ba37e291b3 100644 --- a/core/test/unit/scheduling/post-scheduling/index_spec.js +++ b/core/test/unit/scheduling/post-scheduling/index_spec.js @@ -64,8 +64,7 @@ describe('Scheduling: Post Scheduling', function () { describe('success', function () { it('will be scheduled', function (done) { postScheduling.init({ - apiUrl: scope.apiUrl, - postScheduling: {} + apiUrl: scope.apiUrl }).then(function () { scope.events['post.scheduled'](scope.post); scope.adapter.schedule.called.should.eql(true); @@ -90,8 +89,7 @@ describe('Scheduling: Post Scheduling', function () { ]; postScheduling.init({ - apiUrl: scope.apiUrl, - postScheduling: {} + apiUrl: scope.apiUrl }).then(function () { scope.adapter.reschedule.calledTwice.should.eql(true); done();