Moved all the hooks into a hooks directory

This commit is contained in:
Egil Moeller 2012-02-25 17:23:44 +01:00
parent 6754eed9b4
commit 7b42987407
11 changed files with 36 additions and 36 deletions

View File

@ -1,7 +1,7 @@
var log4js = require('log4js'); var log4js = require('log4js');
var apiLogger = log4js.getLogger("API"); var apiLogger = log4js.getLogger("API");
var apiHandler = require('./handler/APIHandler');
var formidable = require('formidable'); 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 //This is for making an api call, collecting all post information and passing it to the apiHandler
exports.apiCaller = function(req, res, fields) { exports.apiCaller = function(req, res, fields) {

View File

@ -1,5 +1,5 @@
var db = require('./db/DB');
var os = require("os"); var os = require("os");
var db = require('../../db/DB');
exports.onShutdown = false; exports.onShutdown = false;

View File

@ -1,7 +1,7 @@
var hasPadAccess = require("./padaccess"); var hasPadAccess = require("../../padaccess");
var settings = require('./utils/Settings'); var settings = require('../../utils/Settings');
var exportHandler = require('./handler/ExportHandler'); var exportHandler = require('../../handler/ExportHandler');
var importHandler = require('./handler/ImportHandler'); var importHandler = require('../../handler/ImportHandler');
exports.expressCreateServer = function (hook_name, args, cb) { exports.expressCreateServer = function (hook_name, args, cb) {
args.app.get('/p/:pad/:rev?/export/:type', function(req, res, next) { args.app.get('/p/:pad/:rev?/export/:type', function(req, res, next) {

View File

@ -1,4 +1,4 @@
var minify = require('./utils/Minify'); var minify = require('../../utils/Minify');
exports.expressCreateServer = function (hook_name, args, cb) { exports.expressCreateServer = function (hook_name, args, cb) {
//serve minified files //serve minified files

View File

@ -1,8 +1,8 @@
var async = require('async'); var async = require('async');
var readOnlyManager = require("./db/ReadOnlyManager");
var hasPadAccess = require("./padaccess");
var exporthtml = require("./utils/ExportHtml");
var ERR = require("async-stacktrace"); 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) { exports.expressCreateServer = function (hook_name, args, cb) {
//serve read only pad //serve read only pad

View File

@ -1,4 +1,4 @@
var padManager = require('./db/PadManager'); var padManager = require('../../db/PadManager');
exports.expressCreateServer = function (hook_name, args, cb) { exports.expressCreateServer = function (hook_name, args, cb) {
//redirects browser to the pad's sanitized url if needed. otherwise, renders the html //redirects browser to the pad's sanitized url if needed. otherwise, renders the html

View File

@ -1,11 +1,11 @@
var settings = require('./utils/Settings');
var socketio = require('socket.io');
var socketIORouter = require("./handler/SocketIORouter");
var log4js = require('log4js'); 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 padMessageHandler = require("../../handler/PadMessageHandler");
var timesliderMessageHandler = require("./handler/TimesliderMessageHandler"); var timesliderMessageHandler = require("../../handler/TimesliderMessageHandler");
exports.expressCreateServer = function (hook_name, args, cb) { exports.expressCreateServer = function (hook_name, args, cb) {

View File

@ -5,27 +5,27 @@ exports.expressCreateServer = function (hook_name, args, cb) {
//serve index.html under / //serve index.html under /
args.app.get('/', function(req, res) 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 }); res.sendfile(filePath, { maxAge: exports.maxAge });
}); });
//serve robots.txt //serve robots.txt
args.app.get('/robots.txt', function(req, res) 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 }); res.sendfile(filePath, { maxAge: exports.maxAge });
}); });
//serve favicon.ico //serve favicon.ico
args.app.get('/favicon.ico', function(req, res) 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) res.sendfile(filePath, { maxAge: exports.maxAge }, function(err)
{ {
//there is no custom favicon, send the default favicon //there is no custom favicon, send the default favicon
if(err) if(err)
{ {
filePath = path.normalize(__dirname + "/../static/favicon.ico"); filePath = path.normalize(__dirname + "/../../../static/favicon.ico");
res.sendfile(filePath, { maxAge: exports.maxAge }); res.sendfile(filePath, { maxAge: exports.maxAge });
} }
}); });
@ -34,14 +34,14 @@ exports.expressCreateServer = function (hook_name, args, cb) {
//serve pad.html under /p //serve pad.html under /p
args.app.get('/p/:pad', function(req, res, next) 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 }); res.sendfile(filePath, { maxAge: exports.maxAge });
}); });
//serve timeslider.html under /p/$padname/timeslider //serve timeslider.html under /p/$padname/timeslider
args.app.get('/p/:pad/timeslider', function(req, res, next) 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 }); res.sendfile(filePath, { maxAge: exports.maxAge });
}); });

View File

@ -1,5 +1,5 @@
var path = require('path'); var path = require('path');
var minify = require('./utils/Minify'); var minify = require('../../utils/Minify');
exports.expressCreateServer = function (hook_name, args, cb) { exports.expressCreateServer = function (hook_name, args, cb) {
//serve static files //serve static files
@ -10,7 +10,7 @@ exports.expressCreateServer = function (hook_name, args, cb) {
}); });
args.app.get('/static/*', function(req, res) args.app.get('/static/*', function(req, res)
{ {
var filePath = path.normalize(__dirname + "/.." + var filePath = path.normalize(__dirname + "/../../.." +
req.url.replace(/\.\./g, '').split("?")[0]); req.url.replace(/\.\./g, '').split("?")[0]);
res.sendfile(filePath, { maxAge: exports.maxAge }); res.sendfile(filePath, { maxAge: exports.maxAge });
}); });

View File

@ -1,7 +1,7 @@
var settings = require('./utils/Settings');
var express = require('express'); var express = require('express');
var log4js = require('log4js'); var log4js = require('log4js');
var httpLogger = log4js.getLogger("http"); var httpLogger = log4js.getLogger("http");
var settings = require('../../utils/Settings');
//checks for basic http auth //checks for basic http auth

View File

@ -1,15 +1,15 @@
{ {
"parts": [ "parts": [
{ "name": "static", "hooks": { "expressCreateServer": "../static:expressCreateServer" } }, { "name": "static", "hooks": { "expressCreateServer": "../hooks/express/static:expressCreateServer" } },
{ "name": "specialpages", "hooks": { "expressCreateServer": "../specialpages:expressCreateServer" } }, { "name": "specialpages", "hooks": { "expressCreateServer": "../hooks/express/specialpages:expressCreateServer" } },
{ "name": "padurlsanitize", "hooks": { "expressCreateServer": "../padurlsanitize:expressCreateServer" } }, { "name": "padurlsanitize", "hooks": { "expressCreateServer": "../hooks/express/padurlsanitize:expressCreateServer" } },
{ "name": "minified", "hooks": { "expressCreateServer": "../minified:expressCreateServer" } }, { "name": "minified", "hooks": { "expressCreateServer": "../hooks/express/minified:expressCreateServer" } },
{ "name": "padreadonly", "hooks": { "expressCreateServer": "../padreadonly:expressCreateServer" } }, { "name": "padreadonly", "hooks": { "expressCreateServer": "../hooks/express/padreadonly:expressCreateServer" } },
{ "name": "webaccess", "hooks": { "expressConfigure": "../webaccess:expressConfigure" } }, { "name": "webaccess", "hooks": { "expressConfigure": "../hooks/express/webaccess:expressConfigure" } },
{ "name": "apicalls", "hooks": { "expressCreateServer": "../apicalls:expressCreateServer" } }, { "name": "apicalls", "hooks": { "expressCreateServer": "../hooks/express/apicalls:expressCreateServer" } },
{ "name": "importexport", "hooks": { "expressCreateServer": "../importexport:expressCreateServer" } }, { "name": "importexport", "hooks": { "expressCreateServer": "../hooks/express/importexport:expressCreateServer" } },
{ "name": "errorhandling", "hooks": { "expressCreateServer": "../errorhandling:expressCreateServer" } }, { "name": "errorhandling", "hooks": { "expressCreateServer": "../hooks/express/errorhandling:expressCreateServer" } },
{ "name": "socketio", "hooks": { "expressCreateServer": "../socketio:expressCreateServer" } } { "name": "socketio", "hooks": { "expressCreateServer": "../hooks/express/socketio:expressCreateServer" } }
] ]
} }