<commit_before>/**
 * Module dependencies
 */

var angular = window.angular;
var hyper = require('ng-hyper');
var feature = require('ng-feature');
var translate = require('ng-hyper-translate');
var logger = require('./client/logger');
var token = require('access-token');
var envs = require('envs');

/**
 * setup different types of methods
 */

var TYPES = [
  'view',
  'directive',
  'controller',
  'service',
  'filter'
];

/**
 * Expose App constructor
 */

exports = module.exports = App;

/**
 * Initialize a poe-ui app
 *
 * @param {String} name
 */

function App(name) {
  if (!(this instanceof App)) return new App(name);

  var self = this;
  self.name = name;
  self.deps = [hyper.name, translate.name, feature.name];
  self.configures = [cachePartials(this)];
  types(function(type) {
    self[type + 's'] = {};
  });
}

/**
 * Use a plugin
 *
 * @param {String|Object|Function} dep
 */

App.prototype.use = function(dep) {
  if (typeof dep === 'function') return dep(this);
  if (dep.name) return this.deps.push(dep.name);
  this.deps.push(dep);
};

/**
 * Load the routes
 *
 * @param {Object} routes
 */

App.prototype.routes = function(routes) {
  this.routes = routes;
};

/**
 * Add a configure function
 *
 * @param {Function} fn
 */

App.prototype.configure = function(fn) {
  this.configures.push(fn);
};

/**
 * Start the application
 *
 * @param {Object} scope
 * @param {Function} fn
 */

App.prototype.start = function(scope, fn) {
  var self = this;
  var mod = self.module = angular.module(self.name, self.deps);
  mod.name = self.name;

  envs.set(scope);

  types(function(type) {
    if (type === 'view') return;
    var confs = self[type + 's'];
    angular.forEach(confs, function(conf, name) {
      if (typeof conf === 'function') return conf(mod);
      mod[type](name, conf);
    });
  });

  initRoutes(mod, self.routes, self.views, self.controllers);
  initHttp(mod);

  if (fn) self.configures.push(fn);

  start(mod, self);

  angular.bootstrap(document, [self.name]);

  return mod;
};

/**
 * Setup the type registration methods
 */

types(function(type) {
  var plural = type + 's';
  App.prototype[type] = function(name, conf) {
    if (type === 'controller') name = toController(name);
    if (type === 'view') this[plural][name.replace('.jade', '')] = conf;
    this[plural][name] = conf;
  };<commit_msg>fix routing views with html extension<commit_after>/**
 * Module dependencies
 */

var angular = window.angular;
var hyper = require('ng-hyper');
var feature = require('ng-feature');
var translate = require('ng-hyper-translate');
var logger = require('./client/logger');
var token = require('access-token');
var envs = require('envs');

/**
 * setup different types of methods
 */

var TYPES = [
  'view',
  'directive',
  'controller',
  'service',
  'filter'
];

/**
 * Expose App constructor
 */

exports = module.exports = App;

/**
 * Initialize a poe-ui app
 *
 * @param {String} name
 */

function App(name) {
  if (!(this instanceof App)) return new App(name);

  var self = this;
  self.name = name;
  self.deps = [hyper.name, translate.name, feature.name];
  self.configures = [cachePartials(this)];
  types(function(type) {
    self[type + 's'] = {};
  });
}

/**
 * Use a plugin
 *
 * @param {String|Object|Function} dep
 */

App.prototype.use = function(dep) {
  if (typeof dep === 'function') return dep(this);
  if (dep.name) return this.deps.push(dep.name);
  this.deps.push(dep);
};

/**
 * Load the routes
 *
 * @param {Object} routes
 */

App.prototype.routes = function(routes) {
  this.routes = routes;
};

/**
 * Add a configure function
 *
 * @param {Function} fn
 */

App.prototype.configure = function(fn) {
  this.configures.push(fn);
};

/**
 * Start the application
 *
 * @param {Object} scope
 * @param {Function} fn
 */

App.prototype.start = function(scope, fn) {
  var self = this;
  var mod = self.module = angular.module(self.name, self.deps);
  mod.name = self.name;

  envs.set(scope);

  types(function(type) {
    if (type === 'view') return;
    var confs = self[type + 's'];
    angular.forEach(confs, function(conf, name) {
      if (typeof conf === 'function') return conf(mod);
      mod[type](name, conf);
    });
  });

  initRoutes(mod, self.routes, self.views, self.controllers);
  initHttp(mod);

  if (fn) self.configures.push(fn);

  start(mod, self);

  angular.bootstrap(document, [self.name]);

  return mod;
};

/**
 * Setup the type registration methods
 */

types(function(type) {
  var plural = type + 's';
  App.prototype[type] = function(name, conf) {
    if (type === 'controller') name = toController(name);
    if (type === 'view') this[plural][name.replace('.jade', '').replace('.html', '')] = conf;
    this[plural][name] = conf;
  };
{'fraction_non_alphanumeric': 0.18332982529993685, 'fraction_numerical': 0.0, 'mean_word_length': 3.5128205128205128, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2385766', 'n_tokens_mistral': 1621, 'n_tokens_neox': 1611, 'n_words': 392}