/* Hide a published post from the blog engine Require paramter: filepath webroot */ requirelib("filelib"); requirelib("appdata"); includes("config.js"); includes("helper.js"); includes("indexManager.js"); function hidePost(postObjectName, webroot){ //Check public post exists var publishWebPosition = filepathClean(webroot) + "/blog/posts/" + postObjectName + ".html"; if (filelib.fileExists(publishWebPosition)){ filelib.deleteFile(publishWebPosition); } sendResp("OK"); } function getPostNameFromFilepath(path){ var tmp = path.split("/").pop(); if (tmp.indexOf(".html") >= 0){ tmp = tmp.replace(".html", ""); }else if (tmp.indexOf(".json") >= 0){ tmp = tmp.replace(".json", ""); } return tmp; } var postName = getPostNameFromFilepath(filepath); hidePost(postName, webroot);