diff --git a/public/src/widgets.js b/public/src/widgets.js index 863ce62be0..f06ec5fcc6 100644 --- a/public/src/widgets.js +++ b/public/src/widgets.js @@ -13,7 +13,7 @@ }; ajaxify.widgets.render = function(tpl_url, url, callback) { - var widgetLocations = [], numLocations; + var widgetLocations = ['sidebar', 'footer'], numLocations; $('#content [widget-area]').each(function() { widgetLocations.push($(this).attr('widget-area')); @@ -28,6 +28,17 @@ function renderWidgets(location) { var area = $('#content [widget-area="' + location + '"]'); + if (!area.length && window.location.pathname.indexOf('/admin') === -1) { + if (location === 'footer') { + $('#content').append($('
')); + } else if (location === 'sidebar') { + $('#content > *').wrapAll($('
')); + $('#content').append($('
')); + } + + area = $('#content [widget-area="' + location + '"]'); + } + socket.emit('widgets.render', {template: tpl_url + '.tpl', url: url, location: location}, function(err, renderedWidgets) { var html = ''; diff --git a/src/controllers/admin.js b/src/controllers/admin.js index 97f6efdc42..d940e06534 100644 --- a/src/controllers/admin.js +++ b/src/controllers/admin.js @@ -109,7 +109,12 @@ adminController.logger.get = function(req, res, next) { adminController.themes.get = function(req, res, next) { async.parallel({ areas: function(next) { - plugins.fireHook('filter:widgets.getAreas', [], next); + var defaultAreas = [ + { name: 'Global Sidebar', template: 'global', location: 'sidebar' }, + { name: 'Global Footer', template: 'global', location: 'footer' }, + ]; + + plugins.fireHook('filter:widgets.getAreas', defaultAreas, next); }, widgets: function(next) { plugins.fireHook('filter:widgets.getWidgets', [], next); diff --git a/src/widgets.js b/src/widgets.js index 62e1b55309..e1ca3b504c 100644 --- a/src/widgets.js +++ b/src/widgets.js @@ -18,7 +18,16 @@ var async = require('async'), var rendered = []; - Widgets.getArea(area.template, area.location, function(err, widgets) { + async.parallel({ + global: function(next) { + Widgets.getArea('global', area.location, next); + }, + local: function(next) { + Widgets.getArea(area.template, area.location, next); + } + }, function(err, data) { + var widgets = data.global.concat(data.local); + async.eachSeries(widgets, function(widget, next) { plugins.fireHook('filter:widget.render:' + widget.widget, { uid: uid,