<commit_before>var express = require( 'express' ),
		app = express(),
		debug = require( 'debug' )( 'dashboard:init' ),
		config = require( './config' ),
		swig = require( 'swig' ),
		path = require( 'path' ),
		fs = require( 'fs' );

app.engine('tpl', swig.renderFile);
app.set( 'views', __dirname + '/views' );
app.set( 'view engine', 'tpl' );

// Disabled Views cache
app.set('view cache', false);
swig.setDefaults({ cache: false });

app.use( express.static( __dirname + '/public' ) );

require( 'require-fu' )(  __dirname + '/routers' )( app );

/***/

var dirBase = path.join( __dirname, 'tiles' ),
		dirTimer = path.join( dirBase, 'timer' ),
		timerPkg = require( path.join( dirTimer, 'package.json' ) );

app.use( '/tiles/' + timerPkg.name + '/api', require( path.join( dirTimer, 'server' ) ) );
app.get( '/tiles/' + timerPkg.name, function( req, res, next ){
	debug( path.join( dirTimer, 'client', 'index.html' ) );
	res.set( {'Content-Type': 'text/html'} );
	fs.createReadStream( path.join( dirTimer, 'client', 'index.html' ) ).pipe( res );
} );

/***/

app.listen( config.get( 'app:port' ), function(){
	debug( 'Server listen in %d', config.get( 'app:port' ) );
} );
<commit_msg>Mount tiles in a dynamic way<commit_after>var express = require( 'express' ),
		app = express(),
		debug = require( 'debug' )( 'dashboard:init' ),
		config = require( './config' ),
		swig = require( 'swig' ),
		path = require( 'path' ),
		fs = require( 'fs' );

app.engine('tpl', swig.renderFile);
app.set( 'views', __dirname + '/views' );
app.set( 'view engine', 'tpl' );

// Disabled Views cache
app.set('view cache', false);
swig.setDefaults({ cache: false });

app.use( express.static( __dirname + '/public' ) );

require( 'require-fu' )(  __dirname + '/routers' )( app );

var dirBase = path.join( __dirname, 'tiles' );
mountTiles( dirBase, function() {
	app.listen( config.get( 'app:port' ), function(){
		debug( 'Server listen in %d', config.get( 'app:port' ) );
	} );

} );

function mountTiles( dirBase, callback ) {
	fs.readdir( dirBase, function( err, files ) {
		files.forEach( function( file ) {
			var dirTimer = path.join( dirBase, file ),
				timerPkg = require( path.join( dirTimer, 'package.json' ) );

			app.use( '/tiles/' + timerPkg.name + '/api', require( path.join( dirTimer, 'server' ) ) );
			app.get( '/tiles/' + timerPkg.name, function( req, res, next ){
				res.set( {'Content-Type': 'text/html'} );
				fs.createReadStream( path.join( dirTimer, 'client', 'index.html' ) ).pipe( res );
			} );
		});

		callback();
	});
}

{'fraction_non_alphanumeric': 0.2137795275590551, 'fraction_numerical': 0.0, 'mean_word_length': 3.8865384615384615, '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': '3881289', 'n_tokens_mistral': 948, 'n_tokens_neox': 912, 'n_words': 227}