Commit 8ee14248 authored by maik alms's avatar maik alms

Merge branch 'master' of 10.2.0.3:Compilenix/blogger

parents d0672209 18b98c02
......@@ -3,5 +3,6 @@ parts/
*.log
*.gz
*.bz2
cache/
node_modules
/Config.js
......@@ -7,6 +7,8 @@ var Config = {
authorMail: "user@domain.tld",
Link: "http://127.0.0.1",
DirectoryCache: "cache",
DefaultContentType: "text/html",
ServerVersion: "node.js/" + process.version,
server: {
port: 8000
},
......
var DirectoryCache = _Config.post.DirectoryCache || "cache";
var DirectoryCache = _Config.DirectoryCache || "cache";
function has(req) {
return _fs.existsSync(_path(req));
return _fs.existsSync(_path(req));
}
function send(req, res) {
if (has(req)) {
var dataToSend = _fs.readFileSync(_path(req), 'utf8');
res.setContent(dataToSend);
return res;
}
if (has(req)) {
var dataToSend = _fs.readFileSync(_path(req), 'utf8');
res.setContent(dataToSend);
return res;
}
}
function add(req, cont) {
_fs.writeFileSync(_path(req), cont);
_fs.writeFileSync(_path(req), cont);
}
function _hash(req) {
var shasum = _crypto.createHash('sha1');
shasum.update(req.url);
return shasum.digest('hex');
var shasum = _crypto.createHash('sha1');
shasum.update(req.url);
return shasum.digest('hex');
}
function _path(req) {
return DirectoryCache + '/' + _hash(req);
return DirectoryCache + '/' + _hash(req);
}
exports.send = send;
exports.add = add;
exports.has = has;
function _responseWrapper(response) {
this.response = response;
this.data = '';
this.responseCode = 200;
this.responseCode = 404;
this.contentLength = 0;
this.contentType = "text/html";
this.serverVersion = "node.js/" + process.version;
this.contentType = _Config.DefaultContentType || "text/html";
this.serverVersion = _Config.ServerVersion || "node.js/" + process.version;
}
_responseWrapper.prototype.setContent = function (content) {
......

var Port = _Config.server.port || 80;
function Start(handle, route) {
function onRequest(request, response) {
......@@ -12,7 +13,7 @@ function Start(handle, route) {
var server = _http.createServer(onRequest);
server.on('error', onErr);
server.listen(_Config.server.port || 80);
server.listen(Port);
}
function process_request(request, response, handle, route) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment