<commit_before>var path = require('path'),
	pattern = /(.*)\.css$/i,
	widgets = require('../widgets.js');

module.exports = function (app, options) {

	var lessCompiler = require('../utils/lessCompiler');

	if (options.lessPath) {
		app.get(path.join('/', options.lessPath, '*'), function (req, res, next) {
			var match = pattern.exec(req.path);
			if (!match) return next();
			var filePath = path.join(process.cwd(), match[1] + '.less');
			lessCompiler(filePath, function (err, css) {
				if (err) return next(err);
				if (!css) return next();
				sendCss(res, css);
			});
		});
	}

	var widgetLessPath = options.lessPath ? path.join('/', options.lessPath, '/widgets.css') : '/widgets.css',
		widgetLess = '';
	widgets.get().forEach(function(widget) {
		if (!widget.less) return;
		widgetLess += ('.widget-' + widget.path.join('_') + '{ @import \''+ widget.less + '\';}');
	});

	app.get(widgetLessPath, function(req, res, next){
		if (widgetLess === '') return sendCss(res, '');
		lessCompiler('/widget.less', widgetLess, function (err, css) {
			if (err) return next(err);
			if (!css) return next();
			sendCss(res, css);
		});
	});

};

function sendCss (res, css) {
	var etag = '"' + require('crypto').createHash('md5').update(css).digest('hex') + '"';
	res.set({
		'Content-Type': 'text/css',
		'ETag': etag,
		'Cache-Control': 'max-age=31536000'
	});
	res.send(css);
}<commit_msg>Included widgets in other less<commit_after>var path = require('path'),
	fs = require('fs'),
	pattern = /(.*)\.css$/i,
	widgets = require('../widgets.js');

module.exports = function (app, options) {

	var lessCompiler = require('../utils/lessCompiler');

	app.get(path.join('/', options.lessPath, '*'), function (req, res, next) {
		var match = pattern.exec(req.path);
		if (!match) return next();
		var filePath = path.join(process.cwd(), match[1] + '.less');
		fs.readFile(filePath, { encoding: 'utf8' }, function (err, data) {
			if (req.query.includeWidgets === 'true') {
				widgets.get().forEach(function(widget) {
					if (!widget.less) return;
					data += ('.widget-' + widget.path.join('_') + '{ @import \''+ path.relative(path.dirname(filePath), widget.less) + '\';}');
				});
			}
			lessCompiler(filePath, data, function (err, css) {
				if (err) return next(err);
				if (!css) return next();
				sendCss(res, css);
			});

		});
	});

};

function sendCss (res, css) {
	var etag = '"' + require('crypto').createHash('md5').update(css).digest('hex') + '"';
	res.set({
		'Content-Type': 'text/css',
		'ETag': etag,
		'Cache-Control': 'max-age=31536000'
	});
	res.send(css);
}
{'fraction_non_alphanumeric': 0.22802942315137437, 'fraction_numerical': 0.008130081300813009, 'mean_word_length': 3.893939393939394, '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': '5911587', 'n_tokens_mistral': 1025, 'n_tokens_neox': 913, 'n_words': 190}