<commit_before>const m = require('mithril');
const nav = require('./components/nav');

const mixinPage = function (nav, page) {
  return {
    view: function() {
      return m('div', {id: 'container', class: 'row'}, [
        m('div', {id: 'nav', class: 'col s2 l1'},
            nav),
        m('div', {id: 'content', class: 'col offset-s2 s10 offset-l1 l11'},
            page)
      ]);
    }
  };
};

// TODO: remove after implementing pages
const blank = mixinPage(nav, {view: () => m('div', 'TODO')});

const routes = {
  locked: {
    '/login': blank
  },
  app: {
    '/metrics': {controller: () => m.route('/metrics/overview')},
    '/metrics/overview': blank,
    '/metrics/realtime': blank,
    '/metrics/demographics': blank,

    '/streams': {controller: () => m.route('/streams/live')},
    '/streams/live': blank,
    '/streams/all': mixinPage(nav, require('./pages/streams')),
    '/streams/search': blank,

    '/users': {controller: () => m.route('/users/all')},
    '/users/all': blank,
    '/users/search': blank,

    '/admins': {controller: () => m.route('/admins/all')},
    '/admins/all': blank,
    '/admins/create': blank,

    '/settings': blank
  }
};

// TODO: Separate into Authentication module
const isLoggedIn = true;
if (!isLoggedIn) {
  m.route(document.body, '/login', routes.locked);
} else {
  m.route(document.body, '/metrics', routes.app);
}
<commit_msg>Add controller handling to page mixin<commit_after>const m = require('mithril');
const nav = require('./components/nav');

const mixinPage = function (nav, page) {
  return {
    controller: function() {
      let ctrl = this;
      ctrl.navCtrl = new nav.controller();
      ctrl.pageCtrl = new page.controller();
    },
    view: function(ctrl) {
      return m('div', {id: 'container', class: 'row'}, [
        m('div', {id: 'nav', class: 'col s2 l1'},
            nav.view(ctrl.navCtrl)),
        m('div', {id: 'content', class: 'col offset-s2 s10 offset-l1 l11'},
            page.view(ctrl.pageCtrl))
      ]);
    }
  };
};

// TODO: remove after implementing pages
const blank = mixinPage(nav, {
  controller: () => {},
  view: () => m('div', 'TODO')
});

const routes = {
  locked: {
    '/login': blank
  },
  app: {
    '/metrics': {controller: () => m.route('/metrics/overview')},
    '/metrics/overview': blank,
    '/metrics/realtime': blank,
    '/metrics/demographics': blank,

    '/streams': {controller: () => m.route('/streams/live')},
    '/streams/live': blank,
    '/streams/all': mixinPage(nav, require('./pages/streams')),
    '/streams/search': blank,

    '/users': {controller: () => m.route('/users/all')},
    '/users/all': blank,
    '/users/search': blank,

    '/admins': {controller: () => m.route('/admins/all')},
    '/admins/all': blank,
    '/admins/create': blank,

    '/settings': blank
  }
};

// TODO: Separate into Authentication module
const isLoggedIn = true;
if (!isLoggedIn) {
  m.route(document.body, '/login', routes.locked);
} else {
  m.route(document.body, '/metrics', routes.app);
}

{'fraction_non_alphanumeric': 0.21306068601583114, 'fraction_numerical': 0.005277044854881266, 'mean_word_length': 2.9698952879581153, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7640958', 'n_tokens_mistral': 1038, 'n_tokens_neox': 1008, 'n_words': 231}