+++ /dev/null
-var http = require("http"),
- url = require("url"),
- path = require("path"),
- fs = require("fs"),
- req = require("./lib/wsrequest.js"),
- port = process.argv[2] || 8888;
-
-http.createServer(req.wsRequest).listen(port);
-
-console.log("Server running on port: ", port);
\ No newline at end of file
--- /dev/null
+
+var http = require("http"),
+ url = require("url"),
+ path = require("path"),
+ fs = require("fs"),
+ req = require("./wsrequest.js"),
+ localPort = 8888,
+ defaultLayout = "standard",
+ defaultMain = null;
+
+
+
+
+
+exports.setPort = function(port) {
+ localPort = port;
+}
+
+exports.start = function() {
+ // initialise req
+ req.setDefaultLayout(defaultLayout);
+ req.setDefaultMain(defaultMain);
+
+
+ http.createServer(req.wsRequest).listen(localPort);
+
+ console.log("Server running on port: ", localPort);
+}
+
+exports.setDefaultLayout = function(layout) {
+ defaultLayout = layout;
+}
+
+exports.setDefaultMain = function(main) {
+ defaultMain = main;
+}
\ No newline at end of file
--- /dev/null
+exports.standard = function () {
+ var lay = "<html><head><?njs header ?></head><body><?nfs title ?>";
+ lay += "<table width=\"100%\"><tr><td><?njs menu ?></td></tr>";
+ lay += "<tr valign=\"top\"><td></td><?njs sidebar ?><td><?njs body ?></td></tr>";
+ lay += "<tr><td><?njs footer ?></td></tr></table>";
+
+ return lay;
+}
+
+
+exports.straight = function () {
+ var lay = "<html><head><?njs header ?></head><body><?nfs title ?>";
+ lay += "<table width=\"100%\"><tr><td><?njs menu ?></td></tr>";
+ lay += "<tr valign=\"top\"><td></td><?njs sidebar ?><td><?njs body ?></td></tr>";
+ lay += "<tr><td><?njs footer ?></td></tr></table>";
+
+ return lay;
+}
\ No newline at end of file
var myparse = require("./myparse.js");
var webmain = require("./webmain.js");
-var staticExtensions = ["html", "gif", "jpg", "css", "js", "ico"];
+//var staticExtensions = ["html", "gif", "jpg", "css", "js", "ico"];
function wsRequest(request, response) {
var isStatic = 0;
var purl = url.parse(request.url);
- staticExtensions.forEach(function testExtn(setest) {
+ /*staticExtensions.forEach(function testExtn(setest) {
console.log("testing url: ", request.url);
console.log("against: ", purl.pathname);
var chk = purl.pathname.split(".");
if(chkid != -1) {
isStatic = 1;
}
- });
+ });*/
+
+ // if the end of the pathname is something.something, we assume static
+ var lpath = purl.pathname.split("/").pop();
+ var idx = lpath.indexOf(".");
+ console.log("testing url: ", request.url);
+ console.log("against: ", purl.pathname);
+ console.log("lpath is: '%s'", lpath);
+ console.log("type is: '%s'", typeof lpath);
+ console.log("idx is: ", idx);
+
+ if(idx > 0) isStatic = 1;
if(isStatic == 1) {
// do the static
- var servethis = purl.pathname.split("/").pop();
- serveStatic(servethis, response);
+ console.log("Service as static");
+ serveStatic(lpath, response);
return;
}