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() {
socket.emit('admin.email.test', function(err) {
app.alert({
alert_id: 'test_email_sent',
type: !err ? 'info' : 'danger',
title: 'Test Email Sent',
message: err ? err.message : '',
timeout: 2500
if (err) {
return app.alertError(err.message);
}
app.alertSuccess('Test Email Sent');
});
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') {

@ -10,10 +10,36 @@ var path = require('path'),
topics = require('./topics'),
privileges = require('./privileges'),
meta = require('./meta'),
utils = require('../public/src/utils'),
sitemap = {
obj: undefined,
getStaticUrls: function(callback) {
utils = require('../public/src/utils');
var sitemap = {};
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, [{
url: '',
changefreq: 'weekly',
@ -27,8 +53,9 @@ var path = require('path'),
changefreq: 'daily',
priority: '0.4'
}]);
},
getDynamicUrls: function(callback) {
};
sitemap.getDynamicUrls = function(callback) {
var returnUrls = [];
async.parallel({
@ -91,23 +118,13 @@ var path = require('path'),
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();
}
};
};
module.exports = sitemap;

@ -175,6 +175,11 @@ SocketAdmin.settings.set = function(socket, data, 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) {
if (plugins.hasListeners('action:email.send')) {
emailer.send('test', socket.uid, {

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

@ -26,8 +26,12 @@
</label>
</div>
<div class="form-group">
<label>Number of Topic to Display in Sitemap</label>
<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>
</div>

Loading…
Cancel
Save