Node.js based forum software built for the modern web
closes #1428
psychobunnyc6183f1a82f6
diff --git a/public/src/ajaxify.js b/public/src/ajaxify.jsindex 0d3e126d9d..a649a243f0 100644--- a/public/src/ajaxify.js+++ b/public/src/ajaxify.js@@ -93,25 +93,25 @@ var ajaxify = ajaxify || {};templates.parse(tpl_url, data, function(template) {translator.translate(template, function(translatedTemplate) {$('#content').html(translatedTemplate);- ajaxify.widgets.render(tpl_url);+ ajaxify.widgets.render(tpl_url, function() {+ if (typeof callback === 'function') {+ callback();+ }- ajaxify.variables.parse();-- $(window).trigger('action:ajaxify.contentLoaded', {url: url});+ app.processPage();- ajaxify.loadScript(tpl_url);+ $('#content, #footer').stop(true, true).removeClass('ajaxifying');+ ajaxify.initialLoad = false;- if (typeof callback === 'function') {- callback();- }+ app.refreshTitle(url);+ $(window).trigger('action:ajaxify.end', {url: url});+ });- app.processPage();+ ajaxify.variables.parse();- $('#content, #footer').stop(true, true).removeClass('ajaxifying');- ajaxify.initialLoad = false;+ $(window).trigger('action:ajaxify.contentLoaded', {url: url});- app.refreshTitle(url);- $(window).trigger('action:ajaxify.end', {url: url});+ ajaxify.loadScript(tpl_url);});});});diff --git a/public/src/widgets.js b/public/src/widgets.jsindex 5a5333a96f..edc4f2bc7e 100644--- a/public/src/widgets.js+++ b/public/src/widgets.js@@ -33,10 +33,7 @@function renderWidgets(location) {var area = $('#content [widget-area="' + location + '"]');- socket.emit('widgets.render', {template: tpl_url + '.tpl', location: location}, function(err, renderedWidgets) {- if (err) {- return;- }+ $.get(RELATIVE_PATH + '/api/widgets/render/' + tpl_url + '/' + location, function(renderedWidgets) {var html = '';for (var i=0; i<renderedWidgets.length; ++i) {diff --git a/src/controllers/api.js b/src/controllers/api.jsindex 5fc9997a39..f698a348ea 100644--- a/src/controllers/api.js+++ b/src/controllers/api.js@@ -3,7 +3,8 @@var pkg = require('./../../package.json'),meta = require('./../meta'),user = require('./../user'),- plugins = require('./../plugins');+ plugins = require('./../plugins'),+ widgets = require('../widgets');var apiController = {};@@ -77,4 +78,16 @@ apiController.getConfig = function(req, res, next) {};+apiController.renderWidgets = function(req, res, next) {+ var uid = req.user ? req.user.uid : 0,+ area = {+ template: req.params.template + '.tpl',+ location: req.params.location+ };++ widgets.render(uid, area, function(err, data) {+ res.json(200, data);+ });+};+module.exports = apiController;diff --git a/src/routes/api.js b/src/routes/api.jsindex 9af798e95b..ea78f251dc 100644--- a/src/routes/api.js+++ b/src/routes/api.js@@ -184,6 +184,7 @@ module.exports = function(app, middleware, controllers) {app.use('/api', router);router.get('/config', controllers.api.getConfig);+ router.get('/widgets/render/:template/:location', controllers.api.renderWidgets);router.get('/user/uid/:uid', middleware.checkGlobalPrivacySettings, controllers.accounts.getUserByUID);router.get('/get_templates_listing', getTemplatesListing);diff --git a/src/widgets.js b/src/widgets.jsindex bc1910a95f..c52bb9298c 100644--- a/src/widgets.js+++ b/src/widgets.js@@ -9,7 +9,6 @@ var async = require('async'),(function(Widgets) {-Widgets.render = function(uid, area, callback) {if (!area.location || !area.template) {callback({@@ -19,6 +18,7 @@ var async = require('async'),var rendered = [];+async.parallel({global: function(next) {Widgets.getArea('global', area.location, next);