Skip to content

Commit

Permalink
fix: generatePosts
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorybesson committed Oct 16, 2017
1 parent dc5c9c3 commit 2b3d2da
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 62 deletions.
56 changes: 0 additions & 56 deletions src/cli/cms/data/file.js
Expand Up @@ -77,62 +77,6 @@ export function get(pathJson) {
return json
}

export function fromUrl(url) {
var res = {
root: '',
draft: {
dir: '',
file: '',
path: ''
},
publish: {
dir: '',
file: '',
link: '',
path: '',
json: ''
},
json: {
path: '',
file: ''
}
}

if (url != null) {
const dir = path.dirname(url).replace(config.root, '')
const filename = path.basename(url)
const pathPublish = path.join(Manager.instance.pathPublish, path.sep)

let link = url.replace(pathPublish, '')
link = link.replace(new RegExp('\\' + path.sep, 'g'), '/')
link = cmsData.fileAttr.delete('/' + link)

const publishPath = Manager.instance.pathPublish.replace(config.root, '')
const dataPath = Manager.instance.pathData.replace(config.root, '')

res.root = config.root

res.json.dir = coreUtils.file.changePath(dir, dataPath)
res.publish.dir = coreUtils.file.changePath(dir, publishPath)
res.publish.json = res.json.dir

res.publish.file = cmsData.fileAttr.delete(filename)
res.publish.link = link
res.json.file = filename.replace(
`.${config.files.templates.extension}`,
'.json'
)
res.publish.json = path.join(
res.json.dir,
cmsData.fileAttr.delete(res.json.file)
)

res.publish.path = path.join(res.publish.dir, res.publish.file)
res.json.path = path.join(res.json.dir, res.json.file)
}
return res
}

export function getFilesByType(pathFile, type = null) {
const extension = '.' + config.files.templates.extension
let result = []
Expand Down
6 changes: 3 additions & 3 deletions src/cli/cms/operations/save.js
Expand Up @@ -37,9 +37,9 @@ export function saveJson(jsonPath, json) {
return true
}

export function saveHtml(url, html) {
mkdirp.sync(path.dirname(url))
fse.writeFileSync(url, html)
export function saveHtml(pathFile, html) {
mkdirp.sync(path.dirname(pathFile))
fse.writeFileSync(pathFile, html)

return true
}
4 changes: 2 additions & 2 deletions src/server/routes/get-generate-posts.js
Expand Up @@ -45,7 +45,7 @@ var route = function(req, res) {
// if get
var result
var generateArgs = []
generateArgs.push(`ABE_DESTINATION=${Manager.instance.pathPublish.replace(config.root, '')}`)
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)
})
Expand All @@ -59,7 +59,7 @@ var route = function(req, res) {
result = {
success: 0,
msg:
'cannot run process generate-posts, because an other one is already running'
'cannot run process generate-posts, because another one is already running'
}
}
res.set('Content-Type', 'application/json')
Expand Down
3 changes: 2 additions & 1 deletion src/server/routes/operations/post/submit.js
@@ -1,3 +1,4 @@
import path from 'path'
import {
cmsOperations,
abeExtend,
Expand Down Expand Up @@ -32,7 +33,7 @@ var route = function(req, res, next) {
if (config.publish['auto-republish'].limit >= nbPosts) {

var generateArgs = []
generateArgs.push(`ABE_DESTINATION=${Manager.instance.pathPublish.replace(config.root, '')}`)
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)
Expand Down

0 comments on commit 2b3d2da

Please sign in to comment.