From cd9a88a608ff906fc820f34291f3ca21f64ef672 Mon Sep 17 00:00:00 2001 From: Alexey Kasyanchuk Date: Thu, 16 Aug 2018 15:43:25 +0300 Subject: [PATCH] feat(trackers): display descriptions --- src/app/torrent-page.js | 33 +++++++++++++++++++++++---------- src/app/torrent.js | 12 ++---------- src/app/trackers-images.js | 28 ++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 20 deletions(-) create mode 100644 src/app/trackers-images.js diff --git a/src/app/torrent-page.js b/src/app/torrent-page.js index dfbdbe0..243de8a 100644 --- a/src/app/torrent-page.js +++ b/src/app/torrent-page.js @@ -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 ( + + {text ? {`${text[1]} `}{text[2]} : item} +
+
+ ) + }) +} let buildFilesTree = (filesList) => { let rootTree = { @@ -359,7 +373,8 @@ export default class TorrentPage extends Page {
- +
-
- { - this.torrent && this.torrent.info && this.torrent.info.description - ? -
- : - null - } -
+ { + this.torrent && this.torrent.info && this.torrent.info.description + && +
+
{parseDescriptionText(this.torrent.info.description)}
+
+ }
diff --git a/src/app/torrent.js b/src/app/torrent.js index 5d1794d..049d67d 100644 --- a/src/app/torrent.js +++ b/src/app/torrent.js @@ -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') @@ -361,13 +359,7 @@ export default class Torrent extends Component { } } -
- { - torrent.info && torrent.info.trackers && torrent.info.trackers.includes('rutracker') - && - - } -
+ } diff --git a/src/app/trackers-images.js b/src/app/trackers-images.js new file mode 100644 index 0000000..e1874b3 --- /dev/null +++ b/src/app/trackers-images.js @@ -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 ( +
+ { + info.trackers.includes('rutracker') + && + + } + { + info.trackers.includes('nyaa') + && + + } +
+ ) +} \ No newline at end of file