<commit_before>//console.log(require('node-sqlite3'));
var express = require('express');
var server = express();

server.use(express.bodyParser());
server.use(express.cookieParser());
server.use('/js', express.static(__dirname+'/client/js'));
server.use('/css', express.static(__dirname+'/client/css'));
server.use('/images', express.static(__dirname+'/client/images'));

var sessions = {};
var sessionIndex = 1000000000;

var htmlWriter = function(){
	this.html = '';
	this.append = function(line){
		this.html += line + '\n';
		return this;
	}
}

var createPage = function(session){
	return new htmlWriter()
		.append('<!DOCTYPE html>')
		.append('<html>')
		.append('<head>')
		.append('<title>RainbowCake</title>')
		.append('<link rel="stylesheet" type="text/css" href="/js/jquery-ui-1.10.0.custom/css/smoothness/jquery-ui-1.10.0.custom.min.css" />')
		.append('<link rel="stylesheet" type="text/css" href="/css/themes/default/rainbowcake.css" />')
		.append('<script type="text/javascript" src="/js/jquery-1.9.1.min.js"></script>')
		.append('<script type="text/javascript" src="/js/jquery-ui-1.10.0.custom/js/jquery-ui-1.10.0.custom.min.js"></script>')
		.append('<script type="text/javascript" src="/js/jquery.rainbowcake.js"></script>')
		.append('<script type="text/javascript">')
		.append('(function($){$.rainbowcake.session('+JSON.stringify(session)+').actions({});}(jQuery))')
		.append('</script>')
		.append('<script type="text/javascript" src="//lnf-jgett.eecs.umich.edu/demo/js/rainbowcake-actions.js"></script>') //TODO: replace this with stored data
		.append('<script type="text/javascript" src="/js/actions.js"></script>')
		.append('<script type="text/javascript" src="/js/client.js"></script>')
		.append('</head>')
		.append('<body>')
		.append('<div class="rainbowcake">')
		.append('</div>')
		.append('</body>')
		.append('</html>')
		.html;
}

var message = function(code){
	var result = '';
	switch (code){
		case '1':
			result = 'Invalid username or password';
			break;
		default:
			result = 'An unknown problem occurred.';
			break;
	}
	return result;
}

var createLogin = function(code){
	var msg = '';
	if (define(code, '') != '')
		msg = '<div class="login-error">'+message(code)+'</div>';
	return new htmlWriter()
		.append('<!DOCTYPE html>')
		.append('<html>')
		.append('<head>')
		.append('<title>RainbowCake Login</title>')
		.append('<link rel="stylesheet" type="text/css" href="/css/themes/default/rainbowcake.css" />')
		.append('</head>')
		.append('<body>')
		.append('<div class="rainbowcake-login">')
		.append('<form method="POST" action="/">')
		.append('<input type="hidden" name="command" value="login" />')
		.append('<div class="label">Username</div>')
		.append('<div class="control"><input type="textbox" name="username" value="" /></div>')
		.append('<div class="label">Password</div>')
		.append('<div class="control"><input type="password" name="password" value="" /></div>')
		.append('<div class="button"><input type="submit" value="Sign In" /></div>')
		.append(msg)
		.append('</form>')
		.append('</div>')
		.append('</body>')
		.append('</html>')
		.html;
}

var define = function(x, y){
	return (typeof x == 'undefined') ? y : x;
}

var createSession = function(callback){
	var session = {'id': (sessionIndex).toString(36), 'pwd': null};
	sessionIndex += 1;
	require('./server/commands.js')
		.command('shell-exec')
		.session(session)
		.data('pwd')
		.execute(function(result){
			sessions[session.id] = session;
			callback(session);
		});
}

var handleLogin = function(post, callback){
	var result = {'success': false, 'code': '1'}<commit_msg>fixed error caused by missing commands.js file, this was made a function inside rainbowcake.js<commit_after>//console.log(require('node-sqlite3'));
var express = require('express');
var server = express();

server.use(express.bodyParser());
server.use(express.cookieParser());
server.use('/js', express.static(__dirname+'/client/js'));
server.use('/css', express.static(__dirname+'/client/css'));
server.use('/images', express.static(__dirname+'/client/images'));

var sessions = {};
var sessionIndex = 1000000000;

var htmlWriter = function(){
	this.html = '';
	this.append = function(line){
		this.html += line + '\n';
		return this;
	}
}

var createPage = function(session){
	return new htmlWriter()
		.append('<!DOCTYPE html>')
		.append('<html>')
		.append('<head>')
		.append('<title>RainbowCake</title>')
		.append('<link rel="stylesheet" type="text/css" href="/js/jquery-ui-1.10.0.custom/css/smoothness/jquery-ui-1.10.0.custom.min.css" />')
		.append('<link rel="stylesheet" type="text/css" href="/css/themes/default/rainbowcake.css" />')
		.append('<script type="text/javascript" src="/js/jquery-1.9.1.min.js"></script>')
		.append('<script type="text/javascript" src="/js/jquery-ui-1.10.0.custom/js/jquery-ui-1.10.0.custom.min.js"></script>')
		.append('<script type="text/javascript" src="/js/jquery.rainbowcake.js"></script>')
		.append('<script type="text/javascript">')
		.append('(function($){$.rainbowcake.session('+JSON.stringify(session)+').actions({});}(jQuery))')
		.append('</script>')
		.append('<script type="text/javascript" src="//lnf-jgett.eecs.umich.edu/demo/js/rainbowcake-actions.js"></script>') //TODO: replace this with stored data
		.append('<script type="text/javascript" src="/js/actions.js"></script>')
		.append('<script type="text/javascript" src="/js/client.js"></script>')
		.append('</head>')
		.append('<body>')
		.append('<div class="rainbowcake">')
		.append('</div>')
		.append('</body>')
		.append('</html>')
		.html;
}

var message = function(code){
	var result = '';
	switch (code){
		case '1':
			result = 'Invalid username or password';
			break;
		default:
			result = 'An unknown problem occurred.';
			break;
	}
	return result;
}

var createLogin = function(code){
	var msg = '';
	if (define(code, '') != '')
		msg = '<div class="login-error">'+message(code)+'</div>';
	return new htmlWriter()
		.append('<!DOCTYPE html>')
		.append('<html>')
		.append('<head>')
		.append('<title>RainbowCake Login</title>')
		.append('<link rel="stylesheet" type="text/css" href="/css/themes/default/rainbowcake.css" />')
		.append('</head>')
		.append('<body>')
		.append('<div class="rainbowcake-login">')
		.append('<form method="POST" action="/">')
		.append('<input type="hidden" name="command" value="login" />')
		.append('<div class="label">Username</div>')
		.append('<div class="control"><input type="textbox" name="username" value="" /></div>')
		.append('<div class="label">Password</div>')
		.append('<div class="control"><input type="password" name="password" value="" /></div>')
		.append('<div class="button"><input type="submit" value="Sign In" /></div>')
		.append(msg)
		.append('</form>')
		.append('</div>')
		.append('</body>')
		.append('</html>')
		.html;
}

var define = function(x, y){
	return (typeof x == 'undefined') ? y : x;
}

var createSession = function(callback){
	var session = {'id': (sessionIndex).toString(36), 'pwd': <PASSWORD>};
	sessionIndex += 1;
	commands('shell-exec')
		.session(session)
		.data('pwd')
		.execute(function(result){
			sessions[session.id] = session;
			callback(session);
		});
}

var handleLogin = function(post, callback){
	var result = {'success': true, 'code': ''}
{'fraction_non_alphanumeric': 0.24001098448441577, 'fraction_numerical': 0.00947411780859536, 'mean_word_length': 4.941272430668842, 'pattern_counts': {'":': 0, '<': 118, '<?xml version=': 0, '>': 118, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '3547353', 'n_tokens_mistral': 2666, 'n_tokens_neox': 2450, 'n_words': 432}