<commit_before>var mapjson = require('./mapjson.js');
var yogView = require('yog-view');
var yogBigPipe = require('yog-bigpipe');
var _ = require('lodash');

module.exports.views = function (app, conf) {
    var middleware = [];
    var viewEngines = [];

    app.set('views', conf.viewsDir);

    if (conf.viewCache) {
        app.enable('view cache');
    }

    //初始化map.json API
    app.fis = new mapjson.ResourceApi(conf.confDir);

    middleware.push(function (req, res, next) {
        res.fis = app.fis;
        next();
    });

    //初始化bigpipe
    if (conf.bigpipe) {
        middleware.push(yogBigPipe());
    }

    _(conf.engine).forEach(function (engine, name) {
        //设置view engine
        var viewEngine = new yogView(app, engine, conf[name] || {});
        viewEngines.push(viewEngine);
        app.engine(name, viewEngine.renderFile.bind(viewEngine));
    });

    yog.view = {
        cleanCache: function () {
            // 清除FIS resourcemap缓存
            app.fis = new mapjson.ResourceApi(conf.confDir);
            _(viewEngines).forEach(function (viewEngine) {
                viewEngine.cleanCache();
            });
        }
    };

    return function () {
        app.use(middleware);
    };
};

module.exports.views.defaultConf = {
    confDir: yog.ROOT_PATH + '/conf/fis',
    viewsDir: yog.ROOT_PATH + '/views',
    bigpipe: true,
    tpl: {
        cache: 'memory'
    },
    engine: {
        tpl: 'yog-swig'
    }
};<commit_msg>[upd] add bigpie conf<commit_after>var mapjson = require('./mapjson.js');
var yogView = require('yog-view');
var yogBigPipe = require('yog-bigpipe');
var _ = require('lodash');

module.exports.views = function (app, conf) {
    var middleware = [];
    var viewEngines = [];

    app.set('views', conf.viewsDir);

    if (conf.viewCache) {
        app.enable('view cache');
    }

    //初始化map.json API
    app.fis = new mapjson.ResourceApi(conf.confDir);

    middleware.push(function (req, res, next) {
        res.fis = app.fis;
        next();
    });

    //初始化bigpipe
    if (conf.bigpipe) {
        middleware.push(yogBigPipe(conf.bigpipeOpt));
    }

    _(conf.engine).forEach(function (engine, name) {
        //设置view engine
        var viewEngine = new yogView(app, engine, conf[name] || {});
        viewEngines.push(viewEngine);
        app.engine(name, viewEngine.renderFile.bind(viewEngine));
    });

    yog.view = {
        cleanCache: function () {
            // 清除FIS resourcemap缓存
            app.fis = new mapjson.ResourceApi(conf.confDir);
            _(viewEngines).forEach(function (viewEngine) {
                viewEngine.cleanCache();
            });
        }
    };

    return function () {
        app.use(middleware);
    };
};

module.exports.views.defaultConf = {
    confDir: yog.ROOT_PATH + '/conf/fis',
    viewsDir: yog.ROOT_PATH + '/views',
    bigpipe: true,
    bigpipeOpt: {
        skipAnalysis: true
    },
    tpl: {
        cache: 'memory'
    },
    engine: {
        tpl: 'yog-swig'
    }
};
{'fraction_non_alphanumeric': 0.1535393818544367, 'fraction_numerical': 0.0, 'mean_word_length': 2.1953290870488322, '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': '5411571', 'n_tokens_mistral': 1024, 'n_tokens_neox': 996, 'n_words': 174}