diff --git a/src/scripts/app.tag b/src/scripts/app.tag index 4bf0795..4ec0433 100644 --- a/src/scripts/app.tag +++ b/src/scripts/app.tag @@ -130,6 +130,7 @@ document.addEventListener("click", function(event) { }); self.state = { + "browsed" : false, /* was a link clicked to a post yet */ "page" : self.opts.page, "results" : self.decode(self.opts.results), "start" : self.opts.start, @@ -141,7 +142,8 @@ self.state = { "loaded" : false, "initial" : document.getElementsByTagName("noscript")[0].textContent, "links" : self.decode(self.opts.links), - "categories" : self.decode(self.opts.categories) + "categories" : self.decode(self.opts.categories), + "post_categories" : self.decode(self.opts.post_categories) }; self.active = lens.actives({ @@ -215,6 +217,7 @@ self.on("mount", () => { window.RiotControl.on("openpost", (id) => { console.log("caught the event in the app tag"); + self.state.browsed = true; console.log(`the id is ${id}`); self.route(`/posts/${id}`); } diff --git a/src/scripts/post.tag b/src/scripts/post.tag index cd2f25a..1591aa3 100644 --- a/src/scripts/post.tag +++ b/src/scripts/post.tag @@ -57,7 +57,7 @@ self.route = route; self.loading = false; -self.categories = []; +self.categories = self.opts.state.post_categories; self._id = self.opts.state._id.slice(-hashLength); self.author = self.opts.state.author; self.title = self.opts.state.title; @@ -181,7 +181,9 @@ prevPost(_id) { } self.on("mount", () => { - self.getPost(self._id); + if (self.opts.state.browsed) { + self.getPost(self._id); + } }); diff --git a/src/templates/index.html b/src/templates/index.html index 40a8f25..5289bef 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -27,6 +27,7 @@ start: "{{ start }}", results: "{{ quote(results) }}", categories: "{{ quote(categories) }}", + post_categories: "{{ quote(dumps(postcontent['categories'])) }}", links : "{{ quote(links) }}", page : "{{ page }}", author : "{{ postcontent['author'] }}", diff --git a/src/website.py b/src/website.py index d9a2726..5f91653 100755 --- a/src/website.py +++ b/src/website.py @@ -69,6 +69,7 @@ def NeverWhere(configfile=None): postcontent["title"] = initial_post["title"] return { "quote" : quote, + "dumps" : dumps, "start" : 0, "results" : dumps([]), "postid" : initial_post["_id"],