From 8c23887520ef4ce579c8f88600c009422beb87ed Mon Sep 17 00:00:00 2001 From: wes Date: Wed, 9 Aug 2017 13:36:07 -0400 Subject: [PATCH] performance improvements --- src/scripts/app.tag | 38 +++++++++++++++++++------------------- src/scripts/post.tag | 9 +++++++-- src/scripts/postsview.tag | 4 ++-- src/scripts/riotblog.js | 24 +++++++++++++----------- src/styles/riotblog.scss | 1 + src/templates/index.html | 29 +++++++++++++++++++++++------ src/website.py | 8 +++++++- 7 files changed, 72 insertions(+), 41 deletions(-) diff --git a/src/scripts/app.tag b/src/scripts/app.tag index 74267ab..2b1f088 100644 --- a/src/scripts/app.tag +++ b/src/scripts/app.tag @@ -27,12 +27,12 @@ class="mobile-menu tab tab-block menu">
  • @@ -41,20 +41,20 @@
    - + @@ -62,20 +62,20 @@
    @@ -90,6 +90,7 @@ import './links.tag'; import './loading.tag'; import fetchCached from 'fetch-cached'; +import 'whatwg-fetch'; import Z from './zipper.js'; import pathEq from 'ramda/src/pathEq'; import route from 'riot-route'; @@ -189,7 +190,6 @@ var about = activate("about"); var links = activate("links"); function posts(_id) { - console.log(self.state); if (self.state._id != _id) { self.state._id = _id; } @@ -216,7 +216,7 @@ self.route("projects", projects); self.route("about", about); self.route("links", links); -self.on("mount", () => { +self.one("updated", () => { route.start(true); }); diff --git a/src/scripts/post.tag b/src/scripts/post.tag index 4b755bd..122f5f8 100644 --- a/src/scripts/post.tag +++ b/src/scripts/post.tag @@ -63,7 +63,10 @@ self.prevloading = ""; self.nextloading = ""; self.content = ""; self.swipe = false; -self.loading = self.opts.state.loaded; + +self.on("mount", () => { + self.loading = self.opts.state.loaded; +}); RiotControl.on("filtercategory", (ev) => { @@ -183,7 +186,9 @@ getPost(_id) { .then((resp) => { self.updatePost(JSON.parse(resp)) }) } -self.getPost(self.opts.state._id); +self.on("mount", () => { + self.getPost(self.opts.state._id); +}); diff --git a/src/scripts/postsview.tag b/src/scripts/postsview.tag index 705acc4..d2edc12 100644 --- a/src/scripts/postsview.tag +++ b/src/scripts/postsview.tag @@ -1,8 +1,8 @@ diff --git a/src/scripts/riotblog.js b/src/scripts/riotblog.js index 968d852..0feee6d 100644 --- a/src/scripts/riotblog.js +++ b/src/scripts/riotblog.js @@ -10,18 +10,20 @@ import { default as promise } from 'es6-promise'; import { default as smooth } from 'smoothscroll-polyfill'; import 'element-closest'; -promise.Promise.polyfill(); -smooth.polyfill(); +window.addEventListener("load", () => { -window.RiotControl = RiotControl; + promise.Promise.polyfill(); + smooth.polyfill(); -RiotControl.addStore(new riot.observable()); + window.RiotControl = RiotControl; -riot.mount("app"); -riot.mount("post", - { - "creator" : "author" - }); + RiotControl.addStore(new riot.observable()); + riot.mount("app"); + riot.mount("post", + { + "creator" : "author" + }); -riot.mount("bbutton"); -riot.mount("projects"); + riot.mount("bbutton"); + riot.mount("projects"); +}); diff --git a/src/styles/riotblog.scss b/src/styles/riotblog.scss index 4c67092..c6288b2 100644 --- a/src/styles/riotblog.scss +++ b/src/styles/riotblog.scss @@ -62,6 +62,7 @@ $navbarHeight: 100px; border: none; color: black !important; text-decoration: none; + text-transform: capitalize; &:hover { background-color: $brandingBG !important; } diff --git a/src/templates/index.html b/src/templates/index.html index 2355904..13d21c2 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -1,14 +1,12 @@ - - - - +
    diff --git a/src/website.py b/src/website.py index c1590d1..37e127f 100755 --- a/src/website.py +++ b/src/website.py @@ -170,6 +170,12 @@ def NeverWhere(configfile=None): app = NeverWhere() +@app.teardown_appcontext +def teardown_couchdb(exception): + posts = getattr(g, 'posts', None) + if posts is not None: + del posts.db + posts = LocalProxy(get_posts) login_manager.init_app(app) @@ -179,4 +185,4 @@ csrf = CSRFProtect() csrf.init_app(app) if __name__ == "__main__": - NeverWhere("./appconfig").run(host="localhost", port=8001, debug=True) + NeverWhere().run(host="localhost", port=8001, debug=True)