+// require the main njspurls modules
var app = require("njspurls");
+// below we set a bunch of things globally for the app
+// set the port to listen to
app.setPort(8888);
+
+// location for loading "purls"
app.setPurlPath("./purls");
+
+// location for resources
+app.setResPath("./res");
+
+// purl to load for main page, i.e. /
app.setDefaultMainPurl("main");
app.addMenu("name1", "/linkto1");
app.addMenu("name2", "/linkto2");
+++ /dev/null
-function go(request, response, callback) {
- response.write("<br><br><font size=\"-1\"><i>Copyright PJR.cc 2012</i></font>");
- callback(request, response);
- return;
-}
-
-exports.go = go;
\ No newline at end of file
+++ /dev/null
-function go(request, response, callback) {
- console.log("in main_head.go");
- response.write("<html><head><title>im a head</title></head><body>");
- callback(request, response);
- return;
-}
-
-exports.go = go;
\ No newline at end of file
+++ /dev/null
-function go(request, response, callback) {
- console.log("in main_head.go");
- response.write("<table><tr><th>menu</th><td>item1</td><td>item2</td><td>item3</td></tr></table>");
- callback(request, response);
- return;
-}
-
-exports.go = go;
\ No newline at end of file
+++ /dev/null
-function process(request, response, callback) {
- response.write("Body");
- callback(request, response);
-}
-
-
-exports.process = process;
-exports.requireBody = function() { return true;};
+++ /dev/null
-function process(request, response, callback) {
- response.writeHead(302, { 'Location':'/body/'})
- callback(request, response);
-}
-
-
-exports.process = process;
-exports.requireBody = function() { return false;};
+++ /dev/null
-function requireBody() {
- return true;
-}
-
-function process(request, response, callback) {
- response.write("from callback<br>");
- callback(request, response);
-}
-
-exports.requireBody = requireBody;
-exports.process = process;
global.njspurls.mainPath = mainpath;
}
+exports.setResPath = function(setpath) {
+ // default purl path is set based on the module.parent if its relative
+ var basename = path.dirname(module.parent.filename);
+ var mainpath = path.resolve(basename, setpath);
+ console.log("setting res path to ", mainpath);
+ global.njspurls.mainResPath = mainpath;
+}
+
exports.setFooterText = function(text) {
global.njspurls.footerText = text;
}
}
function serveStatic(staticname, response) {
- var pathName = "./res/"+staticname;
+ var pathName = "";
+ if(typeof global.njspurls.mainResPath != "undefined") {
+ pathName = global.njspurls.mainResPath + "/" + staticname;
+ } else {
+ pathName = "./res/"+staticname;
+ }
console.log("Pathname for check is ", pathName);
fs.exists(pathName, function(exists) {
if(!exists) {