diff --git a/node/apicalls.js b/node/hooks/express/apicalls.js similarity index 97% rename from node/apicalls.js rename to node/hooks/express/apicalls.js index 183f4411..8a9751eb 100644 --- a/node/apicalls.js +++ b/node/hooks/express/apicalls.js @@ -1,7 +1,7 @@ var log4js = require('log4js'); var apiLogger = log4js.getLogger("API"); -var apiHandler = require('./handler/APIHandler'); var formidable = require('formidable'); +var apiHandler = require('../../handler/APIHandler'); //This is for making an api call, collecting all post information and passing it to the apiHandler exports.apiCaller = function(req, res, fields) { diff --git a/node/errorhandling.js b/node/hooks/express/errorhandling.js similarity index 97% rename from node/errorhandling.js rename to node/hooks/express/errorhandling.js index 1e8a734e..cb8c5898 100644 --- a/node/errorhandling.js +++ b/node/hooks/express/errorhandling.js @@ -1,5 +1,5 @@ -var db = require('./db/DB'); var os = require("os"); +var db = require('../../db/DB'); exports.onShutdown = false; diff --git a/node/importexport.js b/node/hooks/express/importexport.js similarity index 84% rename from node/importexport.js rename to node/hooks/express/importexport.js index b53447da..9e78f34d 100644 --- a/node/importexport.js +++ b/node/hooks/express/importexport.js @@ -1,7 +1,7 @@ -var hasPadAccess = require("./padaccess"); -var settings = require('./utils/Settings'); -var exportHandler = require('./handler/ExportHandler'); -var importHandler = require('./handler/ImportHandler'); +var hasPadAccess = require("../../padaccess"); +var settings = require('../../utils/Settings'); +var exportHandler = require('../../handler/ExportHandler'); +var importHandler = require('../../handler/ImportHandler'); exports.expressCreateServer = function (hook_name, args, cb) { args.app.get('/p/:pad/:rev?/export/:type', function(req, res, next) { diff --git a/node/minified.js b/node/hooks/express/minified.js similarity index 76% rename from node/minified.js rename to node/hooks/express/minified.js index f0f050a7..09a08cae 100644 --- a/node/minified.js +++ b/node/hooks/express/minified.js @@ -1,4 +1,4 @@ -var minify = require('./utils/Minify'); +var minify = require('../../utils/Minify'); exports.expressCreateServer = function (hook_name, args, cb) { //serve minified files diff --git a/node/padreadonly.js b/node/hooks/express/padreadonly.js similarity index 88% rename from node/padreadonly.js rename to node/hooks/express/padreadonly.js index 0121e7eb..60ece0ad 100644 --- a/node/padreadonly.js +++ b/node/hooks/express/padreadonly.js @@ -1,8 +1,8 @@ var async = require('async'); -var readOnlyManager = require("./db/ReadOnlyManager"); -var hasPadAccess = require("./padaccess"); -var exporthtml = require("./utils/ExportHtml"); var ERR = require("async-stacktrace"); +var readOnlyManager = require("../../db/ReadOnlyManager"); +var hasPadAccess = require("../../padaccess"); +var exporthtml = require("../../utils/ExportHtml"); exports.expressCreateServer = function (hook_name, args, cb) { //serve read only pad diff --git a/node/padurlsanitize.js b/node/hooks/express/padurlsanitize.js similarity index 94% rename from node/padurlsanitize.js rename to node/hooks/express/padurlsanitize.js index 6fdd5f79..4f5dd7a5 100644 --- a/node/padurlsanitize.js +++ b/node/hooks/express/padurlsanitize.js @@ -1,4 +1,4 @@ -var padManager = require('./db/PadManager'); +var padManager = require('../../db/PadManager'); exports.expressCreateServer = function (hook_name, args, cb) { //redirects browser to the pad's sanitized url if needed. otherwise, renders the html diff --git a/node/socketio.js b/node/hooks/express/socketio.js similarity index 80% rename from node/socketio.js rename to node/hooks/express/socketio.js index e6a4f95c..bc65c7b7 100644 --- a/node/socketio.js +++ b/node/hooks/express/socketio.js @@ -1,11 +1,11 @@ -var settings = require('./utils/Settings'); -var socketio = require('socket.io'); -var socketIORouter = require("./handler/SocketIORouter"); var log4js = require('log4js'); -var hooks = require("./pluginfw/hooks"); +var socketio = require('socket.io'); +var settings = require('../../utils/Settings'); +var socketIORouter = require("../../handler/SocketIORouter"); +var hooks = require("../../pluginfw/hooks"); -var padMessageHandler = require("./handler/PadMessageHandler"); -var timesliderMessageHandler = require("./handler/TimesliderMessageHandler"); +var padMessageHandler = require("../../handler/PadMessageHandler"); +var timesliderMessageHandler = require("../../handler/TimesliderMessageHandler"); exports.expressCreateServer = function (hook_name, args, cb) { diff --git a/node/specialpages.js b/node/hooks/express/specialpages.js similarity index 68% rename from node/specialpages.js rename to node/hooks/express/specialpages.js index 02509767..13cfd821 100644 --- a/node/specialpages.js +++ b/node/hooks/express/specialpages.js @@ -5,27 +5,27 @@ exports.expressCreateServer = function (hook_name, args, cb) { //serve index.html under / args.app.get('/', function(req, res) { - var filePath = path.normalize(__dirname + "/../static/index.html"); + var filePath = path.normalize(__dirname + "/../../../static/index.html"); res.sendfile(filePath, { maxAge: exports.maxAge }); }); //serve robots.txt args.app.get('/robots.txt', function(req, res) { - var filePath = path.normalize(__dirname + "/../static/robots.txt"); + var filePath = path.normalize(__dirname + "/../../../static/robots.txt"); res.sendfile(filePath, { maxAge: exports.maxAge }); }); //serve favicon.ico args.app.get('/favicon.ico', function(req, res) { - var filePath = path.normalize(__dirname + "/../static/custom/favicon.ico"); + var filePath = path.normalize(__dirname + "/../../../static/custom/favicon.ico"); res.sendfile(filePath, { maxAge: exports.maxAge }, function(err) { //there is no custom favicon, send the default favicon if(err) { - filePath = path.normalize(__dirname + "/../static/favicon.ico"); + filePath = path.normalize(__dirname + "/../../../static/favicon.ico"); res.sendfile(filePath, { maxAge: exports.maxAge }); } }); @@ -34,14 +34,14 @@ exports.expressCreateServer = function (hook_name, args, cb) { //serve pad.html under /p args.app.get('/p/:pad', function(req, res, next) { - var filePath = path.normalize(__dirname + "/../static/pad.html"); + var filePath = path.normalize(__dirname + "/../../../static/pad.html"); res.sendfile(filePath, { maxAge: exports.maxAge }); }); //serve timeslider.html under /p/$padname/timeslider args.app.get('/p/:pad/timeslider', function(req, res, next) { - var filePath = path.normalize(__dirname + "/../static/timeslider.html"); + var filePath = path.normalize(__dirname + "/../../../static/timeslider.html"); res.sendfile(filePath, { maxAge: exports.maxAge }); }); diff --git a/node/static.js b/node/hooks/express/static.js similarity index 82% rename from node/static.js rename to node/hooks/express/static.js index a81227a4..99f6eeff 100644 --- a/node/static.js +++ b/node/hooks/express/static.js @@ -1,5 +1,5 @@ var path = require('path'); -var minify = require('./utils/Minify'); +var minify = require('../../utils/Minify'); exports.expressCreateServer = function (hook_name, args, cb) { //serve static files @@ -10,7 +10,7 @@ exports.expressCreateServer = function (hook_name, args, cb) { }); args.app.get('/static/*', function(req, res) { - var filePath = path.normalize(__dirname + "/.." + + var filePath = path.normalize(__dirname + "/../../.." + req.url.replace(/\.\./g, '').split("?")[0]); res.sendfile(filePath, { maxAge: exports.maxAge }); }); diff --git a/node/webaccess.js b/node/hooks/express/webaccess.js similarity index 96% rename from node/webaccess.js rename to node/hooks/express/webaccess.js index 05c398a0..8e9f967a 100644 --- a/node/webaccess.js +++ b/node/hooks/express/webaccess.js @@ -1,7 +1,7 @@ -var settings = require('./utils/Settings'); var express = require('express'); var log4js = require('log4js'); var httpLogger = log4js.getLogger("http"); +var settings = require('../../utils/Settings'); //checks for basic http auth diff --git a/pluginomatic.json b/pluginomatic.json index e37d43a4..0c777c47 100644 --- a/pluginomatic.json +++ b/pluginomatic.json @@ -1,15 +1,15 @@ { "parts": [ - { "name": "static", "hooks": { "expressCreateServer": "../static:expressCreateServer" } }, - { "name": "specialpages", "hooks": { "expressCreateServer": "../specialpages:expressCreateServer" } }, - { "name": "padurlsanitize", "hooks": { "expressCreateServer": "../padurlsanitize:expressCreateServer" } }, - { "name": "minified", "hooks": { "expressCreateServer": "../minified:expressCreateServer" } }, - { "name": "padreadonly", "hooks": { "expressCreateServer": "../padreadonly:expressCreateServer" } }, - { "name": "webaccess", "hooks": { "expressConfigure": "../webaccess:expressConfigure" } }, - { "name": "apicalls", "hooks": { "expressCreateServer": "../apicalls:expressCreateServer" } }, - { "name": "importexport", "hooks": { "expressCreateServer": "../importexport:expressCreateServer" } }, - { "name": "errorhandling", "hooks": { "expressCreateServer": "../errorhandling:expressCreateServer" } }, - { "name": "socketio", "hooks": { "expressCreateServer": "../socketio:expressCreateServer" } } + { "name": "static", "hooks": { "expressCreateServer": "../hooks/express/static:expressCreateServer" } }, + { "name": "specialpages", "hooks": { "expressCreateServer": "../hooks/express/specialpages:expressCreateServer" } }, + { "name": "padurlsanitize", "hooks": { "expressCreateServer": "../hooks/express/padurlsanitize:expressCreateServer" } }, + { "name": "minified", "hooks": { "expressCreateServer": "../hooks/express/minified:expressCreateServer" } }, + { "name": "padreadonly", "hooks": { "expressCreateServer": "../hooks/express/padreadonly:expressCreateServer" } }, + { "name": "webaccess", "hooks": { "expressConfigure": "../hooks/express/webaccess:expressConfigure" } }, + { "name": "apicalls", "hooks": { "expressCreateServer": "../hooks/express/apicalls:expressCreateServer" } }, + { "name": "importexport", "hooks": { "expressCreateServer": "../hooks/express/importexport:expressCreateServer" } }, + { "name": "errorhandling", "hooks": { "expressCreateServer": "../hooks/express/errorhandling:expressCreateServer" } }, + { "name": "socketio", "hooks": { "expressCreateServer": "../hooks/express/socketio:expressCreateServer" } } ] }