<commit_before>var http = require("http");
http.globalAgent.maxSockets = 200;

var express = require('express');
var app = express();
var path = require("path");
var fs = require("fs");

var secretSettingsPath = __dirname + "/../../settings/secretSettings.json";
var settingsPath = __dirname + "/../../settings/settings.json";

if (!fs.existsSync(secretSettingsPath)) {
	console.error("Config file [" + secretSettingsPath + "] missing!");
	console.error("Did you forget to run `make decrypt_conf`?");
	process.exit(1);
}

(function() {
	var conf_time = fs.statSync(secretSettingsPath).mtime.getTime();
	var cast5_time = fs.statSync(secretSettingsPath + ".cast5").mtime.getTime();
 
	if (conf_time < cast5_time) {
		console.error("Your config file is out of date!");
		console.error("You need to run `make decrypt_conf` to update it.");
		process.exit(1);
	}
})();

var secretSettings = JSON.parse(fs.readFileSync(secretSettingsPath, "utf8"));
var settings = JSON.parse(fs.readFileSync(settingsPath, "utf8"));

app.version = settings.version;
var versionator = require('versionator').create(app.version);

exports.init = function(port) {

	function authorize(username, password) {
		return secretSettings.admin.basicAuthId === username & secretSettings.admin.basicAuthPassword === password;
	}

	app.enable('trust proxy');

	app.configure(function(){
//		app.use(express.basicAuth(authorize));
		app.set('views', __dirname + '/views');
		app.set('view engine', 'ejs');
//		app.use(express.logger());
//		app.use(express.compress());
//		app.use(express.bodyParser());
//		app.use(express.methodOverride());
		app.use(versionator.middleware);
		app.use(express.static(__dirname + '/static', {maxAge: 31104000000})); //
		app.use(express.static(__dirname + '/chapters'));
		app.use(express.static(__dirname + '/../../fass/www'));
		app.use(app.router);
//		app.use(express.errorHandler({ dumpExceptions: true, showStack: true })); 
	});

	app.configure('development', function(){
		app.use(express.errorHandler()); 
		//app.use(express.errorHandler({ dumpExceptions: true, showStack: true })); 
		// app.use(express.logger({ format: ':method :url' }));
	});

 	app.configure('production', function(){
		app.use(express.errorHandler()); 
	});

	app.use(function(err, req, res, next) {
		res.render('500.ejs', { locals: { error: err }, status: 500});	
	});

	app.listen(port);
<commit_msg>Added a route for bookmarklets<commit_after>var http = require("http");
http.globalAgent.maxSockets = 200;

var express = require('express');
var app = express();
var path = require("path");
var fs = require("fs");

var secretSettingsPath = __dirname + "/../../settings/secretSettings.json";
var settingsPath = __dirname + "/../../settings/settings.json";

if (!fs.existsSync(secretSettingsPath)) {
	console.error("Config file [" + secretSettingsPath + "] missing!");
	console.error("Did you forget to run `make decrypt_conf`?");
	process.exit(1);
}

(function() {
	var conf_time = fs.statSync(secretSettingsPath).mtime.getTime();
	var cast5_time = fs.statSync(secretSettingsPath + ".cast5").mtime.getTime();
 
	if (conf_time < cast5_time) {
		console.error("Your config file is out of date!");
		console.error("You need to run `make decrypt_conf` to update it.");
		process.exit(1);
	}
})();

var secretSettings = JSON.parse(fs.readFileSync(secretSettingsPath, "utf8"));
var settings = JSON.parse(fs.readFileSync(settingsPath, "utf8"));

app.version = settings.version;
var versionator = require('versionator').create(app.version);

exports.init = function(port) {

	function authorize(username, password) {
		return secretSettings.admin.basicAuthId === username & secretSettings.admin.basicAuthPassword === password;
	}

	app.enable('trust proxy');

	app.configure(function(){
//		app.use(express.basicAuth(authorize));
		app.set('views', __dirname + '/views');
		app.set('view engine', 'ejs');
//		app.use(express.logger());
//		app.use(express.compress());
//		app.use(express.bodyParser());
//		app.use(express.methodOverride());
		app.use(versionator.middleware);
		app.use('/bookmarklets', express.static(__dirname + '/bookmarklets'));
		app.use(express.static(__dirname + '/static', {maxAge: 31104000000})); //
		app.use(express.static(__dirname + '/chapters'));
		app.use(express.static(__dirname + '/../../fass/www'));
		app.use(app.router);
//		app.use(express.errorHandler({ dumpExceptions: true, showStack: true })); 
	});

	app.configure('development', function(){
		app.use(express.errorHandler()); 
		//app.use(express.errorHandler({ dumpExceptions: true, showStack: true })); 
		// app.use(express.logger({ format: ':method :url' }));
	});

 	app.configure('production', function(){
		app.use(express.errorHandler()); 
	});

	app.use(function(err, req, res, next) {
		res.render('500.ejs', { locals: { error: err }, status: 500});	
	});

	app.listen(port);

{'fraction_non_alphanumeric': 0.19123095924248662, 'fraction_numerical': 0.011115685467270481, 'mean_word_length': 4.976629766297663, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5588835', 'n_tokens_mistral': 1643, 'n_tokens_neox': 1543, 'n_words': 297}