This commit is contained in:
GitHub Merge Button 2012-01-08 06:50:00 -08:00
commit 9462f90516
3 changed files with 17 additions and 12 deletions

View file

@ -45,8 +45,9 @@ var socketIORouter;
var version = "";
try
{
var ref = fs.readFileSync("../.git/HEAD", "utf-8");
var refPath = "../.git/" + ref.substring(5, ref.indexOf("\n"));
var rootPath = path.normalize(__dirname + "/../")
var ref = fs.readFileSync(rootPath + ".git/HEAD", "utf-8");
var refPath = rootPath + ".git/" + ref.substring(5, ref.indexOf("\n"));
version = fs.readFileSync(refPath, "utf-8");
version = version.substring(0, 7);
console.log("Your Etherpad Lite git version is " + version);

View file

@ -58,7 +58,9 @@ exports.minifyJS = function(req, res, jsFilename)
{
throw new Error("there is no profile for creating " + name);
}
var rootPath = path.normalize(__dirname + "/../../" );
//minifying is enabled
if(settings.minify)
{
@ -70,7 +72,7 @@ exports.minifyJS = function(req, res, jsFilename)
//find out the highest modification date
function(callback)
{
var folders2check = ["../static/css","../static/js"];
var folders2check = [rootPath + "static/css", rootPath + "static/js"];
//go trough this two folders
async.forEach(folders2check, function(path, callback)
@ -109,7 +111,7 @@ exports.minifyJS = function(req, res, jsFilename)
function(callback)
{
//check the modification time of the minified js
fs.stat("../var/minified_" + jsFilename, function(err, stats)
fs.stat(rootPath + "var/minified_" + jsFilename, function(err, stats)
{
if(err && err.code != "ENOENT")
{
@ -134,7 +136,7 @@ exports.minifyJS = function(req, res, jsFilename)
{
async.forEach(jsFiles, function (item, callback)
{
fs.readFile("../static/js/" + item, "utf-8", function(err, data)
fs.readFile(rootPath + "static/js/" + item, "utf-8", function(err, data)
{
if(ERR(err, callback)) return;
fileValues[item] = data;
@ -228,7 +230,7 @@ exports.minifyJS = function(req, res, jsFilename)
//write the results plain in a file
function(callback)
{
fs.writeFile("../var/minified_" + jsFilename, result, "utf8", callback);
fs.writeFile(rootPath + "var/minified_" + jsFilename, result, "utf8", callback);
},
//write the results compressed in a file
function(callback)
@ -242,7 +244,7 @@ exports.minifyJS = function(req, res, jsFilename)
if(ERR(err, callback)) return;
fs.writeFile("../var/minified_" + jsFilename + ".gz", compressedResult, callback);
fs.writeFile(rootPath + "var/minified_" + jsFilename + ".gz", compressedResult, callback);
});
}
//skip this step on windows
@ -266,12 +268,12 @@ exports.minifyJS = function(req, res, jsFilename)
var pathStr;
if(gzipSupport && os.type().indexOf("Windows") == -1)
{
pathStr = path.normalize(__dirname + "/../../var/minified_" + jsFilename + ".gz");
pathStr = path.normalize(rootPath + "var/minified_" + jsFilename + ".gz");
res.header('Content-Encoding', 'gzip');
}
else
{
pathStr = path.normalize(__dirname + "/../../var/minified_" + jsFilename );
pathStr = path.normalize(rootPath + "var/minified_" + jsFilename );
}
res.sendfile(pathStr, { maxAge: server.maxAge });
@ -285,7 +287,7 @@ exports.minifyJS = function(req, res, jsFilename)
//read all js files
async.forEach(jsFiles, function (item, callback)
{
fs.readFile("../static/js/" + item, "utf-8", function(err, data)
fs.readFile(rootPath + "static/js/" + item, "utf-8", function(err, data)
{
if(ERR(err, callback)) return;
fileValues[item] = data;

View file

@ -20,6 +20,7 @@
*/
var fs = require("fs");
var path = require('path');
/**
* The IP ep-lite should listen to
@ -74,7 +75,8 @@ exports.loglevel = "INFO";
exports.httpAuth = null;
//read the settings sync
var settingsStr = fs.readFileSync("../settings.json").toString();
var settingsPath = path.normalize(__dirname + "/../../");
var settingsStr = fs.readFileSync(settingsPath + "settings.json").toString();
//remove all comments
settingsStr = settingsStr.replace(/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/gm,"").replace(/#.*/g,"").replace(/\/\/.*/g,"");