all repos — litestore @ 045149148c3b3b1002cee32bf4883a2db5379c1c

A minimalist nosql document store.

app/js/app.js

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
var Page = {}

Page.get = function(id) {
  var content = m.prop("");
  return m.request({
      method: "GET", 
      url: "md/"+id+".md",
      deserialize: function(value) {return value;}
    }).then(function(content){ return marked(content)});
}

var litestore = {
    controller: function() {
      this.pageid = m.route.param("page");
      this.content = Page.get(this.pageid);
    },
    view: function(controller) {
      $('#nav-links').find('.active').removeClass('active');
      $('#nav-'+controller.pageid).addClass('active');
      return m("article", m.trust(controller.content()));
    }
}

m.route.mode = "hash";

m.route(document.getElementsByTagName("main")[0], "/overview", {
    "/:page": litestore
});