NJSPURLS
========
Stands for "Node JS, Primary URL Servicer". It is a simple web framework that provides
and overhead for createing web applications based on the basic URL. There are manu
default parts that are used when servicing a web based applications.
How It Works
============
In NodeJS you define a layout using NJS script (html with tags that define purls that
are called to render pages). For EG if i wanted to create a page "http://host/mypage"
then i create a file called ./purls/mypage.js and inside this file i might create the
following:
exports.layout = function(request, response) {
var layout = "
";
return layout;
}
exports.title = function(request, response, callback) {
response.write("i am a title");
callback();
}
exports.body = function(request, response, callback) {
response.write("i am a body");
callback();
}
A request to http://localhost:8888/mypage will create html that looks like so:
i am a titlei am a body
and it does this by printing out the layout then reaplcing the bits
with the functions in the purl defined with the same name of the tag. For EG
means call the exported function "body" from mypage.js. Defaults
also do exist, and so you dont necessarily have to define your own everytime.
Static Files
============
Static resources are similarly very simple (for eg jpg's, png's, html, etc etc).
Any call to njspurls for a url that ends with a file with an extension are assumed
to be static... I.e. if the url is http://host/file.ext will make njspurls send a
file called "file.ext" from the res directory. URL Paths are not relavent here but
any url that ends with a x.y filename at the end WILL be serviced as a static file
from the res directory.
It should be noted that the path to the file in the URL is not important to
njspurls, for eg http://host/file.ext is exactly the same as
http://host/long/path/file.ext (i.e. the same file will be returned).