Skip to content

Commit

Permalink
fix: The republish-all feature didn't take the type='data' selected b…
Browse files Browse the repository at this point in the history
…y the user
  • Loading branch information
gregorybesson committed Jul 9, 2017
1 parent 8b880a1 commit 08072c8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 31 deletions.
52 changes: 24 additions & 28 deletions src/cli/cms/data/source.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export function fileList(obj, tplPath, match, jsonPage) {
return p
}

export function nextDataList(tplPath, jsonPage, match, onlyDynamicSelect) {
export function nextDataList(tplPath, jsonPage, match) {
var p = new Promise((resolve) => {
if(jsonPage['abe_source'] == null) {
jsonPage['abe_source'] = {}
Expand All @@ -160,40 +160,36 @@ export function nextDataList(tplPath, jsonPage, match, onlyDynamicSelect) {

switch (type) {
case 'request':
if (onlyDynamicSelect && obj.editable) {
resolve()
}else {
requestList(obj, tplPath, match, jsonPage)
.then((jsonPage) => {
resolve(jsonPage)
}).catch((e) => {
console.log('[ERROR] source.js requestList', e)
})
}
requestList(obj, tplPath, match, jsonPage)
.then((jsonPage) => {
resolve(jsonPage)
}).catch((e) => {
console.log('[ERROR] source.js requestList', e)
})
break
case 'value':
valueList(obj, match, jsonPage)
.then(() => {
resolve()
}).catch((e) => {
console.log('[ERROR] source.js valueList', e)
})
.then(() => {
resolve()
}).catch((e) => {
console.log('[ERROR] source.js valueList', e)
})
break
case 'url':
urlList(obj, tplPath, match, jsonPage)
.then(() => {
resolve()
}).catch((e) => {
console.log('[ERROR] source.js urlList', e)
})
.then(() => {
resolve()
}).catch((e) => {
console.log('[ERROR] source.js urlList', e)
})
break
case 'file':
fileList(obj, tplPath, match, jsonPage)
.then(() => {
resolve()
}).catch((e) => {
console.log('[ERROR] source.js fileList', e)
})
.then(() => {
resolve()
}).catch((e) => {
console.log('[ERROR] source.js fileList', e)
})
break
default:
resolve()
Expand All @@ -204,13 +200,13 @@ export function nextDataList(tplPath, jsonPage, match, onlyDynamicSelect) {
return p
}

export function getDataList(tplPath, text, jsonPage, onlyDynamicSelect = false) {
export function getDataList(tplPath, text, jsonPage) {
var p = new Promise((resolve) => {

var promises = []
var matches = cmsData.regex.getTagAbeTypeRequest(text)
Array.prototype.forEach.call(matches, (match) => {
promises.push(nextDataList(tplPath, jsonPage, match[0], onlyDynamicSelect))
promises.push(nextDataList(tplPath, jsonPage, match[0]))
})

Promise.all(promises)
Expand Down
6 changes: 3 additions & 3 deletions src/cli/process/generate-posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ function publishNext(files, tt, cb, i = 0) {
i++
var p = new Promise((resolve) => {
if(typeof templatesTexts[jsonObject.abe_meta.template] === 'undefined' || templatesTexts[jsonObject.abe_meta.template] === null) {
templatesTexts[jsonObject.abe_meta.template] = cmsTemplates.template.getTemplate(jsonObject.abe_meta.template)
templatesTexts[jsonObject.abe_meta.template] = cmsTemplates.template.getTemplate(jsonObject.abe_meta.template, jsonObject)
}

cmsData.source.getDataList(path.dirname(jsonObject.abe_meta.link), templatesTexts[jsonObject.abe_meta.template], jsonObject, true)
cmsData.source.getDataList(path.dirname(jsonObject.abe_meta.link), templatesTexts[jsonObject.abe_meta.template], jsonObject)
.then(() => {
jsonObject = abeExtend.hooks.instance.trigger('afterGetDataListOnSave', jsonObject)

Expand Down Expand Up @@ -59,7 +59,7 @@ function publishNext(files, tt, cb, i = 0) {
const fileName = path.basename(obj.json.content.abe_meta.link, '.'+config.files.templates.extension) + '.' + extension
const relPath = path.join(config.root, processConfig.ABE_DESTINATION, relatedTemplate.path, fileName)

cmsData.source.getDataList(path.dirname(obj.json.content.abe_meta.link), relTemplate, obj.json.content, true)
cmsData.source.getDataList(path.dirname(obj.json.content.abe_meta.link), relTemplate, obj.json.content)
.then(() => {
const page = new Page(relTemplate, obj.json.content, true)
cmsOperations.save.saveHtml(relPath, page.html)
Expand Down

0 comments on commit 08072c8

Please sign in to comment.