Skip to content

Commit

Permalink
fix: the homepage route was not editable in the admin Roles managemen…
Browse files Browse the repository at this point in the history
…t + we do trigger a generate-posts on reference file update
  • Loading branch information
gregorybesson committed Oct 20, 2017
1 parent c8458cb commit 8d2f3a0
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/cli/process/generate-posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,22 @@ function publishNext(files, tt, cb, i = 0) {
jsonObject
)

// removing each blocks potentially containing abe data type then updating the source
// ie. You have a reference file in an abe data type source and you update this reference file
// then it triggers a generate-posts to rebuild the posts and update the content with these
// new data
var textTmp = templatesTexts[jsonObject.abe_meta.template].replace(cmsData.regex.eachBlockPattern, '')

const matches = cmsData.regex.getTagAbeTypeRequest(textTmp)

Array.prototype.forEach.call(matches, match => {
var obj = cmsData.attributes.getAll(match[0], jsonObject)

if (!obj.editable) {
jsonObject[obj.key] = obj.source
}
})

var obj = {
publishAll: true,
type: jsonObject.abe_meta.status,
Expand Down
6 changes: 6 additions & 0 deletions src/server/routes/get-list-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ var route = function(router, req, res, next) {
var urls = []
var html = ''

urls.push({
url: '/abe',
method: '/GET',
regex: '/abe$'
})

Array.prototype.forEach.call(routes, function(route) {
urls.push({
url: route.route.path,
Expand Down
22 changes: 21 additions & 1 deletion src/server/routes/post-reference.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
import {cmsReference} from '../../cli'
import path from 'path'
import {config, abeExtend, cmsReference, Manager} from '../../cli'

var route = function(req, res) {
if (typeof res._header !== 'undefined' && res._header !== null) return
cmsReference.reference.saveFile(req.body.url, req.body.json)
if (
config.publish['auto-republish'] &&
config.publish['auto-republish'].active
) {
var nbPosts = Manager.instance.getList().length
if (config.publish['auto-republish'].limit >= nbPosts) {

var generateArgs = []
generateArgs.push(`ABE_DESTINATION=${path.relative(config.root, Manager.instance.pathPublish)}`)

var proc = abeExtend.process('generate-posts', generateArgs, data => {
res.app.emit('generate-posts', data)
})
if (proc) {
res.app.emit('generate-posts', {percent: 0, time: '00:00sec'})
console.log('generate-posts emitted')
}
}
}
res.set('Content-Type', 'application/json')
res.send(JSON.stringify({success: 1}))
}
Expand Down

0 comments on commit 8d2f3a0

Please sign in to comment.