/* |
|
author: daimajia |
|
|
|
name: appjs Express example |
|
|
|
email: daimajia@gmail.com |
|
|
|
any question feel free to email me :) |
|
*/ |
|
|
|
|
|
var appjs = module.exports = require('appjs'); |
|
var express = require('express'); |
|
var utils = require('util');// Create express server for routing |
|
|
|
appjs.serveFilesFrom(__dirname + '/content'); |
|
|
|
var appRouter = express(); |
|
|
|
/* |
|
*This is default views jade files directory. |
|
*Remeber to create a index.jade file in this directory. |
|
*/ |
|
appRouter.set('views',__dirname + '/content'); |
|
|
|
appRouter.use(express.bodyParser()); |
|
appRouter.engine('jade', require('jade').__express); |
|
appRouter.engine('html', require('ejs').renderFile); |
|
|
|
/** |
|
* Set up the express routes |
|
*/ |
|
appRouter.get('/', function(req, res, next){ |
|
res.render('index.jade', { name: 'Hello Jade!' }); |
|
}); |
|
|
|
appRouter.use(express.static(__dirname + '/content')); |
|
|
|
/** |
|
* Setup AppJS |
|
*/ |
|
|
|
// override AppJS's built in request handler with connect |
|
appjs.router.handle = appRouter.handle.bind(appRouter); |
|
|
|
// have express listen on a port:51686 |
|
appRouter.listen(23453); |
|
|
|
|
|
var window = appjs.createWindow('http://localhost:23453/', { |
|
width : 640, |
|
height: 460, |
|
icons : __dirname + '/content/icons' |
|
}); |
|
|
|
|
|
window.on('create', function(){ |
|
console.log("Window Created"); |
|
window.frame.show(); |
|
window.frame.center(); |
|
}); |
|
|
|
|
|
window.on('ready', function(){ |
|
window.require = require; |
|
window.process = process; |
|
window.module = module; |
|
}); |