mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
closes #1428
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
app.processPage();
|
||||
|
||||
$('#content, #footer').stop(true, true).removeClass('ajaxifying');
|
||||
ajaxify.initialLoad = false;
|
||||
|
||||
app.refreshTitle(url);
|
||||
$(window).trigger('action:ajaxify.end', {url: url});
|
||||
});
|
||||
|
||||
ajaxify.variables.parse();
|
||||
|
||||
$(window).trigger('action:ajaxify.contentLoaded', {url: url});
|
||||
|
||||
ajaxify.loadScript(tpl_url);
|
||||
|
||||
if (typeof callback === 'function') {
|
||||
callback();
|
||||
}
|
||||
|
||||
app.processPage();
|
||||
|
||||
$('#content, #footer').stop(true, true).removeClass('ajaxifying');
|
||||
ajaxify.initialLoad = false;
|
||||
|
||||
app.refreshTitle(url);
|
||||
$(window).trigger('action:ajaxify.end', {url: url});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user