lx-scan
Version:
License eXtension to find 5-tuples of all installed packages: name, version, project home page, license (e. g. Apache v2, BSD) and required notice. It includes a GUI to edit information for each package and to enter information if necessary.
39 lines (38 loc) • 1.29 kB
JavaScript
var fs = require("fs");
var pa = require("path");
module.exports.get = function(req,res) {
var jfile = req.query.jfile||"";
var verbose = req.query.verbose||"";
var path = req.query.path||"";
var type = req.query.type||"";
var oldpath = req.query.oldpath||"";
if(type === "html") {
var file = "";
if (path!== "") {
if(fs.existsSync(path)) {
if(fs.statSync(path).isFile()) { ;
// The user navigated all the way to a file; assume that they want to overwrite the file
// unless the file is a .json file
if(!/^.*\.json$/.test(pa.basename(path)))
file = pa.basename(path);
path = pa.dirname(path);
}
} else {
// user indicated a file path and name
if(fs.statSync(pa.dirname(path)).isDirectory()) {
file = pa.basename(path);
path = pa.dirname(path);
} else {
while(path && !fs.existsSync(path) && path !== ".")
path = pa.dirname(path);
if(!path || path=".") path = "";
}
}
if(file && !/\.html$/.test(file))
file += ".html";
}
res.render("htmloptions", {title: "LX Save Options",jfile:jfile,verbose:verbose,path:path,file:file,oldpath:oldpath});
} else if(type ==="json") {
res.redirect("/browse?caller=/save?type=json&jfile="+jfile+"&path="+pa.dirname(path));
}
};