карта сайта
This commit is contained in:
parent
6d032ff34d
commit
4a4c37e3a5
25
index.js
25
index.js
@ -7,6 +7,7 @@ var express = require('express');
|
|||||||
var app = express();
|
var app = express();
|
||||||
var server = require('http').Server(app);
|
var server = require('http').Server(app);
|
||||||
var io = require('socket.io')(server);
|
var io = require('socket.io')(server);
|
||||||
|
var sm = require('sitemap');
|
||||||
|
|
||||||
const torrentTypeDetect = require('./lib/content');
|
const torrentTypeDetect = require('./lib/content');
|
||||||
|
|
||||||
@ -88,12 +89,34 @@ app.get('/', function(req, res)
|
|||||||
|
|
||||||
app.use(express.static('build'));
|
app.use(express.static('build'));
|
||||||
|
|
||||||
|
app.get('/sitemap.xml', function(req, res) {
|
||||||
|
socketMysql.query('SELECT hash FROM `torrents`', function (error, rows, fields) {
|
||||||
|
if(!rows) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let sitemap = sm.createSitemap ({
|
||||||
|
hostname: 'http://ratsontheboat.org',
|
||||||
|
cacheTime: 600000
|
||||||
|
});
|
||||||
|
sitemap.add({url: '/'});
|
||||||
|
for(let i = 0; i < rows.length; i++)
|
||||||
|
sitemap.add({url: '/torrent/' + rows[i].hash});
|
||||||
|
|
||||||
|
sitemap.toXML( function (err, xml) {
|
||||||
|
if (err) {
|
||||||
|
return res.status(500).end();
|
||||||
|
}
|
||||||
|
res.header('Content-Type', 'application/xml');
|
||||||
|
res.send( xml );
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
app.get('*', function(req, res)
|
app.get('*', function(req, res)
|
||||||
{
|
{
|
||||||
res.sendfile(__dirname + '/build/index.html');
|
res.sendfile(__dirname + '/build/index.html');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// start
|
// start
|
||||||
|
|
||||||
io.on('connection', function(socket)
|
io.on('connection', function(socket)
|
||||||
|
@ -57,6 +57,7 @@
|
|||||||
"react": "^15.4.1",
|
"react": "^15.4.1",
|
||||||
"react-dom": "^15.4.1",
|
"react-dom": "^15.4.1",
|
||||||
"react-tap-event-plugin": "^2.0.1",
|
"react-tap-event-plugin": "^2.0.1",
|
||||||
|
"sitemap": "^1.9.0",
|
||||||
"socket.io": "^1.7.2"
|
"socket.io": "^1.7.2"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
Loading…
Reference in New Issue
Block a user