all repos — litestore @ cfa52c40ecf0648c2139f5634b719b99cac681a6

A minimalist nosql document store.

Refactoring: loading datastore info only once.
h3rald h3rald@h3rald.com
Sun, 22 Mar 2015 19:44:27 +0100
commit

cfa52c40ecf0648c2139f5634b719b99cac681a6

parent

f4dde5e7ad3da28d2661747a3b08b2c25d64ab16

4 files changed, 6 insertions(+), 8 deletions(-)

jump to
M app/js/app.jsapp/js/app.js

@@ -3,10 +3,9 @@ 'use strict';

var app = window.LS || (window.LS = {}); app.flash = m.prop(); - app.system = m.prop(); + app.system = {}; app.init = function(info){ - app.system(info); - console.log(app.system()); + app.system = info; m.route.mode = "hash"; m.route(document.body, "/info", {
M app/js/modules/document.jsapp/js/modules/document.js

@@ -93,7 +93,7 @@ vm.viewDocument();

} }; vm.tools = function(){ - if (app.system().read_only) { + if (app.system.read_only) { return []; } switch (vm.action){
M app/js/modules/guide.jsapp/js/modules/guide.js

@@ -12,7 +12,7 @@ vm.content = Page.get(vm.id()).then(function(content){return content}, vm.flashError);

vm.edit = function(){ m.route("/document/edit/app/md/"+vm.id()+".md"); }; - vm.links = app.system().read_only ? m.prop([]) : m.prop([{action: vm.edit, title: "Edit", icon: "edit"}]); + vm.links = app.system.read_only ? m.prop([]) : m.prop([{action: vm.edit, title: "Edit", icon: "edit"}]); }; app.guide.main = function(){ return m("article.row", [
M app/js/navbar.jsapp/js/navbar.js

@@ -10,7 +10,6 @@ },

vm: { init: function(){ var vm = this; - vm.info = Info.get(); this.activelink = function(url){ return (m.route().match(new RegExp("^\/"+url))) ? "active" : ""; };

@@ -35,8 +34,8 @@ var links = [

m("li", {class: vm.activelink("info")}, [m("a", {href: "/info", config: m.route}, [m("i.fa.fa-info-circle"), " Info"])]), u.dropdown({title: "Guide", icon:"fa-book", links: vm.guidelinks, active: vm.activelink("guide")}), - u.dropdown({title: "Tags", icon:"fa-tag", links: vm.taglinks(vm.info()), active: vm.activelink("tags")})]; - if (!app.system().read_only) { + u.dropdown({title: "Tags", icon:"fa-tag", links: vm.taglinks(app.system), active: vm.activelink("tags")})]; + if (!app.system.read_only) { links.push(m("li", {class: vm.activelink("new")}, [m("a", {href: "/document/create/", config: m.route}, [m("i.fa.fa-plus-circle"), " New"])]));