You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
628 B
JavaScript
25 lines
628 B
JavaScript
var nconf = require('nconf'),
|
|
path = require('path'),
|
|
fs = require('fs'),
|
|
Plugins = require('../plugins'),
|
|
|
|
PluginRoutes = function(app) {
|
|
// Static Assets
|
|
app.get('/plugins/:id/*', function(req, res) {
|
|
var relPath = req.url.replace('/plugins/' + req.params.id, '');
|
|
if (Plugins.staticDirs[req.params.id]) {
|
|
var fullPath = path.join(Plugins.staticDirs[req.params.id], relPath);
|
|
fs.exists(fullPath, function(exists) {
|
|
if (exists) {
|
|
res.sendfile(fullPath);
|
|
} else {
|
|
res.redirect('/404');
|
|
}
|
|
})
|
|
} else {
|
|
res.redirect('/404');
|
|
}
|
|
});
|
|
};
|
|
|
|
module.exports = PluginRoutes; |