@@ -66,9 +79,28 @@ this.placeholderText = "Write a post!"
this.placeholder = this.placeholderText;
this.focused = false;
-this.currentPosts = [];
+this.currentPosts = Z.empty;
+
var self = this;
+currentPost() {
+ var defaultPost = {
+ "_id" : "",
+ "title" : "",
+ "author" : ""
+ };
+
+ return Z.focus(self.currentPosts, defaultPost);
+}
+
+goRight() {
+ self.update({"currentPosts" : Z.goRight(self.currentPosts)});
+}
+
+goLeft() {
+ self.update({"currentPosts" : Z.goLeft(self.currentPosts)});
+}
+
clearplaceholder() {
if (!this.focused) {
this.update({
@@ -90,8 +122,7 @@ checkplaceholder() {
echo(ev) {
this.update({
"converted" : this.converter.makeHtml(
- this.refs.textarea.value.trim()
- )
+ this.refs.textarea.value.trim())
});
}
@@ -138,7 +169,7 @@ submit() {
loadPost(_id) {
return function() {
- axios.get(`/blog/getpost/${_id}`)
+ axios.get(`/blog/getpost/${self.currentPost()._id}`)
.then(function(resp) {
self.refs.textarea.value = resp.data.content;
@@ -159,7 +190,11 @@ loadPost(_id) {
listPosts() {
axios.get("/blog/allposts")
.then(function(resp) {
- self.update({"currentPosts" : resp.data});
+ self.update(
+ {
+ "currentPosts" : Z.extend(self.currentPosts, resp.data)
+ }
+ );
})
.catch(function(err) {
console.log(err);
diff --git a/src/scripts/zipper.js b/src/scripts/zipper.js
index 2186c9a..6a84c5a 100644
--- a/src/scripts/zipper.js
+++ b/src/scripts/zipper.js
@@ -43,6 +43,10 @@ function goLeft(z) {
z.right.unshift(z.left.first()));
}
+function extend(z, xs) {
+ return Zipper(z.left, z.right.concat(xs));
+}
+
var empty = fromList([]);
export default {
@@ -51,5 +55,6 @@ export default {
"goRight" : goRight,
"goLeft" : goLeft,
"empty" : empty,
- "fromList" : fromList
+ "fromList" : fromList,
+ "extend" : extend
};
diff --git a/src/styles/riotblog.scss b/src/styles/riotblog.scss
index d5ee301..20b73d0 100644
--- a/src/styles/riotblog.scss
+++ b/src/styles/riotblog.scss
@@ -86,6 +86,4 @@ $branding: #5764c6;
margin-top: 10%;
}
-.editor {
- height: 100% !important;
-}
+.editor {}
diff --git a/src/website.py b/src/website.py
index 3ba61cb..247bb06 100755
--- a/src/website.py
+++ b/src/website.py
@@ -101,6 +101,11 @@ def NeverWhere(configfile=None):
def getpost(_id):
return posts.getpost(_id)
+ @app.route("/blog/del/<_id>")
+ @login_required
+ def delete(_id):
+ return posts.delete(_id)
+
# editor routes
@app.route("/blog/editor/", methods=("GET", "POST"))