<commit_before>var resource = require('resource'),
    async = require('async'),
    html = require('html-lang'),
    fs = require('fs');

module['exports'] = function(options, callback) {
  var space = resource.use('space'),
      creature = resource.use('creature');

  var $ = this.$;

  //
  // auth nav
  //
  var user =  options.request.user;
  if (typeof user !== 'undefined') {
    $('#auth-nav').html("<p>hi " + user.id + "</p>");
  } else {
    var auth = resource.use('auth');
    auth.view.login.min.present({}, function(err, result) {
      $('#auth-nav').html(result);
    });
  }

  var session = options.request.session || {};
  async.waterfall([
    //
    // all-spaces nav
    //
    function(callback) {

      // TODO: update the following once we can pass spaces into space.view.get.min
      // get all spaces
      space.all(function(err, spaces) {
        if (err) { return callback(err); }

        // retrieve each space id, then render them all
        async.map(spaces,
          function(_space, callback) {
              callback(null, _space.id);

          // render spaces
          }, function(err, spaces) {
            if (err) { return callback(err); }
            space.view.get.min.present({
              data: {
                id: spaces
              }

            // append rendered spaces to dom
            }, function(err, result) {
              if (err) { return callback(err); }
              $('#all-spaces-nav').append(result);
              callback(null);
            });
        });
      });
    },


    // get creatureID in session
    function(callback) {
      // if session does not yet have a creature
      if (typeof session.creatureID === 'undefined') {
        // TODO create a random creature
        creature.create({name: 'bob', description: 'the bob creature'}, function(err, _creature) {
          if (err) { return callback(err); }
          // add creature to session
          session.creatureID = _creature.id;
          return callback(null, session.creatureID);
        });
      // if session has a creature
      } else {
        // use it
        callback(null, session.creatureID);
      }
    },

    // get creature from creatureID
    function(creatureID, callback) {
      creature.get(creatureID, callback);
    },

    //
    // top menu
    //
    // make creature buttons
    function(_creature, callback) {

      // get view of this creature
      creature.view.get.button.present({<commit_msg>[layout] close #24<commit_after>var resource = require('resource'),
    async = require('async'),
    html = require('html-lang'),
    Faker = require('Faker'),
    fs = require('fs');

module['exports'] = function(options, callback) {
  var space = resource.use('space'),
      creature = resource.use('creature');

  var $ = this.$;

  //
  // auth nav
  //
  var user =  options.request.user;
  if (typeof user !== 'undefined') {
    $('#auth-nav').html("<p>hi " + user.id + "</p>");
  } else {
    var auth = resource.use('auth');
    auth.view.login.min.present({}, function(err, result) {
      $('#auth-nav').html(result);
    });
  }

  var session = options.request.session || {};
  async.waterfall([
    //
    // all-spaces nav
    //
    function(callback) {

      // TODO: update the following once we can pass spaces into space.view.get.min
      // get all spaces
      space.all(function(err, spaces) {
        if (err) { return callback(err); }

        // retrieve each space id, then render them all
        async.map(spaces,
          function(_space, callback) {
              callback(null, _space.id);

          // render spaces
          }, function(err, spaces) {
            if (err) { return callback(err); }
            space.view.get.min.present({
              data: {
                id: spaces
              }

            // append rendered spaces to dom
            }, function(err, result) {
              if (err) { return callback(err); }
              $('#all-spaces-nav').append(result);
              callback(null);
            });
        });
      });
    },


    // get creatureID in session
    function(callback) {
      // if session does not yet have a creature, generate a random one
      if (typeof session.creatureID === 'undefined') {
        var creatureName = Faker.Name.lastName();
        creature.create({
          'name': creatureName,
          'description': Faker.Lorem.sentence()
        }, function(err, _creature) {
          if (err) { return callback(err); }
          // add creature to session
          session.creatureID = _creature.id;
          return callback(null, session.creatureID);
        });
      // if session has a creature
      } else {
        // use it
        callback(null, session.creatureID);
      }
    },

    // get creature from creatureID
    function(creatureID, callback) {
      creature.get(creatureID, callback);
    },

    //
    // top menu
    //
    // make creature buttons
    function(_creature, callback) {

      // get view of this creature
      creature.view.get.button.present({
{'fraction_non_alphanumeric': 0.1443177349587102, 'fraction_numerical': 0.00039323633503735744, 'mean_word_length': 1.8740112994350282, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '2304525', 'n_tokens_mistral': 1442, 'n_tokens_neox': 1420, 'n_words': 360}