impress
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -1,4 +0,4 @@ | ||
require('lib/impress'); | ||
require('impress'); | ||
impress.openDatabases(function() { | ||
impress.prepareDataStructures(); | ||
}); |
@@ -7,5 +7,6 @@ module.exports = function(req, res, callback) { | ||
{ name: "dima", age: 32, emails: ["user3@gmail.com", "user4@gmail.com", "user5@gmail.com"] }, | ||
] | ||
], | ||
session: JSON.stringify(impress.sessions[req.impress.session]) | ||
}; | ||
callback(); | ||
} |
@@ -0,2 +1,10 @@ | ||
0.0.3 / 2010-06-11 | ||
================== | ||
* Added template specialization for user groups. Fixed method impress.template(). | ||
* If there is active session, Impress will search for file templateName.groupName.template | ||
* If no group name specified it will search for templateName.everyone.template | ||
* If no such file found it will take templateName.template | ||
* If no such file found it will look into parent directory | ||
0.0.2 / 2010-06-10 | ||
@@ -3,0 +11,0 @@ ================== |
@@ -44,4 +44,6 @@ (function(impress) { | ||
// to be implemented following structure: { | ||
// user: id, // optional: null of userId, if session assigned to user | ||
// sse: [], // active SSE connections | ||
// userId: int, // optional: null of userId, if session assigned to user | ||
// login: string, | ||
// group: string, | ||
// sse: [], // active SSE connections | ||
// } | ||
@@ -683,3 +685,5 @@ | ||
impress.template = function(req, res, data, file, cursor, callback) { // callback(tpl) | ||
var fileName = file+'.template', | ||
var userGroup = ''; | ||
if (req.impress.session) userGroup = '.'+(impress.sessions[req.impress.session].group || 'everyone'); | ||
var fileName = file+userGroup+'.template', | ||
filePath = req.impress.hostDir+lastSlash(req.impress.path)+fileName; | ||
@@ -697,14 +701,30 @@ fileInclude = impress.cache.files[filePath]; | ||
} else { | ||
// Try to find template in parent directory | ||
if ((req.impress.path != '/') && (req.impress.path != '.')) { | ||
req.impress.path = impress.path.dirname(req.impress.path); | ||
impress.template(req, res, data, file, cursor, callback); | ||
impress.watchCache(req.impress.hostDir+req.impress.path+(req.impress.path.endsWith("/") ? "" : "/")); | ||
} else { | ||
// Lose hope to fine template and cave cache | ||
var fileOriginal = req.impress.hostDir+lastSlash(req.impress.url)+fileName; | ||
impress.cache.files[fileOriginal] = "{{FILE_NOT_FOUND}}"; | ||
impress.watchCache(fileOriginal); | ||
callback('No handler found'); | ||
} | ||
// Try to find template without group name | ||
fileName = file+'.template', | ||
filePath = req.impress.hostDir+lastSlash(req.impress.path)+fileName; | ||
fileInclude = impress.cache.files[filePath]; | ||
if (fileInclude) { | ||
if (fileInclude != "{{FILE_NOT_FOUND}}") impress.include(req, res, data, fileInclude, cursor, callback); | ||
else callback('[ Error: template not found "'+file+'" ]'); | ||
} else impress.fs.exists(filePath, function(exists) { | ||
if (exists) { | ||
impress.include(req, res, data, filePath, cursor, callback); | ||
var fileOriginal = req.impress.hostDir+lastSlash(req.impress.url)+fileName; | ||
impress.cache.files[fileOriginal] = filePath; | ||
impress.watchCache(fileOriginal); | ||
} else { | ||
// Try to find template in parent directory | ||
if ((req.impress.path != '/') && (req.impress.path != '.')) { | ||
req.impress.path = impress.path.dirname(req.impress.path); | ||
impress.template(req, res, data, file, cursor, callback); | ||
impress.watchCache(req.impress.hostDir+req.impress.path+(req.impress.path.endsWith("/") ? "" : "/")); | ||
} else { | ||
// Lose hope to fine template and cave cache | ||
var fileOriginal = req.impress.hostDir+lastSlash(req.impress.url)+fileName; | ||
impress.cache.files[fileOriginal] = "{{FILE_NOT_FOUND}}"; | ||
impress.watchCache(fileOriginal); | ||
callback('No handler found'); | ||
} | ||
} | ||
}); | ||
} | ||
@@ -711,0 +731,0 @@ }); |
{ | ||
"name": "impress", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"author": "Timur Shemsedinov <timur.shemsedinov@gmail.com>", | ||
@@ -5,0 +5,0 @@ "description": "Impressive totalitarian style web application framework", |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
516492
46
11217
3