diff --git a/src/posts.py b/src/posts.py index 350092d..d5a2d40 100644 --- a/src/posts.py +++ b/src/posts.py @@ -7,6 +7,7 @@ from werkzeug.local import Local, LocalProxy, LocalManager from couchdb.http import ResourceConflict, ResourceNotFound from flask import jsonify, g from flask_marshmallow import Marshmallow +from itertools import chain def get_mistune(): markdown = getattr(g, "markdown", None) @@ -128,16 +129,14 @@ class Posts: return jsonify(False) def categories(self): - return jsonify( - [ + return list(set(chain.from_iterable([ c["key"][1] for c in self.db.view("blogPosts/categories", - startkey=["category"], - endkey=["category", {}], + startkey=["categories"], + endkey=["categories", {}], inclusive_end=False, reduce=True, group_level=2, group=True) - ] - ) + ]))) diff --git a/src/scripts/app.tag b/src/scripts/app.tag index 28ff20b..d0a2fd0 100644 --- a/src/scripts/app.tag +++ b/src/scripts/app.tag @@ -19,7 +19,7 @@ + items={state.categories}> @@ -138,7 +138,8 @@ self.state = { "title" : self.opts.title, "loaded" : false, "initial" : document.getElementsByTagName("noscript")[0].textContent, - "links" : JSON.parse(decodeURIComponent(self.opts.links)) + "links" : JSON.parse(decodeURIComponent(self.opts.links)), + "categories" : JSON.parse(decodeURIComponent(self.opts.categories)) }; self.active = lens.actives({ @@ -207,15 +208,6 @@ to(name) { }).bind(this); } -function getcategories() { - window.cached("/blog/categories") - .then((resp) => resp.json()) - .then((resp) => { - self.categories = resp; - self.update(); - }); -} - self.on("mount", () => { self.route.base('/blog/') self.route("/", () => { self.route(`/posts/${self.state._id}`); }); @@ -226,7 +218,6 @@ self.on("mount", () => { self.route("about", about); self.route("links", links); route.start(true); - getcategories(); }); diff --git a/src/scripts/categories.tag b/src/scripts/categories.tag new file mode 100644 index 0000000..57b7140 --- /dev/null +++ b/src/scripts/categories.tag @@ -0,0 +1,20 @@ + +
+ + +
+ + +
diff --git a/src/scripts/editor.tag b/src/scripts/editor.tag index 66c0a47..9b9acce 100644 --- a/src/scripts/editor.tag +++ b/src/scripts/editor.tag @@ -8,18 +8,28 @@ {!this.isNewPost ? this.currentPost().title : "No Title"} by {!this.isNewPost ? this.currentPost().author : "No Author"} - - +
+
+
+ +
+
+ +
+
+

title author @@ -42,7 +52,7 @@ onblur={checkplaceholder} oninput={echo} rows="10" - cols="10" + cols="30" __disabled={""} class="editor form-input centered" ref="textarea"> diff --git a/src/scripts/post.tag b/src/scripts/post.tag index 90f4d6b..dc3021d 100644 --- a/src/scripts/post.tag +++ b/src/scripts/post.tag @@ -29,6 +29,7 @@

+
") @login_required