<commit_before>var express = require('express');
var app = express();
var stylus = require('stylus');
var nib = require('nib');
var http = require('http');
var path = require('path');
var socket_io = require('socket.io');

var server = http.createServer(app).listen(1338, function () {
	console.log('System Panel server listening on port 1338');
});

var io = socket_io.listen(server, {
	log : false
});

function compile(str, path) {
	return stylus(str).set('filename', path).use(nib());
}
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.use(stylus.middleware( { src: path.join(__dirname,'public'), compile: compile } ));
app.use(express.static(path.join(__dirname,'public')));
app.use(express.favicon());
app.use(express.urlencoded());
app.use(express.json());
app.use(express.methodOverride());
app.use(express.errorHandler());
app.use(express.cookieParser());
app.use(express.session({ secret: '1234567890ABCDEF' }));
app.use(app.router);
app.use('/tmp', express.static(__dirname + '/tmp'));

app.get('/', function(req, res, next) {
	require('./index.js').page(req, res, app, next);
});

app.get('/login', function(req, res, next) {
	require('./login.js').page(req, res, app, next);
});

app.post('/login', function(req, res, next) {
	require('./login.js').page(req, res, app, next);
});

app.get('/logout', function (req, res, next) {
	require('./logout.js').page(req, res, app, next);
});

app.get('/settings', function(req, res, next) {
	require('./settings.js').page(req, res, app, next);
});

app.post('/settings', function(req, res, next) {
	require('./settings.js').page(req, res, app, next);
});

app.get('/widgetcreate', function (req, res, next) {
	require('./widgetcreate.js').page(req, res, app, next);
});

function getUserWidget(data, cb) {
	var settings = require('./framework/settings.js');

	settings.get_user_info(data.username, function(user) {
		if (user != null) {
			var user_widget = null;

			for (var c = 0; c < user.widgets.length && !user_widget; c++) {
				if (user.widgets[c].id == data.widget_id) {
					user_widget = user.widgets[c];
				}
			}

			if (user_widget) {
				var folder = path.join('panelwidgets',user_widget.widget.folder);
				var loaded_widget = require('./' + path.join(folder, user_widget.widget.phpfile + '.js'));
				loaded_widget.manage_post(data.post_params, function(result, output) {
					if (result) {
						cb(user_widget, 200, output);
					} else {
						loaded_widget.data(function(widget_data) {
							if (widget_data != null) {
								if (data.json) {
									cb(user_widget, 200, 'application/json', widget_data);
								} else {
									app.set('views', path.join(folder.replace('.', __dirname),'views'));
									app.render(user_widget.widget.templatefile.replace('.tpl', ''), {
										data : widget_data,
										user_widget : user_widget,
										username : data.username
									}, function(err, output) {
										app.set('views', path.join(__dirname,'views'));<commit_msg>Some fixes<commit_after>var express = require('express');
var app = express();
var stylus = require('stylus');
var nib = require('nib');
var http = require('http');
var path = require('path');
var socket_io = require('socket.io');

var server = http.createServer(app).listen(1338, function () {
	console.log('System Panel server listening on port 1338');
});

var io = socket_io.listen(server, {
	log : false
});

function compile(str, path) {
	return stylus(str).set('filename', path).use(nib());
}
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.use(stylus.middleware( { src: path.join(__dirname,'public'), compile: compile } ));
app.use(express.static(path.join(__dirname,'public')));
app.use(express.favicon());
app.use(express.urlencoded());
app.use(express.json());
app.use(express.methodOverride());
app.use(express.errorHandler());
app.use(express.cookieParser());
app.use(express.session({ secret: '<KEY>' }));
app.use(app.router);
app.use('/tmp', express.static(__dirname + '/tmp'));

app.get('/', function(req, res, next) {
	require('./index.js').page(req, res, app, next);
});

app.get('/login', function(req, res, next) {
	require('./login.js').page(req, res, app, next);
});

app.post('/login', function(req, res, next) {
	require('./login.js').page(req, res, app, next);
});

app.get('/logout', function (req, res, next) {
	require('./logout.js').page(req, res, app, next);
});

app.get('/settings', function(req, res, next) {
	require('./settings.js').page(req, res, app, next);
});

app.post('/settings', function(req, res, next) {
	require('./settings.js').page(req, res, app, next);
});

app.get('/widgetcreate', function (req, res, next) {
	require('./widgetcreate.js').page(req, res, app, next);
});

function getUserWidget(data, cb) {
	var settings = require('./framework/settings.js');

	settings.get_user_info(data.username, function(user) {
		if (user != null) {
			var user_widget = null;

			for (var c = 0; c < user.widgets.length && !user_widget; c++) {
				if (user.widgets[c].id == data.widget_id) {
					user_widget = user.widgets[c];
				}
			}

			if (user_widget) {
				var loaded_widget = require(user_widget.widget);
				loaded_widget.manage_post(data.post_params, function(result, output) {
					if (result) {
						cb(user_widget, 200, output);
					} else {
						loaded_widget.data(function(widget_data) {
							if (widget_data != null) {
								if (data.json) {
									cb(user_widget, 200, 'application/json', widget_data);
								} else {
									app.set('views', path.join(__dirname ,'node_modules', user_widget.widget ,'views'));
									app.render(user_widget.widget.replace('spw-', ''), {
										data : widget_data,
										user_widget : user_widget,
										username : data.username
									}, function(err, output) {
										app.set('views', path.join(__dirname,'views'));
{'fraction_non_alphanumeric': 0.2027924399795675, 'fraction_numerical': 0.006810829218457347, 'mean_word_length': 4.221333333333333, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 4, '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': '5658497', 'n_tokens_mistral': 2253, 'n_tokens_neox': 1934, 'n_words': 392}