mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-06 12:31:33 +01:00
closes #5813
This commit is contained in:
@@ -291,8 +291,8 @@ Controllers.confirmEmail = function (req, res) {
|
||||
Controllers.robots = function (req, res) {
|
||||
res.set('Content-Type', 'text/plain');
|
||||
|
||||
if (meta.config['robots.txt']) {
|
||||
res.send(meta.config['robots.txt']);
|
||||
if (meta.config['robots:txt']) {
|
||||
res.send(meta.config['robots:txt']);
|
||||
} else {
|
||||
res.send('User-agent: *\n' +
|
||||
'Disallow: ' + nconf.get('relative_path') + '/admin/\n' +
|
||||
|
||||
35
src/upgrades/1.6.0/robots-config-change.js
Normal file
35
src/upgrades/1.6.0/robots-config-change.js
Normal file
@@ -0,0 +1,35 @@
|
||||
'use strict';
|
||||
|
||||
var async = require('async');
|
||||
var db = require('../../database');
|
||||
|
||||
module.exports = {
|
||||
name: 'Fix incorrect robots.txt schema',
|
||||
timestamp: Date.UTC(2017, 6, 10),
|
||||
method: function (callback) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
db.getObject('config', next);
|
||||
},
|
||||
function (config, next) {
|
||||
if (!config) {
|
||||
return callback();
|
||||
}
|
||||
// fix mongo nested data
|
||||
if (config.robots && config.robots.txt) {
|
||||
db.setObjectField('config', 'robots:txt', config.robots.txt, next);
|
||||
} else if (typeof config['robots.txt'] === 'string' && config['robots.txt']) {
|
||||
db.setObjectField('config', 'robots:txt', config['robots.txt'], next);
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
},
|
||||
function (next) {
|
||||
db.deleteObjectField('config', 'robots', next);
|
||||
},
|
||||
function (next) {
|
||||
db.deleteObjectField('config', 'robots.txt', next);
|
||||
},
|
||||
], callback);
|
||||
},
|
||||
};
|
||||
@@ -5,7 +5,7 @@
|
||||
<div class="col-sm-10 col-xs-12">
|
||||
<form>
|
||||
<strong>[[admin/settings/web-crawler:robots-txt]]</strong><br />
|
||||
<textarea class="form-control" data-field="robots.txt"></textarea>
|
||||
<textarea class="form-control" data-field="robots:txt"></textarea>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user