Skip to content

Commit

Permalink
feat(trackers): display descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
DEgITx committed Aug 16, 2018
1 parent 505787c commit 73cfc89
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 20 deletions.
33 changes: 23 additions & 10 deletions src/app/torrent-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ import LinearProgress from 'material-ui/LinearProgress';
import FlatButton from 'material-ui/FlatButton';
import {fileTypeDetect} from './content'
import {contentIcon} from './torrent'
import TrackersImages from './trackers-images'

let parseDescriptionText = (text) => {
return text.split("\n").map(function(item) {
const text = /([A-Za-zА-Яа-я]+:) (.+)/.exec(item)

return (
<span>
{text ? <span><b>{`${text[1]} `}</b>{text[2]}</span> : item}
<br/>
</span>
)
})
}

let buildFilesTree = (filesList) => {
let rootTree = {
Expand Down Expand Up @@ -359,7 +373,8 @@ export default class TorrentPage extends Page {
</div>
<div style={{flexBasis: '40%'}} className='column center w100p'>
<img src={(this.torrent && this.torrent.info && this.torrent.info.poster) ? this.torrent.info.poster : NoImage} className='pad0-75' style={{height: '200px'}} />
<RaisedButton
<TrackersImages info={this.torrent && this.torrent.info} className='column' />
<RaisedButton
href={`magnet:?xt=urn:btih:${this.torrent.hash}`}
target="_self"
label="Magnet"
Expand Down Expand Up @@ -509,15 +524,13 @@ export default class TorrentPage extends Page {
}
</div>
</div>
<div>
{
this.torrent && this.torrent.info && this.torrent.info.description
?
<div />
:
null
}
</div>
{
this.torrent && this.torrent.info && this.torrent.info.description
&&
<div className='fs0-85' style={{width: '95%', padding: 15, margin: 20, boxShadow: 'rgba(0, 0, 0, 0.12) 0px 1px 6px, rgba(0, 0, 0, 0.12) 0px 1px 4px'}}>
<div>{parseDescriptionText(this.torrent.info.description)}</div>
</div>
}
</div>
</Tab>
<Tab label={__('Files')} value="files" >
Expand Down
12 changes: 2 additions & 10 deletions src/app/torrent.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import TorrentPage from './torrent-page'
import LinearProgress from 'material-ui/LinearProgress';
let rating = require('./rating');
import scrollBack from './remember-scroll'

import RutrackerIcon from './images/strategies/rutracker.png'
import NyaaIcon from './images/strategies/nyaa.jpg'
import TrackersImages from './trackers-images'

const contentIcon = (type, category, fill = 'grey') => {
if(category == 'xxx')
Expand Down Expand Up @@ -361,13 +359,7 @@ export default class Torrent extends Component {
}
</div>
}
<div>
{
torrent.info && torrent.info.trackers && torrent.info.trackers.includes('rutracker')
&&
<img src={RutrackerIcon} style={{height: 32}} />
}
</div>
<TrackersImages info={torrent.info} className='row' />
</div>
</a>
}
Expand Down
28 changes: 28 additions & 0 deletions src/app/trackers-images.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react';

import RutrackerIcon from './images/strategies/rutracker.png'
import NyaaIcon from './images/strategies/nyaa.jpg'

export default (props) => {
let className = ''
if(props.className)
className += props.className
const {info} = props
if(!info)
return null

return (
<div>
{
info.trackers.includes('rutracker')
&&
<a href={`https://rutracker.org/forum/viewtopic.php?t=${info.rutrackerThreadId}`}><img src={RutrackerIcon} style={{height: 32}} /></a>
}
{
info.trackers.includes('nyaa')
&&
<img src={NyaaIcon} style={{height: 32}} />
}
</div>
)
}

0 comments on commit 73cfc89

Please sign in to comment.