Skip to content

Instantly share code, notes, and snippets.

@deanlandolt
Created June 15, 2010 17:02
Show Gist options
  • Save deanlandolt/439379 to your computer and use it in GitHub Desktop.
Save deanlandolt/439379 to your computer and use it in GitHub Desktop.
exports.wrap = function(nextApp, options){
return require("jack/cascade").Cascade([
require("jack/static").Static(nextApp, {urls:[""], root:"public"}),
require("pintura/jsgi/redirect-root").RedirectRoot(
require("./jsgi/iewtf").IEWTF(
require("jsgi/class-alias").Handler(
nextApp
)
)
, "/legal/")
]);
};
/**
* The starting point for the infosphere when run with Jack
*/
try{
var pintura = require("pintura/pintura");
}catch(e){
// old loaders need to use this type of access, pintura will fix things from there
require("./lib/util/narwhal-compat");
pintura = require("pintura/pintura");
}
var File = require("file"),
transporter = require("pintura/jsgi/transporter");
var coreApp = require("app");
// setup the Jack application
exports.app =
// this will provide module wrapping for the server side CommonJS libraries for the client
transporter.Transporter({loader: function(id){
if(id.match(/-engine/)){
id = "../engines/default/lib/" + id;
}
return require.loader.loader.fetch(require.loader.resolvePkg(id.substring(0, id.length - 3),"","","")[0]);
}},
pintura.app
);
// wrap pintura app with any exposed app wrapper
if (typeof coreApp.wrap === "function") exports.app = coreApp.wrap(exports.app);
//var perseverePath = require("packages").resource("public/explorer.html").toString();
//perseverePath = perseverePath.substring(0, perseverePath.length - "/explorer.html".length).replace(/\\/,'/');
// now setup the development environment, handle static files before reloading the app
// for better performance
exports.development = function(app, options){
return require("jack/cascade").Cascade([
// cascade from static to pintura REST handling
/* // this will provide module wrapping for the Dojo modules for the client
transporter.Transporter({
urlPrefix:"/js/",
paths:["../../persevere/public/js/"],
converter: transporter.Dojo
}),*/
// the main place for static files accessible from the web
require("jack/static").Static(null, {urls:[""],root:"public"}),
//require("jack/static").Static(null, {urls:["/explorer"],root:perseverePath}),
//require("jack/static").Static(null, {urls:["/js/dojo-persevere"],root:perseverePath}),
// the typical reloader scenario
(!options || options.reload) ? require("jack/reloader").Reloader(File.join(File.cwd(), "jackconfig"), "app") :
exports.app
]);
};
// we start the REPL (the interactive JS console) because it is really helpful
new (require("worker").SharedWorker)("narwhal/repl");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment