фантом
This commit is contained in:
31
index.js
31
index.js
@ -8,9 +8,13 @@ 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');
|
var sm = require('sitemap');
|
||||||
|
var phantomjs = require('phantomjs-prebuilt')
|
||||||
|
|
||||||
const torrentTypeDetect = require('./lib/content');
|
const torrentTypeDetect = require('./lib/content');
|
||||||
|
|
||||||
|
const domain = process.env.NODE_ENV == 'production' ? 'ratsontheboat.org' : 'localhost:3000';
|
||||||
|
const http_port = 8095;
|
||||||
|
|
||||||
const mysqlSettings = {
|
const mysqlSettings = {
|
||||||
host : 'localhost',
|
host : 'localhost',
|
||||||
user : 'btsearch',
|
user : 'btsearch',
|
||||||
@ -24,7 +28,7 @@ const sphinxSettings = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Start server
|
// Start server
|
||||||
server.listen(8095);
|
server.listen(http_port);
|
||||||
|
|
||||||
let socketMysql = mysql.createPool({
|
let socketMysql = mysql.createPool({
|
||||||
connectionLimit: 40,
|
connectionLimit: 40,
|
||||||
@ -82,11 +86,6 @@ function handleListenerDisconnect() {
|
|||||||
handleListenerDisconnect();
|
handleListenerDisconnect();
|
||||||
|
|
||||||
|
|
||||||
app.get('/', function(req, res)
|
|
||||||
{
|
|
||||||
res.sendfile(__dirname + '/build/index.html');
|
|
||||||
});
|
|
||||||
|
|
||||||
app.use(express.static('build'));
|
app.use(express.static('build'));
|
||||||
|
|
||||||
app.get('/sitemap.xml', function(req, res) {
|
app.get('/sitemap.xml', function(req, res) {
|
||||||
@ -95,7 +94,7 @@ app.get('/sitemap.xml', function(req, res) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let sitemap = sm.createSitemap ({
|
let sitemap = sm.createSitemap ({
|
||||||
hostname: 'http://ratsontheboat.org',
|
hostname: 'http://' + domain,
|
||||||
cacheTime: 600000
|
cacheTime: 600000
|
||||||
});
|
});
|
||||||
sitemap.add({url: '/'});
|
sitemap.add({url: '/'});
|
||||||
@ -114,7 +113,23 @@ app.get('/sitemap.xml', function(req, res) {
|
|||||||
|
|
||||||
app.get('*', function(req, res)
|
app.get('*', function(req, res)
|
||||||
{
|
{
|
||||||
res.sendfile(__dirname + '/build/index.html');
|
if(typeof req.query['_escaped_fragment_'] != 'undefined')
|
||||||
|
{
|
||||||
|
let program = phantomjs.exec('phantom.js', 'http://' + domain + req.path)
|
||||||
|
let body = '';
|
||||||
|
program.stderr.pipe(process.stderr)
|
||||||
|
program.stdout.on('data', (chunk) => {
|
||||||
|
body += chunk;
|
||||||
|
});
|
||||||
|
program.on('exit', code => {
|
||||||
|
res.header('Content-Type', 'text/html');
|
||||||
|
res.send( body );
|
||||||
|
})
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
res.sendfile(__dirname + '/build/index-page.html');
|
||||||
});
|
});
|
||||||
|
|
||||||
// start
|
// start
|
||||||
|
@ -54,6 +54,7 @@
|
|||||||
"moment": "^2.17.1",
|
"moment": "^2.17.1",
|
||||||
"mysql": "^2.12.0",
|
"mysql": "^2.12.0",
|
||||||
"page": "^1.7.1",
|
"page": "^1.7.1",
|
||||||
|
"phantomjs-prebuilt": "^2.1.14",
|
||||||
"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",
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
var url = "http://localhost:3000/";
|
var system = require('system');
|
||||||
|
var url = system.args[1];
|
||||||
var page = require('webpage').create();
|
var page = require('webpage').create();
|
||||||
|
|
||||||
page.open(url, function(status) {
|
page.open(url, function(status) {
|
||||||
|
@ -139,13 +139,13 @@ export default class TorrentPage extends Page {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
window.torrentSocket.emit('torrent', this.props.hash, {files: true}, (data) => {
|
window.torrentSocket.emit('torrent', this.props.hash, {files: true}, window.customLoader((data) => {
|
||||||
if(data) {
|
if(data) {
|
||||||
this.torrent = data
|
this.torrent = data
|
||||||
this.setTitle('Download ' + this.torrent.name);
|
this.setTitle('Download ' + this.torrent.name);
|
||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
}
|
}
|
||||||
});
|
}));
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
|
Reference in New Issue
Block a user