отображения типа файла в списке файлов
This commit is contained in:
2
index.js
2
index.js
@ -12,7 +12,7 @@ var sm = require('sitemap');
|
|||||||
var phantomjs = require('phantomjs-prebuilt')
|
var phantomjs = require('phantomjs-prebuilt')
|
||||||
var ipaddr = require('ipaddr.js');
|
var ipaddr = require('ipaddr.js');
|
||||||
|
|
||||||
const torrentTypeDetect = require('./lib/content');
|
const {torrentTypeDetect} = require('./lib/content');
|
||||||
|
|
||||||
// Start server
|
// Start server
|
||||||
server.listen(config.httpPort);
|
server.listen(config.httpPort);
|
||||||
|
@ -274,7 +274,7 @@ const detectSubCategory = (torrent, files, typesPriority, contentType) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const fileDetect = (file) => {
|
const fileTypeDetect = (file) => {
|
||||||
let name = file.path.split('/').pop();
|
let name = file.path.split('/').pop();
|
||||||
let extension = name.split('.').pop();
|
let extension = name.split('.').pop();
|
||||||
if(name.length == 0)
|
if(name.length == 0)
|
||||||
@ -291,7 +291,7 @@ const torrentTypeDetect = (torrent, files) => {
|
|||||||
|
|
||||||
for(let i = 0; i < files.length; i++) {
|
for(let i = 0; i < files.length; i++) {
|
||||||
let file = files[i];
|
let file = files[i];
|
||||||
let type = fileDetect(file)
|
let type = fileTypeDetect(file)
|
||||||
|
|
||||||
if(type) {
|
if(type) {
|
||||||
if(!typesPriority[type])
|
if(!typesPriority[type])
|
||||||
@ -309,4 +309,4 @@ const torrentTypeDetect = (torrent, files) => {
|
|||||||
detectSubCategory(torrent, files, typesPriority, torrent[ContentTypeProp]);
|
detectSubCategory(torrent, files, typesPriority, torrent[ContentTypeProp]);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = torrentTypeDetect;
|
module.exports = {torrentTypeDetect, fileTypeDetect};
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
const mysql = require('mysql');
|
const mysql = require('mysql');
|
||||||
const torrentTypeDetect = require('../lib/content');
|
const {torrentTypeDetect} = require('../lib/content');
|
||||||
|
|
||||||
const mysqlSettings = {
|
const mysqlSettings = {
|
||||||
host : 'localhost',
|
host : 'localhost',
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
const mysql = require('mysql');
|
const mysql = require('mysql');
|
||||||
const torrentTypeDetect = require('../lib/content');
|
const {torrentTypeDetect} = require('../lib/content');
|
||||||
|
|
||||||
const mysqlSettings = {
|
const mysqlSettings = {
|
||||||
host : 'localhost',
|
host : 'localhost',
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
const mysql = require('mysql');
|
const mysql = require('mysql');
|
||||||
const torrentTypeDetect = require('../lib/content');
|
const {torrentTypeDetect} = require('../lib/content');
|
||||||
|
|
||||||
const mysqlSettings = {
|
const mysqlSettings = {
|
||||||
host : 'localhost',
|
host : 'localhost',
|
||||||
|
@ -18,6 +18,8 @@ var moment = require('moment');
|
|||||||
import RefreshIndicator from 'material-ui/RefreshIndicator';
|
import RefreshIndicator from 'material-ui/RefreshIndicator';
|
||||||
let rating = require('../lib/rating');
|
let rating = require('../lib/rating');
|
||||||
import LinearProgress from 'material-ui/LinearProgress';
|
import LinearProgress from 'material-ui/LinearProgress';
|
||||||
|
import {fileTypeDetect} from '../lib/content'
|
||||||
|
import {contentIcon} from './torrent'
|
||||||
|
|
||||||
let buildFilesTree = (filesList) => {
|
let buildFilesTree = (filesList) => {
|
||||||
let rootTree = {
|
let rootTree = {
|
||||||
@ -55,7 +57,7 @@ const treeToTorrentFiles = (tree) => {
|
|||||||
nestedItems={treeToTorrentFiles(tree[file])}
|
nestedItems={treeToTorrentFiles(tree[file])}
|
||||||
primaryTogglesNestedList={true}
|
primaryTogglesNestedList={true}
|
||||||
innerDivStyle={{wordBreak: 'break-word'}}
|
innerDivStyle={{wordBreak: 'break-word'}}
|
||||||
leftIcon={tree[file] && Object.keys(tree[file]).length > 1 ? <FileFolder /> : null}
|
leftIcon={tree[file] && Object.keys(tree[file]).length > 1 ? <FileFolder /> : contentIcon(fileTypeDetect({path: file}))}
|
||||||
/>);
|
/>);
|
||||||
}
|
}
|
||||||
return arr;
|
return arr;
|
||||||
|
115
src/torrent.js
115
src/torrent.js
@ -3,62 +3,8 @@ import formatBytes from './format-bytes'
|
|||||||
import {ListItem} from 'material-ui/List';
|
import {ListItem} from 'material-ui/List';
|
||||||
import Divider from 'material-ui/Divider';
|
import Divider from 'material-ui/Divider';
|
||||||
|
|
||||||
export default (props) => {
|
const contentIcon = (type) => {
|
||||||
|
switch(type)
|
||||||
const torrent = props.torrent;
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<ListItem
|
|
||||||
onClick={() => window.router('/torrent/' + torrent.hash)}
|
|
||||||
primaryText={
|
|
||||||
<a href={'/torrent/' + torrent.hash} ref={(node) => {
|
|
||||||
if(node)
|
|
||||||
node.onclick = () => { return false }
|
|
||||||
}}>
|
|
||||||
<span className='break-word' style={{
|
|
||||||
color: torrent.contentCategory != 'xxx' ? 'black' : 'grey'
|
|
||||||
}}>
|
|
||||||
{torrent.name}
|
|
||||||
</span>
|
|
||||||
</a>
|
|
||||||
}
|
|
||||||
secondaryText={
|
|
||||||
<a href={'/torrent/' + torrent.hash} ref={(node) => {
|
|
||||||
if(node)
|
|
||||||
node.onclick = () => { return false }
|
|
||||||
}}>
|
|
||||||
<div className='column' style={{height: 'auto', whiteSpace: 'normal', paddingTop: '0.30em'}}>
|
|
||||||
<div>
|
|
||||||
{
|
|
||||||
formatBytes(torrent.size, 1) + ' (' + torrent.files + ' files)'
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
{
|
|
||||||
torrent.path && torrent.path.length > 0
|
|
||||||
?
|
|
||||||
torrent.path.map((path, index) => {
|
|
||||||
return <div key={index} className='break-word fs0-75' style={{paddingTop: '0.3em', marginLeft: '0.6em'}}>{path}</div>
|
|
||||||
})
|
|
||||||
:
|
|
||||||
null
|
|
||||||
}
|
|
||||||
{
|
|
||||||
torrent.seeders || torrent.leechers || torrent.completed
|
|
||||||
?
|
|
||||||
<div className='break-word fs0-85' style={{paddingTop: '0.35em'}}>
|
|
||||||
<span style={{color: (torrent.seeders > 0 ? '#00C853' : 'grey')}}>{torrent.seeders} seeders</span>
|
|
||||||
<span style={{color: (torrent.leechers > 0 ? '#AA00FF' : 'grey'), marginLeft: '12px'}}>{torrent.leechers} leechers</span>
|
|
||||||
<span style={{color: (torrent.completed > 0 ? '#FF6D00' : 'grey'), marginLeft: '12px'}}>{torrent.completed} completed</span>
|
|
||||||
</div>
|
|
||||||
:
|
|
||||||
null
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
}
|
|
||||||
leftIcon={
|
|
||||||
(() => {
|
|
||||||
switch(torrent.contentType)
|
|
||||||
{
|
{
|
||||||
case 'video':
|
case 'video':
|
||||||
return (
|
return (
|
||||||
@ -180,8 +126,63 @@ return (
|
|||||||
</svg>
|
</svg>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
})()
|
};
|
||||||
|
export {contentIcon}
|
||||||
|
|
||||||
|
export default (props) => {
|
||||||
|
|
||||||
|
const torrent = props.torrent;
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<ListItem
|
||||||
|
onClick={() => window.router('/torrent/' + torrent.hash)}
|
||||||
|
primaryText={
|
||||||
|
<a href={'/torrent/' + torrent.hash} ref={(node) => {
|
||||||
|
if(node)
|
||||||
|
node.onclick = () => { return false }
|
||||||
|
}}>
|
||||||
|
<span className='break-word' style={{
|
||||||
|
color: torrent.contentCategory != 'xxx' ? 'black' : 'grey'
|
||||||
|
}}>
|
||||||
|
{torrent.name}
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
}
|
}
|
||||||
|
secondaryText={
|
||||||
|
<a href={'/torrent/' + torrent.hash} ref={(node) => {
|
||||||
|
if(node)
|
||||||
|
node.onclick = () => { return false }
|
||||||
|
}}>
|
||||||
|
<div className='column' style={{height: 'auto', whiteSpace: 'normal', paddingTop: '0.30em'}}>
|
||||||
|
<div>
|
||||||
|
{
|
||||||
|
formatBytes(torrent.size, 1) + ' (' + torrent.files + ' files)'
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
{
|
||||||
|
torrent.path && torrent.path.length > 0
|
||||||
|
?
|
||||||
|
torrent.path.map((path, index) => {
|
||||||
|
return <div key={index} className='break-word fs0-75' style={{paddingTop: '0.3em', marginLeft: '0.6em'}}>{path}</div>
|
||||||
|
})
|
||||||
|
:
|
||||||
|
null
|
||||||
|
}
|
||||||
|
{
|
||||||
|
torrent.seeders || torrent.leechers || torrent.completed
|
||||||
|
?
|
||||||
|
<div className='break-word fs0-85' style={{paddingTop: '0.35em'}}>
|
||||||
|
<span style={{color: (torrent.seeders > 0 ? '#00C853' : 'grey')}}>{torrent.seeders} seeders</span>
|
||||||
|
<span style={{color: (torrent.leechers > 0 ? '#AA00FF' : 'grey'), marginLeft: '12px'}}>{torrent.leechers} leechers</span>
|
||||||
|
<span style={{color: (torrent.completed > 0 ? '#FF6D00' : 'grey'), marginLeft: '12px'}}>{torrent.completed} completed</span>
|
||||||
|
</div>
|
||||||
|
:
|
||||||
|
null
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
}
|
||||||
|
leftIcon={contentIcon(torrent.contentType)}
|
||||||
rightIcon={
|
rightIcon={
|
||||||
<a href={`magnet:?xt=urn:btih:${torrent.hash}`}>
|
<a href={`magnet:?xt=urn:btih:${torrent.hash}`}>
|
||||||
<svg style={{
|
<svg style={{
|
||||||
|
Reference in New Issue
Block a user