<commit_before>var send	= require( process.env.ROOT + "/core/send" ).send,
	getUIE	= require( process.env.ROOT + "/db/queries" ).getUsersUIElement,
	modules	= new ( require( "node-static" ).Server )( process.env.ROOT + "/files/modules" ),
	Nscript	= process.env.DEV ? "N.dev.js" : "N.js",
	Rscript = process.env.DEV ? "require.dev.js" : "require.js";

//send initial html and javascript
this.index = function( link ) {
	
	//set headers
	link.res.headers['content-style-type'] = "text/css";
	link.res.headers['content-type'] = "text/html; charset=utf-8";
	
	send.ok( link.res, '<!DOCTYPE html><html><head><script data-main="11/' + Nscript + '" src="11/' + Rscript + '"></script></head><body></body></html>' );
};

//ui modules ( controllers )
// !TODO: optimize performance
this.modules = function( link ) {
	
	if( link.path[ 0 ] == Nscript || link.path[ 0 ] == Rscript ) {
		
		link.req.url = link.path.join( "/" );
		modules.serve( link.req, link.res );
	}
	else if( link.path && typeof link.path[ 0 ] != "undefined" ) {
		
		var moduleName = link.path[ 0 ].replace( /[^0-9a-z_\-]/gi, "" );
		
		if( moduleName != "" ) getUIE( moduleName, link.session.uid, function( err, res ){
			
			if( err || !res.name ) send.notfound( link.res );
			else {
				
				link.req.url = link.path.join( "/" );
				
				modules.serve( link.req, link.res );
			}
		});<commit_msg>load N.js like a normal module<commit_after>var send	= require( process.env.ROOT + "/core/send" ).send,
	getUIE	= require( process.env.ROOT + "/db/queries" ).getUsersUIElement,
	modules	= new ( require( "node-static" ).Server )( process.env.ROOT + "/files/modules" ),
	Nscript	= process.env.DEV ? "N.dev.js" : "N.js",
	Rscript = process.env.DEV ? "require.dev.js" : "require.js";

//send initial html and javascript
this.index = function( link ) {
	
	//set headers
	link.res.headers['content-style-type'] = "text/css";
	link.res.headers['content-type'] = "text/html; charset=utf-8";
	
	send.ok( link.res, '<!DOCTYPE html><html><head><script data-main="11/N/' + Nscript + '" src="11/' + Rscript + '"></script></head><body></body></html>' );
};

//ui modules ( controllers )
// !TODO: optimize performance
this.getModule = function( link ) {
	
	if( link.path[ 0 ] == Rscript ) {
		
		link.req.url = link.path.join( "/" );
		modules.serve( link.req, link.res );
	}
	else if( link.path && typeof link.path[ 0 ] != "undefined" ) {
		
		var moduleName = link.path[ 0 ].replace( /[^0-9a-z_\-]/gi, "" );
		
		if( moduleName != "" ) getUIE( moduleName, link.session.uid, function( err, res ){
			
			if( err || !res.name ) send.notfound( link.res );
			else {
				
				link.req.url = link.path.join( "/" );
				
				modules.serve( link.req, link.res );
			}
		});
{'fraction_non_alphanumeric': 0.21023564064801178, 'fraction_numerical': 0.007731958762886598, 'mean_word_length': 3.1607963246554363, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '7511876', 'n_tokens_mistral': 1082, 'n_tokens_neox': 968, 'n_words': 208}