From b84d112f05e67fb10d8a03af0ce092be66880df9 Mon Sep 17 00:00:00 2001 From: wes Date: Sun, 13 Aug 2017 14:21:19 -0400 Subject: [PATCH] make projects route work properly --- requirements.txt | 1 + src/scripts/app.tag | 1 + src/scripts/post.tag | 16 ++++++++++++++++ src/templates/index.html | 6 +++--- src/website.py | 33 ++++++++++++++++++++++++--------- 5 files changed, 45 insertions(+), 12 deletions(-) diff --git a/requirements.txt b/requirements.txt index 422522b..035e928 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,6 +12,7 @@ Fabric==1.13.1 Flask==0.12 flask-appconfig==0.11.1 Flask-Bootstrap==3.3.7.1 +Flask-Cache==0.13.1 Flask-Login==0.4.0 flask-marshmallow==0.7.0 Flask-WTF==0.14.2 diff --git a/src/scripts/app.tag b/src/scripts/app.tag index b745da0..9fe98f3 100644 --- a/src/scripts/app.tag +++ b/src/scripts/app.tag @@ -124,6 +124,7 @@ RiotControl.on("postswitch", ); self.state = { + "page" : self.opts.page, "_id" : self.opts.postid.slice(-hashLength), "author" : self.opts.author, "title" : self.opts.title, diff --git a/src/scripts/post.tag b/src/scripts/post.tag index a02ef99..35f06d4 100644 --- a/src/scripts/post.tag +++ b/src/scripts/post.tag @@ -141,6 +141,15 @@ updatePost(postcontent) { self.update(); } +getPost(_id) { + self.update({"loading" : true}); + window.cached(`/blog/getpost/${_id.slice(-hashLength)}/${self.category}`) + .then((resp) => resp.text()) + .then((resp) => { + self.updatePost(JSON.parse(resp)) + }) +} + nextPost(_id) { self.update({"loading" : true}); window.cached(`/blog/switchpost/${_id.slice(-hashLength)}/${self.category}`) @@ -169,5 +178,12 @@ prevPost(_id) { self.updatePost(JSON.parse(resp)) }) } + +self.on("mount", () => { + if (self.opts.state.page !== "posts") { + self.getPost(self._id); + } +}); + diff --git a/src/templates/index.html b/src/templates/index.html index ae038f0..363f3f8 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -7,13 +7,13 @@ -
+
-