<commit_before>require('./conf/config');

var connect = require('connect'),
    combo   = require('combohandler'),
    express = require('express'),
    Y       = require('yui').use('handlebars'),

    app    = express.createServer(),
    pubDir = global.config.pubDir;

// -- Express config -----------------------------------------------------------
app.configure('development', function () {
    // Gives us pretty logs in development. Must run before other middleware.
    app.use(express.logger(
        '[:date] :req[x-forwarded-for] ":method :url" :status [:response-time ms]'
    ));
});

app.configure(function () {
    // Don't ignore trailing slashes in routes.
    app.set('strict routing', true);

    // Use our custom Handlebars-based view engine as the default.
    app.register('.handlebars', require('./lib/view'));
    app.set('view engine', 'handlebars');

    // Local values that will be shared across all views. Locals specified at
    // render time will override these values if they share the same name.
    app.set('view options', Y.merge(require('./conf/common'), {
        config: global.config
    }));

    // Middleware.
    app.use(app.router);
    app.use(express.favicon());
    app.use(express.static(pubDir));
});

app.configure('development', function () {
    app.use(express.errorHandler({
        dumpExceptions: true,
        showStack     : true
    }));
});

app.configure('production', function () {
    app.enable('view cache');
    app.use(express.errorHandler());
});

// -- Routes -------------------------------------------------------------------

// Root.
app.get('/', function (req, res) {
    res.render('index');
});

// Combo-handler for JavaScript.
app.get('/combo', combo.combine({rootPath: pubDir + '/js'}), function (req, res) {
    if (connect.utils.conditionalGET(req)) {
        if (!connect.utils.modified(req, res)) {
            return connect.utils.notModified(res);
        }
    }

    res.send(res.body, 200);
});

// Dymanic resource for precompiled templates.
app.get('/templates.js', (function () {
    var precompiled = require('./lib/templates').precompiled,
        templates   = [];

    Y.Object.each(precompiled, function (template, name) {
        templates.push({
            name    : name,
            template: template
        });
    });

    return function (req, res) {
        res.render('templates', {
            layout   : false,
            templates: templates
        }, function (err, view) {
            res.send(view, {'Content-Type': 'application/javascript'}, 200);
        });
    };
}()));

module.exports = app;
<commit_msg>Removed Y.Handlebars dependency from app.js (server).<commit_after>require('./conf/config');

var connect = require('connect'),
    combo   = require('combohandler'),
    express = require('express'),
    Y       = require('yui/yui-base'),

    app    = express.createServer(),
    pubDir = global.config.pubDir;

// -- Express config -----------------------------------------------------------
app.configure('development', function () {
    // Gives us pretty logs in development. Must run before other middleware.
    app.use(express.logger(
        '[:date] :req[x-forwarded-for] ":method :url" :status [:response-time ms]'
    ));
});

app.configure(function () {
    // Don't ignore trailing slashes in routes.
    app.set('strict routing', true);

    // Use our custom Handlebars-based view engine as the default.
    app.register('.handlebars', require('./lib/view'));
    app.set('view engine', 'handlebars');

    // Local values that will be shared across all views. Locals specified at
    // render time will override these values if they share the same name.
    app.set('view options', Y.merge(require('./conf/common'), {
        config: global.config
    }));

    // Middleware.
    app.use(app.router);
    app.use(express.favicon());
    app.use(express.static(pubDir));
});

app.configure('development', function () {
    app.use(express.errorHandler({
        dumpExceptions: true,
        showStack     : true
    }));
});

app.configure('production', function () {
    app.enable('view cache');
    app.use(express.errorHandler());
});

// -- Routes -------------------------------------------------------------------

// Root.
app.get('/', function (req, res) {
    res.render('index');
});

// Combo-handler for JavaScript.
app.get('/combo', combo.combine({rootPath: pubDir + '/js'}), function (req, res) {
    if (connect.utils.conditionalGET(req)) {
        if (!connect.utils.modified(req, res)) {
            return connect.utils.notModified(res);
        }
    }

    res.send(res.body, 200);
});

// Dymanic resource for precompiled templates.
app.get('/templates.js', (function () {
    var precompiled = require('./lib/templates').precompiled,
        templates   = [];

    Y.Object.each(precompiled, function (template, name) {
        templates.push({
            name    : name,
            template: template
        });
    });

    return function (req, res) {
        res.render('templates', {
            layout   : false,
            templates: templates
        }, function (err, view) {
            res.send(view, {'Content-Type': 'application/javascript'}, 200);
        });
    };
}()));

module.exports = app;

{'fraction_non_alphanumeric': 0.20586565752128666, 'fraction_numerical': 0.002270577105014191, 'mean_word_length': 2.2350061199510405, 'pattern_counts': {'":': 2, '<': 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': '990119', 'n_tokens_mistral': 1504, 'n_tokens_neox': 1457, 'n_words': 345}