moved sitemap to its own file

v1.18.x
barisusakli 9 years ago
parent a13bc64f40
commit 650f4d6ed5

@ -8,7 +8,6 @@ var winston = require('winston');
var meta = require('../meta');
var user = require('../user');
var plugins = require('../plugins');
var sitemap = require('../sitemap');
var helpers = require('./helpers');
var Controllers = {
@ -27,7 +26,8 @@ var Controllers = {
authentication: require('./authentication'),
api: require('./api'),
admin: require('./admin'),
globalMods: require('./globalmods')
globalMods: require('./globalmods'),
sitemap: require('./sitemap')
};
@ -251,65 +251,6 @@ Controllers.confirmEmail = function(req, res) {
});
};
Controllers.sitemap = {};
Controllers.sitemap.render = function(req, res, next) {
sitemap.render(function(err, tplData) {
if (err) {
return next(err);
}
Controllers.render('sitemap', tplData, function(err, xml) {
res.header('Content-Type', 'application/xml');
res.send(xml);
});
});
};
Controllers.sitemap.getPages = function(req, res, next) {
if (parseInt(meta.config['feeds:disableSitemap'], 10) === 1) {
return next();
}
sitemap.getPages(function(err, xml) {
if (err) {
return next(err);
}
res.header('Content-Type', 'application/xml');
res.send(xml);
});
};
Controllers.sitemap.getCategories = function(req, res, next) {
if (parseInt(meta.config['feeds:disableSitemap'], 10) === 1) {
return next();
}
sitemap.getCategories(function(err, xml) {
if (err) {
return next(err);
}
res.header('Content-Type', 'application/xml');
res.send(xml);
});
};
Controllers.sitemap.getTopicPage = function(req, res, next) {
if (parseInt(meta.config['feeds:disableSitemap'], 10) === 1) {
return next();
}
sitemap.getTopicPage(parseInt(req.params[0], 10), function(err, xml) {
if (err) {
return next(err);
} else if (!xml) {
return next();
}
res.header('Content-Type', 'application/xml');
res.send(xml);
});
};
Controllers.robots = function (req, res) {
res.set('Content-Type', 'text/plain');

@ -0,0 +1,68 @@
'use strict';
var sitemap = require('../sitemap');
var meta = require('../meta');
var sitemapController = {};
sitemapController.render = function(req, res, next) {
sitemap.render(function(err, tplData) {
if (err) {
return next(err);
}
var Controllers = require('./index');
Controllers.render('sitemap', tplData, function(err, xml) {
if (err) {
return next(err);
}
res.header('Content-Type', 'application/xml');
res.send(xml);
});
});
};
sitemapController.getPages = function(req, res, next) {
if (parseInt(meta.config['feeds:disableSitemap'], 10) === 1) {
return next();
}
sitemap.getPages(function(err, xml) {
if (err) {
return next(err);
}
res.header('Content-Type', 'application/xml');
res.send(xml);
});
};
sitemapController.getCategories = function(req, res, next) {
if (parseInt(meta.config['feeds:disableSitemap'], 10) === 1) {
return next();
}
sitemap.getCategories(function(err, xml) {
if (err) {
return next(err);
}
res.header('Content-Type', 'application/xml');
res.send(xml);
});
};
sitemapController.getTopicPage = function(req, res, next) {
if (parseInt(meta.config['feeds:disableSitemap'], 10) === 1) {
return next();
}
sitemap.getTopicPage(parseInt(req.params[0], 10), function(err, xml) {
if (err) {
return next(err);
} else if (!xml) {
return next();
}
res.header('Content-Type', 'application/xml');
res.send(xml);
});
};
module.exports = sitemapController;
Loading…
Cancel
Save