/* Helper Class This script handles basic stuffs */ function filepathClean(webroot){ if (webroot.substr(webroot.length -1, 1) == "/"){ webroot = webroot.substr(0, webroot.length - 1); } return webroot; } //Generate a quick summary for post object function extractPostInfo(filepath){ var content = filelib.readFile(filepath); var postObject = JSON.parse(content); var title = "Untitled"; var content = "(This post has no content)"; var tags = []; if (typeof postObject.Title != "undefined"){ title = postObject.Title } if (typeof postObject.Content != "undefined"){ content = postObject.Content; if (content.split(" ").length > 100){ //Trim the content off if it is longer than 100 words var words = content.split(" "); var trimmedContent = ""; for (var i = 0; i < 100; i++){ trimmedContent = trimmedContent + words[i] + " "; } trimmedContent = trimmedContent + "..." content = trimmedContent; }else if (content.length > 300){ //To handle lang with no space, like Cantonese var trimmedContent = content.substr(0, 300) + "..." content = trimmedContent; } } if (typeof postObject.Tags != "undefined"){ tags = postObject.Tags } return [title, content, tags]; } function loadFooter(){ //WIP var footerTemplate = appdata.readFile("Blog/template/footer.html"); if (footerTemplate == false){ return "Powered by ArozOS Blog Engine"; }else{ return footerTemplate; } } function loadBlogInfo(){ //WIP return ["My Blog", "An amazing blog written by me!"] } function retrunErrorObject(message){ sendJSONResp(JSON.stringify({ error: message })) }