-
Notifications
You must be signed in to change notification settings - Fork 0
/
wrappers.js
46 lines (38 loc) · 2.06 KB
/
wrappers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/************************************************************
* WRAPPERS *
*----------------------------------------------------------*
* AUTHOR: Christopher Webster *
* DATE: Oct. 3rd 2012 *
*----------------------------------------------------------*
* PURPOSE: *
* This file contains the response wrappers. *
* Each wrapper consumes a meta data object (css and *
* scripts), as well as the body *
* *
*----------------------------------------------------------*
* NOTES: *
* none *
*----------------------------------------------------------*
* CHANGES: *
* DATE: *
* CHANGE: *
* **********************************************************/
var util = require("util");
function standard(meta, body, response) {
var headerTagged = '<head>' + '<meta charset=\"utf-8\"/>' + '<title>' + meta.title + '</title>';
for (var i = 0; i < meta.css.length; i++) {
headerTagged += '<link rel="stylesheet" href="' + meta.css[i] + '" type="text/css" />';
}
for (i = 0; i < meta.jscripts.length; i++) {
headerTagged += '<script src="' + meta.jscripts[i] + '" type="text/javascript"></script>';
}
headerTagged += '</head>';
//complete the call...
var bodyTagged = '<body id="body">' + body + '</body>';
response.setHeader('Content-Type', "text/html");
response.writeHead(200);
response.write('<!DOCTYPE html>' + '<html>' + headerTagged + bodyTagged + '</html>');
response.end();
util.log("served page" + meta.title );
}
exports.standard = standard;