<commit_before>
/**
 * Module dependencies.
 */

var express = require('express')
  , routes = require('./routes')
  , appjs = require('appjs')
  , utils = require('util');


var app = module.exports = express.createServer();

// Configuration

app.configure(function(){
  app.set('views', __dirname + '/views');
  app.set('view engine', 'ejs');
  app.use(express.bodyParser());
  app.use(express.methodOverride());
app.use(express.compiler({ src : __dirname + '/public', enable: ['less']}));
  app.use(app.router);
  app.use(express.static(__dirname + '/public'));
});

app.configure('development', function(){
  app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});

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

// Compatible

// Now less files with @import 'whatever.less' will work(https://github.com/senchalabs/connect/pull/174)
var TWITTER_BOOTSTRAP_PATH = './vendor/twitter/bootstrap/less';
express.compiler.compilers.less.compile = function(str, fn){
  try {
    var less = require('less');var parser = new less.Parser({paths: [TWITTER_BOOTSTRAP_PATH]});
    parser.parse(str, function(err, root){fn(err, root.toCSS());});
  } catch (err) {fn(err);}
}

// Routes

app.get('/', routes.index);


/**
 * Setup AppJS
 */

// override AppJS's built in request handler with connect
appjs.router.handle = app.handle.bind(app);

// have express listen on a port:51686
app.listen(51686);

/**
 * Window options; menus, icons, etc.
 */
var menubar = appjs.createMenu([{
  label:'&File',
  submenu:[
    {
      label:'E&xit',
      action: function(){
        window.close();
      }
    }
  ]
},{
  label:'&Window',
  submenu:[
    {
      label:'Fullscreen',
      action:function(item) {
        window.frame.fullscreen();
        console.log(item.label+" called.");
      }
    },
    {
      label:'Minimize',
      action:function(){
        window.frame.minimize();
      }
    },
    {
      label:'Maximize',
      action:function(){
        window.frame.maximize();
      }
    },{
      label:''//separator
    },{
      label:'Restore',
      action:function(){
        window.frame.restore();
      }
    }
  ]
}]);

menubar.on('select',function(item){
  console.log("menu item "+item.label+" clicked");
});

var trayMenu = appjs.createMenu([{
  label:'Show',
  action:function(){
    window.frame.show();
  },
},{
  label:'Minimize',
  action:function(){
    window.frame.hide();
  }
},{
  label:'Exit',
  action:function(){
    window.close();
  }
}]);

var statusIcon = appjs.createStatusIcon({
  icon:'./data/content/icons/32.png',
  tooltip:'AppJS Hello World',
  menu:trayMenu
});

// create window with url: http://localhost:51686/ instead of http://appjs/
var window = appjs.createWindow('http://localhost:51686/',
 {
  width : 640,
  height: 460,
  icons : __dirname + '/public/icons'
});

// show the window after initialization
window.on('create', function(){
  window.frame.show();
  window.frame.center();
  window.frame.setMenuBar(menubar);
});

// add require/process/module to the window global object for debugging from the DevTools
window.on('ready', function(){
  window.require = require;
  window.process = process;
  window.module = module;
  window.addEventListener('keydown', function(e){
    if (e.keyIdentifier === 'F12') {
      window.frame.openDevTools();
    }
  });
});

window.on('close', function(){
  console.log("Window Closed");
});<commit_msg>code cleanup<commit_after>/**
 * Module dependencies.
 */

var express = require('express'), routes = require('./routes'), appjs = require('appjs'), utils = require('util');

var app = module.exports = express.createServer();

// Configuration

app.configure(function() {
  app.set('views', __dirname + '/views');
  app.set('view engine', 'ejs');
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(express.compiler({
    src : __dirname + '/public',
    enable : ['less']
  }));
  app.use(app.router);
  app.use(express.static(__dirname + '/public'));
});

app.configure('development', function() {
  app.use(express.errorHandler({
    dumpExceptions : true,
    showStack : true
  }));
});

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

// Compatible

// Now less files with @import 'whatever.less' will
// work(https://github.com/senchalabs/connect/pull/174)
var TWITTER_BOOTSTRAP_PATH = './vendor/twitter/bootstrap/less';
express.compiler.compilers.less.compile = function(str, fn) {
  try {
    var less = require('less');
    var parser = new less.Parser({
      paths : [TWITTER_BOOTSTRAP_PATH]
    });
    parser.parse(str, function(err, root) {
      fn(err, root.toCSS());
    });
  } catch (err) {
    fn(err);
  }
}

// Routes

app.get('/', routes.index);

/**
 * Setup AppJS
 */

// override AppJS's built in request handler with connect
appjs.router.handle = app.handle.bind(app);

// have express listen on a port:51686
app.listen(51686);

/**
 * Window options; menus, icons, etc.
 */
var menubar = appjs.createMenu([{
  label : '&File',
  submenu : [{
    label : 'E&xit',
    action : function() {
      window.close();
    }
  }]
}, {
  label : '&Window',
  submenu : [{
    label : 'Fullscreen',
    action : function(item) {
      window.frame.fullscreen();
      console.log(item.label + " called.");
    }
  }, {
    label : 'Minimize',
    action : function() {
      window.frame.minimize();
    }
  }, {
    label : 'Maximize',
    action : function() {
      window.frame.maximize();
    }
  }, {
    label : ''// separator
  }, {
    label : 'Restore',
    action : function() {
      window.frame.restore();
    }
  }]
}]);

menubar.on('select', function(item) {
  console.log("menu item " + item.label + " clicked");
});

var trayMenu = appjs.createMenu([{
  label : 'Show',
  action : function() {
    window.frame.show();
  },
}, {
  label : 'Minimize',
  action : function() {
    window.frame.hide();
  }
}, {
  label : 'Exit',
  action : function() {
    window.close();
  }
}]);

var statusIcon = appjs.createStatusIcon({
  icon : './data/content/icons/32.png',
  tooltip : 'AppJS Hello World',
  menu : trayMenu
});

// create window with url: http://localhost:51686/ instead of http://appjs/
var window = appjs.createWindow('http://localhost:51686/', {
  width : 640,
  height : 460,
  icons : __dirname + '/public/icons'
});

// show the window after initialization
window.on('create', function() {
  window.frame.show();
  window.frame.center();
  window.frame.setMenuBar(menubar);
});

// add require/process/module to the window global object for debugging from the
// DevTools
window.on('ready', function() {
  window.require = require;
  window.process = process;
  window.module = module;
  window.addEventListener('keydown', function(e) {
    if (e.keyIdentifier === 'F12') {
      window.frame.openDevTools();
    }
  });
});

window.on('close', function() {
  console.log("Window Closed");
});
{'fraction_non_alphanumeric': 0.18723037100949094, 'fraction_numerical': 0.009490940465918895, 'mean_word_length': 3.311841289522629, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '5948546', 'n_tokens_mistral': 2340, 'n_tokens_neox': 2263, 'n_words': 448}