Merge remote-tracking branch 'origin/master' into 0.7.0

v1.18.x
barisusakli 10 years ago
commit f988959989

@ -86,14 +86,19 @@ define('admin/settings', ['uploader', 'sounds'], function(uploader, sounds) {
$('button[data-action="email.test"]').off('click').on('click', function() { $('button[data-action="email.test"]').off('click').on('click', function() {
socket.emit('admin.email.test', function(err) { socket.emit('admin.email.test', function(err) {
app.alert({ if (err) {
alert_id: 'test_email_sent', return app.alertError(err.message);
type: !err ? 'info' : 'danger', }
title: 'Test Email Sent', app.alertSuccess('Test Email Sent');
message: err ? err.message : '',
timeout: 2500
}); });
return false;
});
$('#clear-sitemap-cache').off('click').on('click', function() {
socket.emit('admin.settings.clearSitemapCache', function() {
app.alertSuccess('Sitemap Cache Cleared!');
}); });
return false;
}); });
if (typeof callback === 'function') { if (typeof callback === 'function') {

@ -10,10 +10,36 @@ var path = require('path'),
topics = require('./topics'), topics = require('./topics'),
privileges = require('./privileges'), privileges = require('./privileges'),
meta = require('./meta'), meta = require('./meta'),
utils = require('../public/src/utils'), utils = require('../public/src/utils');
sitemap = {
obj: undefined, var sitemap = {};
getStaticUrls: function(callback) {
sitemap.render = function(callback) {
if (sitemap.obj && sitemap.obj.cache.length) {
return sitemap.obj.toXML(callback);
}
async.parallel([
sitemap.getStaticUrls,
sitemap.getDynamicUrls
], function(err, urls) {
if (err) {
return callback(err);
}
urls = urls[0].concat(urls[1]);
sitemap.obj = sm.createSitemap({
hostname: nconf.get('url'),
cacheTime: 1000 * 60 * 60, // Cached for 1 hour
urls: urls
});
sitemap.obj.toXML(callback);
});
};
sitemap.getStaticUrls = function(callback) {
callback(null, [{ callback(null, [{
url: '', url: '',
changefreq: 'weekly', changefreq: 'weekly',
@ -27,8 +53,9 @@ var path = require('path'),
changefreq: 'daily', changefreq: 'daily',
priority: '0.4' priority: '0.4'
}]); }]);
}, };
getDynamicUrls: function(callback) {
sitemap.getDynamicUrls = function(callback) {
var returnUrls = []; var returnUrls = [];
async.parallel({ async.parallel({
@ -91,22 +118,12 @@ var path = require('path'),
callback(err, returnUrls); callback(err, returnUrls);
}); });
}, };
render: function(callback) {
if (sitemap.obj !== undefined && sitemap.obj.cache.length) {
return sitemap.obj.toXML(callback);
}
async.parallel([sitemap.getStaticUrls, sitemap.getDynamicUrls], function(err, urls) {
urls = urls[0].concat(urls[1]);
sitemap.obj = sm.createSitemap({
hostname: nconf.get('url'),
cacheTime: 1000 * 60 * 60, // Cached for 1 hour
urls: urls
});
sitemap.obj.toXML(callback); sitemap.clearCache = function() {
}); if (sitemap.obj) {
sitemap.obj.clearCache();
} }
}; };

@ -175,6 +175,11 @@ SocketAdmin.settings.set = function(socket, data, callback) {
meta.settings.set(data.hash, data.values, callback); meta.settings.set(data.hash, data.values, callback);
}; };
SocketAdmin.settings.clearSitemapCache = function(socket, data, callback) {
require('../sitemap').clearCache();
callback();
};
SocketAdmin.email.test = function(socket, data, callback) { SocketAdmin.email.test = function(socket, data, callback) {
if (plugins.hasListeners('action:email.send')) { if (plugins.hasListeners('action:email.send')) {
emailer.send('test', socket.uid, { emailer.send('test', socket.uid, {

@ -162,6 +162,7 @@ var async = require('async'),
}; };
User.setUserField = function(uid, field, value, callback) { User.setUserField = function(uid, field, value, callback) {
callback = callback || function() {};
db.setObjectField('user:' + uid, field, value, function(err) { db.setObjectField('user:' + uid, field, value, function(err) {
if (err) { if (err) {
return callback(err) return callback(err)
@ -172,6 +173,7 @@ var async = require('async'),
}; };
User.setUserFields = function(uid, data, callback) { User.setUserFields = function(uid, data, callback) {
callback = callback || function() {};
db.setObject('user:' + uid, data, function(err) { db.setObject('user:' + uid, data, function(err) {
if (err) { if (err) {
return callback(err); return callback(err);

@ -26,8 +26,12 @@
</label> </label>
</div> </div>
<div class="form-group">
<label>Number of Topic to Display in Sitemap</label> <label>Number of Topic to Display in Sitemap</label>
<input class="form-control" type="text" placeholder="" data-field="sitemapTopics" /> <input class="form-control" type="text" placeholder="" data-field="sitemapTopics" />
</div>
<button id="clear-sitemap-cache" class="btn btn-warning">Clear Sitemap Cache</button>
</form> </form>
</div> </div>

Loading…
Cancel
Save