mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 20:16:04 +01:00
closes #1428
This commit is contained in:
@@ -93,14 +93,7 @@ var ajaxify = ajaxify || {};
|
|||||||
templates.parse(tpl_url, data, function(template) {
|
templates.parse(tpl_url, data, function(template) {
|
||||||
translator.translate(template, function(translatedTemplate) {
|
translator.translate(template, function(translatedTemplate) {
|
||||||
$('#content').html(translatedTemplate);
|
$('#content').html(translatedTemplate);
|
||||||
ajaxify.widgets.render(tpl_url);
|
ajaxify.widgets.render(tpl_url, function() {
|
||||||
|
|
||||||
ajaxify.variables.parse();
|
|
||||||
|
|
||||||
$(window).trigger('action:ajaxify.contentLoaded', {url: url});
|
|
||||||
|
|
||||||
ajaxify.loadScript(tpl_url);
|
|
||||||
|
|
||||||
if (typeof callback === 'function') {
|
if (typeof callback === 'function') {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
@@ -113,6 +106,13 @@ var ajaxify = ajaxify || {};
|
|||||||
app.refreshTitle(url);
|
app.refreshTitle(url);
|
||||||
$(window).trigger('action:ajaxify.end', {url: url});
|
$(window).trigger('action:ajaxify.end', {url: url});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ajaxify.variables.parse();
|
||||||
|
|
||||||
|
$(window).trigger('action:ajaxify.contentLoaded', {url: url});
|
||||||
|
|
||||||
|
ajaxify.loadScript(tpl_url);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -33,10 +33,7 @@
|
|||||||
function renderWidgets(location) {
|
function renderWidgets(location) {
|
||||||
var area = $('#content [widget-area="' + location + '"]');
|
var area = $('#content [widget-area="' + location + '"]');
|
||||||
|
|
||||||
socket.emit('widgets.render', {template: tpl_url + '.tpl', location: location}, function(err, renderedWidgets) {
|
$.get(RELATIVE_PATH + '/api/widgets/render/' + tpl_url + '/' + location, function(renderedWidgets) {
|
||||||
if (err) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var html = '';
|
var html = '';
|
||||||
|
|
||||||
for (var i=0; i<renderedWidgets.length; ++i) {
|
for (var i=0; i<renderedWidgets.length; ++i) {
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
var pkg = require('./../../package.json'),
|
var pkg = require('./../../package.json'),
|
||||||
meta = require('./../meta'),
|
meta = require('./../meta'),
|
||||||
user = require('./../user'),
|
user = require('./../user'),
|
||||||
plugins = require('./../plugins');
|
plugins = require('./../plugins'),
|
||||||
|
widgets = require('../widgets');
|
||||||
|
|
||||||
var apiController = {};
|
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;
|
module.exports = apiController;
|
||||||
|
|||||||
@@ -184,6 +184,7 @@ module.exports = function(app, middleware, controllers) {
|
|||||||
app.use('/api', router);
|
app.use('/api', router);
|
||||||
|
|
||||||
router.get('/config', controllers.api.getConfig);
|
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('/user/uid/:uid', middleware.checkGlobalPrivacySettings, controllers.accounts.getUserByUID);
|
||||||
router.get('/get_templates_listing', getTemplatesListing);
|
router.get('/get_templates_listing', getTemplatesListing);
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ var async = require('async'),
|
|||||||
|
|
||||||
|
|
||||||
(function(Widgets) {
|
(function(Widgets) {
|
||||||
|
|
||||||
Widgets.render = function(uid, area, callback) {
|
Widgets.render = function(uid, area, callback) {
|
||||||
if (!area.location || !area.template) {
|
if (!area.location || !area.template) {
|
||||||
callback({
|
callback({
|
||||||
@@ -19,6 +18,7 @@ var async = require('async'),
|
|||||||
|
|
||||||
var rendered = [];
|
var rendered = [];
|
||||||
|
|
||||||
|
|
||||||
async.parallel({
|
async.parallel({
|
||||||
global: function(next) {
|
global: function(next) {
|
||||||
Widgets.getArea('global', area.location, next);
|
Widgets.getArea('global', area.location, next);
|
||||||
|
|||||||
Reference in New Issue
Block a user