v1.18.x
Baris Usakli 8 years ago
parent 4e7447c9d6
commit e036e26238

@ -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' +

@ -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>

Loading…
Cancel
Save