Skip to content

Commit

Permalink
refactoring: cleaning code
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorybesson committed Jul 15, 2017
1 parent 822ea32 commit 9c351d2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 14 deletions.
6 changes: 2 additions & 4 deletions src/cli/cms/templates/template.js
Expand Up @@ -396,7 +396,7 @@ export function setAbePrecontribDefaultValueIfDoesntExist(templateText) {
* then removes all abe tags (but the tab='slug' ones)
* then adds 'precontribTemplate' with the template name as an attribute to tab='slug' tags
* @param {Array} templatesList [description]
* @return {object} [description]
* @return {Array} [description]
*/
export function getAbePrecontribFromTemplates(templatesList) {
var precontributionTemplate = []
Expand All @@ -408,9 +408,7 @@ export function getAbePrecontribFromTemplates(templatesList) {
precontributionTemplate.push(templateText)
})

return {
template: precontributionTemplate
}
return precontributionTemplate
}

export function getStructureAndTemplates() {
Expand Down
11 changes: 3 additions & 8 deletions src/server/routes/get-main.js
Expand Up @@ -27,9 +27,7 @@ function renderAbeAdmin(EditorVariables, obj, filePath) {
manager.list = Manager.instance.getStructureAndTemplates()
manager.editConfig = EditorVariables.express.req.app.get('config')
manager.config = JSON.stringify(config)

var _hasBlock = (obj) ? obj.hasBlock : false
var _hasSingleBlock = (obj) ? obj.hasSingleBlock : false

var _preview = (filePath) ? '/abe/page/' + EditorVariables.express.req.params[0] + `?filePath=${EditorVariables.express.req.query.filePath}` : false
var _form = (obj) ? obj.form : false
var _json = (obj) ? obj.json : false
Expand All @@ -56,12 +54,9 @@ function renderAbeAdmin(EditorVariables, obj, filePath) {
EditorVariables.test = JSON.stringify(locale)
EditorVariables.text = locale
EditorVariables.preview = _preview
EditorVariables.hasSingleBlock = _hasSingleBlock
EditorVariables.hasBlock = _hasBlock
EditorVariables.form = _form
EditorVariables.json = _json
EditorVariables.manager = manager
// EditorVariables.nonce = '\'nonce-' + EditorVariables.express.res.locals.nonce + '\''
EditorVariables.editorWidth = editorWidth

if (_json != null && _json.abe_meta) {
Expand All @@ -73,7 +68,7 @@ function renderAbeAdmin(EditorVariables, obj, filePath) {
if (filePath != null && filePath.indexOf('.json') > -1) {
EditorVariables.express.res.set('Content-Type', 'application/json')
EditorVariables.express.res.send(JSON.stringify(_json))
}else if(EditorVariables.pageHtml != ''){
} else if(EditorVariables.pageHtml != ''){
EditorVariables.express.res.render(config.abeEngine, EditorVariables)
} else {
EditorVariables.express.res.render('../views/template-manager', EditorVariables)
Expand Down Expand Up @@ -174,7 +169,7 @@ var route = function(req, res, next) {
var precontribs = Manager.instance.getPrecontribution()
var promises = []
EditorVariables.resultPrecontrib = []
Array.prototype.forEach.call(precontribs.template, (precontrib) => {
Array.prototype.forEach.call(precontribs, (precontrib) => {
var p = editor(precontrib, obj.json, '', true)
.then((resultPrecontrib) => {
EditorVariables.resultPrecontrib.push(resultPrecontrib)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/cms/templates/template.js
Expand Up @@ -349,7 +349,7 @@ describe('cmsTemplates', function() {

// test
var precontrib = cmsTemplates.template.getAbePrecontribFromTemplates([{name: 'slug', template: this.fixture.slug}])
chai.expect(precontrib.template[0]).to.not.be.undefined;
chai.expect(precontrib[0]).to.not.be.undefined;
});

/**
Expand Down
1 change: 0 additions & 1 deletion tests/unit/controllers/editor.js
Expand Up @@ -27,7 +27,6 @@ describe('editor', function() {
var result = add(
data.obj,
data.json,
data.text,
{add:function () {}}
)

Expand Down

0 comments on commit 9c351d2

Please sign in to comment.