<commit_before>/*
 *  Use:  $ node app.js -g <group>
 *
 * */


// Load Node.js libs.
var express = require('express');
var http = require('http');
var path = require('path');
var fs = require('fs');
var crypto = require('crypto');
var sqlite3 = require('sqlite3');
var database = require('./database');

// handle command line args
var argv = require('optimist')
            .usage('Run the Group Research web app.\nUsage: $0')
            .alias('g', 'group').describe('g', 'set the group to use').demand('g')
            .alias('p', 'pass').describe('p', 'set the group password').demand('p')
            .argv;

GLOBAL.group = argv.g;
GLOBAL.group_password = argv.p;

// Include modules for their handler functions.
var routes = require('./routes/index');  // routes/index.js  (default)
var submit = require('./routes/submit');  // routes/submit.js
var login = require('./routes/login');  // routes/submit.js
var config = require('./config'); //handle initial config shit

// Create application.
var app = express();

//add config shit
var devenv = config.devenvironment(app, express);


var dbname = GLOBAL.group + '.db';
GLOBAL.errormessage = '';

// Connect to database.
if ( !fs.existsSync( dbname ) )
{
    database.dbinit('init', dbname, GLOBAL.group, path);
    console.log( 'no database found, initializing database named \'' + GLOBAL.group + '\'');
}

var sha = crypto.createHash('sha1');
sha.update( GLOBAL.group + GLOBAL.password + Date.now().toString() );
var cookie_secret = sha.digest( 'hex' );

var grppath = __dirname + '/groups//' + GLOBAL.group + '//';
GLOBAL.db = new sqlite3.Database( dbname, sqlite3.OPEN_READWRITE );

// Set node/express variables.
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');

// Set up express middleware.
app.use(express.favicon());
//app.use(express.favicon(__dirname + '/public/images/favicon.ico'));
app.use(express.cookieParser( cookie_secret ));
app.use(express.session());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.static(path.join(__dirname, 'public')));
app.use(app.router);

// Set up routes and handlers.
//handle login
//app.get('/', login.login);
app.get('/', function(req, res) { res.redirect('/index') });
app.get('/index', routes.index);<commit_msg>use express.basicAuth()<commit_after>/*
 *  Use:  $ node app.js -g <group>
 *
 * */


// Load Node.js libs.
var express = require('express');
var http = require('http');
var path = require('path');
var fs = require('fs');
var crypto = require('crypto');
var sqlite3 = require('sqlite3');
var database = require('./database');

// handle command line args
var argv = require('optimist')
            .usage('Run the Group Research web app.\nUsage: $0')
            .alias('g', 'group').describe('g', 'set the group to use').demand('g')
            .alias('p', 'pass').describe('p', 'set the group password').demand('p')
            .argv;

GLOBAL.group = argv.g;
GLOBAL.group_password = argv.p;

// Include modules for their handler functions.
var routes = require('./routes/index');  // routes/index.js  (default)
var submit = require('./routes/submit');  // routes/submit.js
var login = require('./routes/login');  // routes/submit.js
var config = require('./config'); //handle initial config shit

// Create application.
var app = express();

//add config shit
var devenv = config.devenvironment(app, express);


var dbname = GLOBAL.group + '.db';
GLOBAL.errormessage = '';

// Connect to database.
if ( !fs.existsSync( dbname ) )
{
    database.dbinit('init', dbname, GLOBAL.group, path);
    console.log( 'no database found, initializing database named \'' + GLOBAL.group + '\'');
}

var sha = crypto.createHash('sha1');
sha.update( GLOBAL.group + GLOBAL.password + Date.now().toString() );
var cookie_secret = sha.digest( 'hex' );

var grppath = __dirname + '/groups//' + GLOBAL.group + '//';
GLOBAL.db = new sqlite3.Database( dbname, sqlite3.OPEN_READWRITE );

// Set node/express variables.
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');

// Set up express middleware.
app.use(express.favicon());
//app.use(express.favicon(__dirname + '/public/images/favicon.ico'));
app.use(express.cookieParser( cookie_secret ));
app.use(express.session());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.static(path.join(__dirname, 'public')));
app.use(express.basicAuth(GLOBAL.group, GLOBAL.group_password));
app.use(app.router);

// Set up routes and handlers.
//handle login
//app.get('/', login.login);
app.get('/', function(req, res) { res.redirect('/index') });
app.get('/index', routes.index);
{'fraction_non_alphanumeric': 0.1956476250261561, 'fraction_numerical': 0.004184975936388366, 'mean_word_length': 3.994775339602926, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3640473', 'n_tokens_mistral': 1529, 'n_tokens_neox': 1522, 'n_words': 376}