|
|
@ -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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|