From 6127f038fce5dbe47be01fdc565c14b5d8d24b80 Mon Sep 17 00:00:00 2001 From: paulr Date: Sun, 30 Dec 2012 21:59:57 +1100 Subject: [PATCH] some functionality for the basic flow of appsc --- examples/simple/myapp.js | 17 +++++++++++++---- examples/simple/purls/asdf.js | 17 ----------------- examples/simple/purls/justlayout.js | 6 ++++++ examples/simple/purls/simplelayout.js | 17 +++++++++++++++++ lib/wsrequest.js | 4 ++-- 5 files changed, 38 insertions(+), 23 deletions(-) delete mode 100644 examples/simple/purls/asdf.js create mode 100644 examples/simple/purls/justlayout.js create mode 100644 examples/simple/purls/simplelayout.js diff --git a/examples/simple/myapp.js b/examples/simple/myapp.js index dd24da3..aa29540 100644 --- a/examples/simple/myapp.js +++ b/examples/simple/myapp.js @@ -8,15 +8,24 @@ app.setPort(8888); // location for loading "purls" app.setPurlPath("./purls"); -// location for resources +// location for static resources app.setResPath("./res"); // purl to load for main page, i.e. / +// this will search for main.js from purls/ (this is the default) app.setDefaultMainPurl("main"); -app.addMenu("name1", "/linkto1"); -app.addMenu("name2", "/linkto2"); -app.addMenu("name3", "/linkto3"); + +// add some menu items for the default menu builder +app.addMenu("Home", "/"); +app.addMenu("SimpleLayout", "/simplelayout"); +app.addMenu("LayoutOnly", "/justlayout"); + +// default name for the application. Used by default section +// builders where a name is required app.setAppName("MyExampleApp"); + +// set some default footer text (typically a copyright notice or something app.setFooterText("

Copyright PJR.cc 2012 ©"); app.start(); + diff --git a/examples/simple/purls/asdf.js b/examples/simple/purls/asdf.js deleted file mode 100644 index 4548ccb..0000000 --- a/examples/simple/purls/asdf.js +++ /dev/null @@ -1,17 +0,0 @@ -exports.layout = function () { - var lay = "

Example Custom Layout




"; - - return lay; -} - - -exports.extra = function(request, response, callback) { - response.write("heres some stuff for extra!!
"); - callback(); -} - -exports.preResponse = function(request, response, callback) { - console.log("this is preresponse for asdf"); - callback(); -} - diff --git a/examples/simple/purls/justlayout.js b/examples/simple/purls/justlayout.js new file mode 100644 index 0000000..f02b439 --- /dev/null +++ b/examples/simple/purls/justlayout.js @@ -0,0 +1,6 @@ +exports.layout = function(request, response) { + var tkl = "

Just a Layout

this purl is simple a layout"; + tkl += " and nothing else!"; + + return tkl; +} \ No newline at end of file diff --git a/examples/simple/purls/simplelayout.js b/examples/simple/purls/simplelayout.js new file mode 100644 index 0000000..4548ccb --- /dev/null +++ b/examples/simple/purls/simplelayout.js @@ -0,0 +1,17 @@ +exports.layout = function () { + var lay = "

Example Custom Layout




"; + + return lay; +} + + +exports.extra = function(request, response, callback) { + response.write("heres some stuff for extra!!
"); + callback(); +} + +exports.preResponse = function(request, response, callback) { + console.log("this is preresponse for asdf"); + callback(); +} + diff --git a/lib/wsrequest.js b/lib/wsrequest.js index 81278bc..17547e7 100644 --- a/lib/wsrequest.js +++ b/lib/wsrequest.js @@ -156,10 +156,10 @@ function urlServicer(request, response, purl) { if(typeof purlClass.layout == "undefined") { console.log("set via undefined"); - purlLayout = layouts.standard(); + purlLayout = layouts.standard(request, response); } else { // find and resolve the layout - purlLayout = purlClass.layout(); + purlLayout = purlClass.layout(request, response); } // now we should have a layout and a class -- 1.7.0.4