mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-30 18:46:01 +01:00
robots + sitemap; some clean up
This commit is contained in:
@@ -1,11 +1,12 @@
|
|||||||
var topicsController = require('./topics'),
|
var topicsController = require('./topics'),
|
||||||
categoriesController = require('./categories'),
|
categoriesController = require('./categories'),
|
||||||
async = require('async'),
|
async = require('async'),
|
||||||
auth = require('../routes/authentication'),
|
nconf = require('nconf'),
|
||||||
meta = require('../meta'),
|
auth = require('./../routes/authentication'),
|
||||||
plugins = require('../plugins'),
|
meta = require('./../meta'),
|
||||||
categories = require('../categories'),
|
plugins = require('./../plugins'),
|
||||||
categoryTools = require('../categoryTools');
|
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;
|
module.exports = Controllers;
|
||||||
@@ -629,6 +629,10 @@ process.on('uncaughtException', function(err) {
|
|||||||
app.get('/confirm/:code', app.buildHeader, controllers.confirmEmail);
|
app.get('/confirm/:code', app.buildHeader, controllers.confirmEmail);
|
||||||
app.get('/api/confirm/:code', app.prepareAPI, controllers.confirmEmail);
|
app.get('/api/confirm/:code', app.prepareAPI, controllers.confirmEmail);
|
||||||
|
|
||||||
|
app.get('/sitemap.xml', controllers.sitemap);
|
||||||
|
|
||||||
|
app.get('/robots.txt', controllers.robots);
|
||||||
|
|
||||||
/* Topics */
|
/* Topics */
|
||||||
app.get('/topic/:topic_id/:slug?', app.buildHeader, controllers.topics.get);
|
app.get('/topic/:topic_id/:slug?', app.buildHeader, controllers.topics.get);
|
||||||
app.get('/api/topic/:topic_id/:slug?', app.prepareAPI, 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('/category/:category_id/:slug?', app.buildHeader, controllers.categories.get);
|
||||||
app.get('/api/category/:category_id/:slug?', app.prepareAPI, 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) {
|
app.get('/outgoing', function (req, res) {
|
||||||
if (!req.query.url) {
|
if (!req.query.url) {
|
||||||
|
|||||||
Reference in New Issue
Block a user