1234567891011121314151617181920212223242526272829303132333435363738 |
- /*
- ListPost.js
- Author: tobychui
- This script list all the post within the system
- */
- //Require the file library
- requirelib("filelib");
- //Require the internal library for handling the path of blog posting
- includes("config.js");
- var blogPostStorage = getBlogPostStore();
- function main(){
- //Create a directory in user:/Document/ for storing Blog stuffs
- if (blogPostStorage == ""){
- //The blog post storage is not set. Use default
- blogPostStorage = "user:/Document/Blog/Posts/";
- }
- //Filter out the last / if exists
- if (blogPostStorage.substr(blogPostStorage.length - 1, 1) == "/"){
- blogPostStorage = blogPostStorage.substr(0, blogPostStorage.length - 1);
- }
- //If it doesn't exists
- filelib.mkdir(blogPostStorage);
- //List all the created post
- var allPosts = filelib.aglob(blogPostStorage + "/*.json");
- //Return the value of the posts
- sendJSONResp(JSON.stringify(allPosts));
- }
- main();
|