From f01cb88c5710b96d2d54a4ebf22bcf180686d41d Mon Sep 17 00:00:00 2001 From: psychobunny Date: Mon, 31 Mar 2014 13:03:22 -0400 Subject: [PATCH] deprecated: plugins/fireHook, filter:server.create_routes, filter:admin.create_routes --- public/src/ajaxify.js | 13 ---- src/routes/plugins.js | 145 ------------------------------------------ 2 files changed, 158 deletions(-) diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index 9cfc90e8f3..00a2350aae 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -67,19 +67,6 @@ var ajaxify = ajaxify || {}; window.history[!quiet ? 'pushState' : 'replaceState']({ url: url + hash }, url, RELATIVE_PATH + '/' + url + hash); - - $.ajax(RELATIVE_PATH + '/plugins/fireHook', { - type: 'PUT', - data: { - _csrf: $('#csrf_token').val(), - hook: 'page.load', - args: { - template: tpl_url, - url: url, - uid: app.uid - } - } - }); } translator.load(tpl_url); diff --git a/src/routes/plugins.js b/src/routes/plugins.js index 9764c5479d..2108ee83fa 100644 --- a/src/routes/plugins.js +++ b/src/routes/plugins.js @@ -11,150 +11,8 @@ var _ = require('underscore'), plugins = require('../plugins'), pluginRoutes = []; -/* -* TO BE DEPRECATED post 0.4x -*/ -function setupPluginRoutes(app) { - var custom_routes = { - 'routes': [], - 'api': [], - 'templates': [] - }; - - plugins.ready(function() { - plugins.fireHook('filter:server.create_routes', custom_routes, function(err, custom_routes) { - winston.warn('[plugins] filter:server.create_routes is deprecated and will maintain limited functionality until 0.4x'); - var route, - routes = custom_routes.routes; - - pluginRoutes = custom_routes; - - for (route in routes) { - if (routes.hasOwnProperty(route)) { - (function(route) { - app[routes[route].method || 'get'](routes[route].route, function(req, res) { - routes[route].options(req, res, function(options) { - async.parallel([ - function(next) { - app.render('header', {}, next); - }, - function(next) { - app.render('footer', {}, next); - } - ], function(err, data) { - res.send(data[0] + options.content + data[1]); - }); - }); - }); - }(route)); - } - } - - var apiRoutes = custom_routes.api; - for (route in apiRoutes) { - if (apiRoutes.hasOwnProperty(route)) { - (function(route) { - app[apiRoutes[route].method || 'get']('/api' + apiRoutes[route].route, function(req, res) { - apiRoutes[route].callback(req, res, function(data) { - res.json(data); - }); - }); - }(route)); - } - } - - var templateRoutes = custom_routes.templates; - for (route in templateRoutes) { - if (templateRoutes.hasOwnProperty(route)) { - (function(route) { - app.get('/templates/' + templateRoutes[route].template, function(req, res) { - res.send(templateRoutes[route].content); - }); - }(route)); - } - } - }); - }); -} - -/* -* TO BE DEPRECATED post 0.4x -*/ -function setupPluginAdminRoutes(app) { - var custom_routes = { - 'routes': [], - 'api': [] - }; - - plugins.ready(function() { - plugins.fireHook('filter:admin.create_routes', custom_routes, function(err, custom_routes) { - winston.warn('[plugins] filter:admin.create_routes is deprecated and will maintain limited functionality until 0.4x'); - var route, routes = custom_routes.routes; - - for (route in routes) { - if (routes.hasOwnProperty(route)) { - (function(route) { - app[routes[route].method || 'get']('/admin' + routes[route].route, function(req, res) { - routes[route].options(req, res, function(options) { - async.parallel([ - function(next) { - app.render('admin/header', {}, next); - }, - function(next) { - app.render('admin/footer', {}, next); - } - ], function(err, data) { - res.send(data[0] + options.content + data[1]); - }); - }); - }); - }(route)); - } - } - - var apiRoutes = custom_routes.api; - for (route in apiRoutes) { - if (apiRoutes.hasOwnProperty(route)) { - (function(route) { - app[apiRoutes[route].method || 'get']('/api/admin' + apiRoutes[route].route, function(req, res) { - apiRoutes[route].callback(req, res, function(data) { - res.json(data); - }); - }); - }(route)); - } - } - }); - }); -} module.exports = function(app, middleware, controllers) { - /** - * GET/PUT /plugins/fireHook to be deprecated after 0.4.x - * - */ - app.get('/plugins/fireHook', function(req, res) { - // GET = filter - plugins.fireHook('filter:' + req.query.hook, req.query.args, function(err, returnData) { - if (typeof returnData === 'object') { - res.json(200, returnData); - } else { - res.send(200, validator.escape(returnData)); - } - }); - }); - - app.put('/plugins/fireHook', function(req, res) { - // PUT = action - var hook = 'action:' + req.body.hook; - if (plugins.hasListeners(hook)) { - // Hook executes - plugins.fireHook(hook, req.body.args); - } - - res.send(200); - }); - // Static Assets app.get('/plugins/:id/*', function(req, res) { var relPath = req._parsedUrl.pathname.replace(nconf.get('relative_path') + '/plugins/', ''), @@ -193,7 +51,4 @@ module.exports = function(app, middleware, controllers) { res.redirect('/404'); } }); - - setupPluginRoutes(app); - setupPluginAdminRoutes(app); }; \ No newline at end of file