топ торрентов
This commit is contained in:
26
index.js
26
index.js
@ -423,10 +423,29 @@ io.on('connection', function(socket)
|
||||
updateTorrentTrackers(hash);
|
||||
});
|
||||
|
||||
/*
|
||||
socket.on('topTorrents', function(params, callback)
|
||||
socket.on('topTorrents', function(type, callback)
|
||||
{
|
||||
mysqlPool.query('SELECT * FROM `torrents` ORDER BY seeders LIMIT 10', hash, function (error, rows) {
|
||||
let where = '';
|
||||
let max = 20;
|
||||
if(type && type.length > 0)
|
||||
{
|
||||
where += ' and contentType = ' + mysqlPool.escape(type) + ' ';
|
||||
max = 15;
|
||||
|
||||
if(type == 'hours')
|
||||
{
|
||||
where = ' and `added` > DATE_SUB(NOW(), INTERVAL 24 HOUR) '
|
||||
}
|
||||
if(type == 'week')
|
||||
{
|
||||
where = ' and `added` > DATE_SUB(NOW(), INTERVAL 7 DAY) '
|
||||
}
|
||||
if(type == 'month')
|
||||
{
|
||||
where = ' and `added` > DATE_SUB(NOW(), INTERVAL 7 DAY) '
|
||||
}
|
||||
}
|
||||
mysqlPool.query(`SELECT * FROM torrents WHERE seeders > 0 and (contentCategory is null or contentCategory != 'xxx') ${where} ORDER BY seeders + leechers DESC LIMIT ${max}`, function (error, rows) {
|
||||
if(!rows || rows.length == 0) {
|
||||
callback(undefined)
|
||||
return;
|
||||
@ -439,7 +458,6 @@ io.on('connection', function(socket)
|
||||
callback(searchList);
|
||||
});
|
||||
});
|
||||
*/
|
||||
|
||||
socket.on('admin', function(callback)
|
||||
{
|
||||
|
@ -139,6 +139,9 @@ export default class RecentTorrents extends Component {
|
||||
return (
|
||||
<List className='animated recent-torrents'>
|
||||
<Subheader className='recent-title' inset={true}>
|
||||
<FlatButton style={{marginRight: '8px'}} primary={true} label='top' labelStyle={{color: "#a4c639"}} onClick={() =>{
|
||||
window.router('/top');
|
||||
}} />
|
||||
<FlatButton style={{marginRight: '8px'}} label={!this.state.pause ? 'running' : 'stoped'} secondary={this.state.pause} primary={!this.state.pause} onClick={() =>{
|
||||
this.pauseAndContinue()
|
||||
}} />
|
||||
|
@ -6,6 +6,7 @@ import IndexPage from './index-page.js'
|
||||
import TorrentPage from './torrent-page.js'
|
||||
import DMCAPage from './dmca-page.js'
|
||||
import AdminPage from './admin-page.js'
|
||||
import TopPage from './top-page.js'
|
||||
|
||||
router('/', () => {
|
||||
//singleton
|
||||
@ -33,4 +34,10 @@ router('/admi5p', () => {
|
||||
//singleton
|
||||
let pie = new PagesPie;
|
||||
pie.open(AdminPage, {replace: 'all'});
|
||||
});
|
||||
|
||||
router('/top', () => {
|
||||
//singleton
|
||||
let pie = new PagesPie;
|
||||
pie.open(TopPage, {replace: 'all'});
|
||||
});
|
78
src/top-page.js
Normal file
78
src/top-page.js
Normal file
@ -0,0 +1,78 @@
|
||||
import React from 'react';
|
||||
import Page from './page';
|
||||
import Footer from './footer';
|
||||
import { Header } from './index-page'
|
||||
|
||||
import TorrentLine from './torrent'
|
||||
import {List} from 'material-ui/List';
|
||||
import Subheader from 'material-ui/Subheader';
|
||||
import RaisedButton from 'material-ui/RaisedButton';
|
||||
|
||||
export default class TopPage extends Page {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
this.setTitle('Rats On The Boat - Torrents top');
|
||||
this.topTorrents = {};
|
||||
this.types = ['main', 'week', 'hours', 'month', 'video', 'audio', 'books', 'pictures', 'application', 'archive']
|
||||
this.descriptions = {
|
||||
main: 'All',
|
||||
video: 'Video',
|
||||
audio: 'Audio/Music',
|
||||
books: 'Books',
|
||||
pictures: 'Pictures/Images',
|
||||
application: 'Applications/Games',
|
||||
archive: 'Archives',
|
||||
week: 'Last week',
|
||||
hours: 'Last 24 hours',
|
||||
month: 'Last month'
|
||||
}
|
||||
}
|
||||
componentDidMount()
|
||||
{
|
||||
super.componentDidMount();
|
||||
for(const type of this.types)
|
||||
{
|
||||
window.torrentSocket.emit('topTorrents', type == 'main' ? null : type, window.customLoader((data) => {
|
||||
this.topTorrents[type] = data;
|
||||
this.forceUpdate()
|
||||
}))
|
||||
}
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<Header />
|
||||
<div className='column center w100p pad0-75'>
|
||||
<RaisedButton label="Back to main page" primary={true} onClick={() => {
|
||||
window.router('/')
|
||||
}} />
|
||||
{
|
||||
this.types.map((type) => {
|
||||
const torrents = this.topTorrents[type];
|
||||
|
||||
if(!torrents)
|
||||
return null;
|
||||
|
||||
return (
|
||||
<List style={{paddingBottom: '70px'}} className='animated recent-torrents'>
|
||||
<Subheader inset={true}>
|
||||
{
|
||||
this.descriptions[type]
|
||||
}
|
||||
</Subheader>
|
||||
{
|
||||
torrents.map((torrent, index) => {
|
||||
return <TorrentLine key={index} torrent={torrent} />
|
||||
})
|
||||
}
|
||||
</List>
|
||||
)
|
||||
|
||||
})
|
||||
}
|
||||
<Footer />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user