<commit_before>// Routes for the UI server. Suitable for dynamic content that should not be
// cached aggressively.
var fs = require('fs'),
    path = require('path'),
    express = require('express'),
    mirror = require('mirror'),
    Bones = require('bones'),
    controllers = require('../mvc/controllers'),
    models = require('../mvc/models');

module.exports = function(server, settings) {
    server.enable('jsonp callback');

    // Initialize bones, bones templates, server-side mixins.
    Bones.Bones(server);
    Bones.settings = settings;
    require('../mvc/models-server')(settings);

    // Add templates to the Bones template cache.
    var templatePath = path.join(__dirname, '..', 'templates'),
        templateFiles = fs.readdirSync(templatePath);
    for (var i = 0; i < templateFiles.length; i++) {
        var key = path.basename(templateFiles[i], '.hbs');
        Bones.templates[key] = fs.readFileSync(
            path.join(templatePath, templateFiles[i]),
            'utf-8'
        );
    }

    // Set up the backbone router
    new controllers.Router();

    // Static assets, mirrored module assets, and options mirrored to client.
    server.use(express.staticProvider(path.join(__dirname, '..', 'client')));
    server.get('/vendor.js', mirror.assets([
        'tilestream/client/js/jquery.js',
        'underscore/underscore.js',
        'backbone/backbone.js',
        'handlebars/handlebars.js',
        'bones/bones.js',
        'openlayers_slim/OpenLayers.js',
        'wax/control/lib/gridutil.js',
        'wax/build/wax.ol.min.js',
        'wax/lib/record.js',
        'tilestream/mvc/controllers.js',
        'tilestream/mvc/models.js',
        'tilestream/mvc/views.js',
        'tilestream/client/js/app.js'
    ]));
    server.get('/vendor.css', mirror.assets(['wax/theme/controls.css']));
    server.get('/theme/default/style.css', mirror.file('openlayers_slim/theme/default/style.css'));
    server.get('/settings.js', function(req, res, next) {
        res.send(
            'var Bones = Bones || {};\n' +
            'Bones.settings = ' + JSON.stringify(settings) + ';',
            { 'Content-Type': 'text/javascript' }
        );
    });

    // Add map wax endpoint.
    require('./wax')(server, settings);<commit_msg>Controllers must come last in vendor.js to have proper references to models.<commit_after>// Routes for the UI server. Suitable for dynamic content that should not be
// cached aggressively.
var fs = require('fs'),
    path = require('path'),
    express = require('express'),
    mirror = require('mirror'),
    Bones = require('bones'),
    controllers = require('../mvc/controllers'),
    models = require('../mvc/models');

module.exports = function(server, settings) {
    server.enable('jsonp callback');

    // Initialize bones, bones templates, server-side mixins.
    Bones.Bones(server);
    Bones.settings = settings;
    require('../mvc/models-server')(settings);

    // Add templates to the Bones template cache.
    var templatePath = path.join(__dirname, '..', 'templates'),
        templateFiles = fs.readdirSync(templatePath);
    for (var i = 0; i < templateFiles.length; i++) {
        var key = path.basename(templateFiles[i], '.hbs');
        Bones.templates[key] = fs.readFileSync(
            path.join(templatePath, templateFiles[i]),
            'utf-8'
        );
    }

    // Set up the backbone router
    new controllers.Router();

    // Static assets, mirrored module assets, and options mirrored to client.
    server.use(express.staticProvider(path.join(__dirname, '..', 'client')));
    server.get('/vendor.js', mirror.assets([
        'tilestream/client/js/jquery.js',
        'underscore/underscore.js',
        'backbone/backbone.js',
        'handlebars/handlebars.js',
        'bones/bones.js',
        'openlayers_slim/OpenLayers.js',
        'wax/control/lib/gridutil.js',
        'wax/build/wax.ol.min.js',
        'wax/lib/record.js',
        'tilestream/mvc/models.js',
        'tilestream/mvc/views.js',
        'tilestream/mvc/controllers.js',
        'tilestream/client/js/app.js'
    ]));
    server.get('/vendor.css', mirror.assets(['wax/theme/controls.css']));
    server.get('/theme/default/style.css', mirror.file('openlayers_slim/theme/default/style.css'));
    server.get('/settings.js', function(req, res, next) {
        res.send(
            'var Bones = Bones || {};\n' +
            'Bones.settings = ' + JSON.stringify(settings) + ';',
            { 'Content-Type': 'text/javascript' }
        );
    });

    // Add map wax endpoint.
    require('./wax')(server, settings);
{'fraction_non_alphanumeric': 0.1652569941444372, 'fraction_numerical': 0.0008674907829104315, 'mean_word_length': 2.654516640253566, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6570155', 'n_tokens_mistral': 1451, 'n_tokens_neox': 1415, 'n_words': 274}