mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-05 06:37:10 -04:00
make the app mountable
This commit is contained in:
parent
9f0ca7cc44
commit
6188c88e4a
6 changed files with 49 additions and 20 deletions
22
node/utils/Minify.js
Normal file → Executable file
22
node/utils/Minify.js
Normal file → Executable file
|
@ -35,6 +35,11 @@ var os = require('os');
|
|||
var TAR_PATH = path.join(__dirname, 'tar.json');
|
||||
var tar = JSON.parse(fs.readFileSync(TAR_PATH, 'utf8'));
|
||||
|
||||
module.exports = function(opts) {
|
||||
settings = opts;
|
||||
return exports;
|
||||
}
|
||||
|
||||
/**
|
||||
* creates the minifed javascript for the given minified name
|
||||
* @param req the Express request
|
||||
|
@ -63,7 +68,7 @@ exports.minifyJS = function(req, res, jsFilename)
|
|||
//find out the highest modification date
|
||||
function(callback)
|
||||
{
|
||||
var folders2check = ["../static/css","../static/js"];
|
||||
var folders2check = [__dirname+"/../../static/css",__dirname+"/../../static/js"];
|
||||
|
||||
//go trough this two folders
|
||||
async.forEach(folders2check, function(path, callback)
|
||||
|
@ -102,7 +107,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(__dirname+"/../../var/minified_" + jsFilename, function(err, stats)
|
||||
{
|
||||
if(err && err.code != "ENOENT")
|
||||
{
|
||||
|
@ -127,7 +132,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(__dirname+"/../../static/js/" + item, "utf-8", function(err, data)
|
||||
{
|
||||
if(ERR(err, callback)) return;
|
||||
fileValues[item] = data;
|
||||
|
@ -152,9 +157,10 @@ exports.minifyJS = function(req, res, jsFilename)
|
|||
{
|
||||
var filename = item.match(/"[^"]*"/g)[0].substr(1);
|
||||
filename = filename.substr(0,filename.length-1);
|
||||
|
||||
filename = __dirname+"/../"+filename
|
||||
|
||||
var type = item.match(/INCLUDE_[A-Z]+/g)[0].substr("INCLUDE_".length);
|
||||
|
||||
|
||||
//read the included file
|
||||
fs.readFile(filename, "utf-8", function(err, data)
|
||||
{
|
||||
|
@ -205,7 +211,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(__dirname+"/../../var/minified_" + jsFilename, result, "utf8", callback);
|
||||
},
|
||||
//write the results compressed in a file
|
||||
function(callback)
|
||||
|
@ -219,7 +225,7 @@ exports.minifyJS = function(req, res, jsFilename)
|
|||
|
||||
if(ERR(err, callback)) return;
|
||||
|
||||
fs.writeFile("../var/minified_" + jsFilename + ".gz", compressedResult, callback);
|
||||
fs.writeFile(__dirname+"/../../var/minified_" + jsFilename + ".gz", compressedResult, callback);
|
||||
});
|
||||
}
|
||||
//skip this step on windows
|
||||
|
@ -262,7 +268,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(__dirname+"/../../static/js/" + item, "utf-8", function(err, data)
|
||||
{
|
||||
if(ERR(err, callback)) return;
|
||||
fileValues[item] = data;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue