Skip to content

Node.js based forum software built for the modern web

robots + sitemap; some clean up

psychobunny00df660fa555
diff --git a/src/controllers/index.js b/src/controllers/index.js
index fd7ba63ea6..9c5ea79d06 100644
--- a/src/controllers/index.js
+++ b/src/controllers/index.js
@@ -1,11 +1,12 @@
var topicsController = require('./topics'),
categoriesController = require('./categories'),
async = require('async'),
- auth = require('../routes/authentication'),
- meta = require('../meta'),
- plugins = require('../plugins'),
- categories = require('../categories'),
- categoryTools = require('../categoryTools');
+ nconf = require('nconf'),
+ auth = require('./../routes/authentication'),
+ meta = require('./../meta'),
+ plugins = require('./../plugins'),
+ categories = require('./../categories'),
+ categoryTools = require('./../categoryTools');
@@ -164,4 +165,25 @@ Controllers.confirmEmail = function(req, res, next) {
});
};
+Controllers.sitemap = function(req, res, next) {
+ var sitemap = require('./../sitemap.js');
+
+ sitemap.render(function(xml) {
+ res.header('Content-Type', 'application/xml');
+ res.send(xml);
+ });
+};
+
+Controllers.robots = function (req, res) {
+ res.set('Content-Type', 'text/plain');
+
+ if (meta.config["robots.txt"]) {
+ res.send(meta.config["robots.txt"]);
+ } else {
+ res.send("User-agent: *\n" +
+ "Disallow: /admin/\n" +
+ "Sitemap: " + nconf.get('url') + "/sitemap.xml");
+ }
+};
+
module.exports = Controllers;
\ No newline at end of file
diff --git a/src/webserver.js b/src/webserver.js
index a0c6dd97fe..29ab11efa5 100644
--- a/src/webserver.js
+++ b/src/webserver.js
@@ -629,6 +629,10 @@ process.on('uncaughtException', function(err) {
app.get('/confirm/:code', app.buildHeader, controllers.confirmEmail);
app.get('/api/confirm/:code', app.prepareAPI, controllers.confirmEmail);
+ app.get('/sitemap.xml', controllers.sitemap);
+
+ app.get('/robots.txt', controllers.robots);
+
/* Topics */
app.get('/topic/:topic_id/:slug?', app.buildHeader, controllers.topics.get);
app.get('/api/topic/:topic_id/:slug?', app.prepareAPI, controllers.topics.get);
@@ -649,56 +653,7 @@ process.on('uncaughtException', function(err) {
app.get('/category/:category_id/:slug?', app.buildHeader, controllers.categories.get);
app.get('/api/category/:category_id/:slug?', app.prepareAPI, controllers.categories.get);
- app.get('/confirm/:code', function (req, res) {
- app.build_header({
- req: req,
- res: res
- }, function (err, header) {
- res.send(header + app.create_route('confirm/' + req.params.code) + templates.footer);
- });
- });
-
- app.get('/sitemap.xml', function (req, res) {
- var sitemap = require('./sitemap.js');
-
- sitemap.render(function (xml) {
- res.header('Content-Type', 'application/xml');
- res.send( xml );
- });
- });
-
- app.get('/robots.txt', function (req, res) {
- res.set('Content-Type', 'text/plain');
-
- if (meta.config["robots.txt"]) {
- res.send(meta.config["robots.txt"])
- } else {
- res.send("User-agent: *\n" +
- "Disallow: /admin/\n" +
- "Sitemap: " + nconf.get('url') + "/sitemap.xml");
- }
- });
-
- /*app.get('/recent/:term?', function (req, res) {
- // TODO consolidate with /recent route as well -> that can be combined into this area. See "Basic Routes" near top.
- app.build_header({
- req: req,
- res: res
- }, function (err, header) {
- res.send(header + app.create_route('recent/' + req.params.term, null, 'recent') + templates.footer);
- });
-
- });*/
-
- /*app.get('/popular/:term?', function (req, res) {
- app.build_header({
- req: req,
- res: res
- }, function (err, header) {
- res.send(header + app.create_route('popular/' + req.params.term, null, 'popular') + templates.footer);
- });
-
- });*/
+
app.get('/outgoing', function (req, res) {
if (!req.query.url) {