diff --git a/src/posts.py b/src/posts.py index edbcfa1..8fa35ad 100644 --- a/src/posts.py +++ b/src/posts.py @@ -26,3 +26,16 @@ class Posts: def getposts(self, limit, start): result = self.db.iterview("blogPosts/blog-posts", 10, include_docs=True, limit=limit, skip=start) return jsonify(list(result)) + + def allposts(self): + result = self.db.iterview("blogPosts/blog-posts", 10, include_docs=True) + + posts = [] + for item in result: + posts.append({ + "_id" : item.doc["_id"], + "title" : item.doc["title"], + "author" : item.doc["author"] + }) + + return jsonify(posts) diff --git a/src/scripts/editor.tag b/src/scripts/editor.tag index 91415fe..4f40488 100644 --- a/src/scripts/editor.tag +++ b/src/scripts/editor.tag @@ -24,7 +24,6 @@
- diff --git a/src/templates/write.html b/src/templates/write.html index 6a050ef..b9ce75a 100644 --- a/src/templates/write.html +++ b/src/templates/write.html @@ -26,8 +26,8 @@ {% endblock %} {% block scripts %} - + {% endblock %} diff --git a/src/website.py b/src/website.py index 3ef7b1f..a49a4af 100755 --- a/src/website.py +++ b/src/website.py @@ -93,6 +93,10 @@ def NeverWhere(configfile=None): index = 0 return posts.getposts(index+1, index) + @app.route("/blog/allposts") + def allposts(): + return posts.allposts() + # editor routes @app.route("/blog/editor/", methods=("GET", "POST")) @@ -113,8 +117,9 @@ def NeverWhere(configfile=None): author = request.form.get("author", "no author") title = request.form.get("title", "no title") content = request.form.get("content", "no content") + postid = request.form.get("postid", False) - post = {"author" : author, "title" : title, "content" : content} + post = {"author" : author, "title" : title, "content" : content } return posts.savepost(**post)