Improve CV Editor + Fixe
Some checks reported errors
Neutral/pipeline/head Something is wrong with the build of this commit

This commit is contained in:
Raphix
2023-03-29 18:13:13 +02:00
parent 353746b3d4
commit 12b340e0f1
3 changed files with 513 additions and 26 deletions

View File

@ -134,8 +134,20 @@ router.post("/", function(req, res, next) {
res.send({"result":"success", "content":fileData.toString()})
} else {
var fileData = null;
if(fs.existsSync(markdownFolder)) {
fileData = fs.readFileSync(markdownFolder + "project/" + bod.value + ".md")
} else {
fileData = fs.readFileSync("../MD_TEST/project/" + bod.value + ".md")
}
res.send({"result":"success", "content":fileData.toString()})
res.send({"result":"failed", "content":"ERROR_NOT_VALID_REQUEST"})
}
@ -360,12 +372,166 @@ router.post("/", function(req, res, next) {
} else {
res.send({"result":"failed", "content":"ERROR_NOT_VALID_REQUEST"})
if(fs.existsSync(markdownFolder)) {
fs.writeFile(markdownFolder + "/project/" + bod.type + ".md", bod.value, (err) => {
if(err) {
res.send({"result":"success", "content":"ERROR_NOT_PERMITTED"})
console.log(err)
} else {
res.send({"result":"success", "content":"NO_PROBLEM"})
console.log(err)
}
})
} else {
fs.writeFile("../MD_TEST/project/" + bod.type + ".md", bod.value, (err) => {
if(err) {
res.send({"result":"success", "content":"ERROR_NOT_PERMITTED"})
console.log(err)
} else {
res.send({"result":"success", "content":"NO_PROBLEM"})
console.log(err)
}
})
}
}
}
} else if(bod.request == "get-projects") {
const projectFolder = "/home/gitlab-ci/cv/dashboard-raphael/markdown/project/"
if(fs.existsSync(projectFolder)) {
var allProject = new Array()
fs.readdirSync(projectFolder).forEach((file) => {
allProject.push((file).replace(".md", ""))
})
res.send({"result":"success", "content":allProject})
} else {
var allProject = new Array()
fs.readdirSync("../MD_TEST/project/").forEach((file) => {
allProject.push((file).replace(".md", ""))
})
res.send({"result":"success", "content":allProject})
}
} else if(bod.request == "del") {
const projectFolder = "/home/gitlab-ci/cv/dashboard-raphael/markdown/project/"
if(fs.existsSync(projectFolder + bod.value + ".md")) {
fs.rm(projectFolder + bod.value + ".md", (err) => {
if(err) {
res.send({"result":"success", "content":"ERROR_NOT_PERMITTED"})
console.log(err)
} else {
res.send({"result":"success", "content":"NO_PROBLEM"})
}
})
} else if(fs.existsSync("../MD_TEST/project/" + bod.value + ".md")) {
fs.rm("../MD_TEST/project/" + bod.value + ".md", (err) => {
if(err) {
res.send({"result":"success", "content":"ERROR_NOT_PERMITTED"})
console.log(err)
} else {
res.send({"result":"success", "content":"NO_PROBLEM"})
}
})
} else {
res.send({"result":"failed", "content":"FILE_NO_EXIST"})
}
} else if(bod.request == "add") {
const projectFolder = "/home/gitlab-ci/cv/dashboard-raphael/markdown/project/"
if(fs.existsSync(projectFolder)) {
fs.writeFile(projectFolder + bod.value + ".md", "**" + bod.value + "**" ,(err) => {
if(err) {
res.send({"result":"success", "content":"ERROR_NOT_PERMITTED"})
console.log(err)
} else {
res.send({"result":"success", "content":"NO_PROBLEM"})
}
})
} else {
fs.writeFile(projectFolder + bod.value + ".md", "**" + bod.value + "**" ,(err) => {
if(err) {
res.send({"result":"success", "content":"ERROR_NOT_PERMITTED"})
console.log(err)
} else {
res.send({"result":"success", "content":"NO_PROBLEM"})
}
})
}
}
} else {