2016-11-22 21:19:08 +01:00
|
|
|
import React from 'react';
|
|
|
|
import lbry from '../lbry.js';
|
2016-12-08 00:07:28 +01:00
|
|
|
import lighthouse from '../lighthouse.js';
|
2017-04-11 03:29:07 +02:00
|
|
|
import uri from '../uri.js';
|
2017-04-13 20:52:26 +02:00
|
|
|
import {Video} from '../page/watch.js'
|
|
|
|
import {TruncatedText, Thumbnail, FilePrice, BusyMessage} from '../component/common.js';
|
2017-01-13 03:03:34 +01:00
|
|
|
import {FileActions} from '../component/file-actions.js';
|
|
|
|
import {Link} from '../component/link.js';
|
2017-04-13 20:52:26 +02:00
|
|
|
import UriIndicator from '../component/channel-indicator.js';
|
2016-07-16 04:58:24 +02:00
|
|
|
|
|
|
|
var FormatItem = React.createClass({
|
|
|
|
propTypes: {
|
2017-04-11 03:29:07 +02:00
|
|
|
metadata: React.PropTypes.object,
|
|
|
|
contentType: React.PropTypes.string,
|
|
|
|
uri: React.PropTypes.string,
|
2017-03-08 08:17:16 +01:00
|
|
|
outpoint: React.PropTypes.string,
|
2016-07-16 04:58:24 +02:00
|
|
|
},
|
|
|
|
render: function() {
|
2017-04-11 03:29:07 +02:00
|
|
|
const {thumbnail, author, title, description, language, license} = this.props.metadata;
|
|
|
|
const mediaType = lbry.getMediaType(this.props.contentType);
|
2016-07-16 04:58:24 +02:00
|
|
|
|
|
|
|
return (
|
2017-04-13 20:52:26 +02:00
|
|
|
<table className="table-standard">
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td>Content-Type</td><td>{this.props.contentType}</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Author</td><td>{author}</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Language</td><td>{language}</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>License</td><td>{license}</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
);
|
2016-07-16 04:58:24 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-04-13 20:52:26 +02:00
|
|
|
let ShowPage = React.createClass({
|
2017-04-11 03:29:07 +02:00
|
|
|
_uri: null,
|
|
|
|
|
2016-07-16 04:58:24 +02:00
|
|
|
propTypes: {
|
2017-04-11 03:29:07 +02:00
|
|
|
uri: React.PropTypes.string,
|
2016-07-16 04:58:24 +02:00
|
|
|
},
|
2016-07-16 19:14:06 +02:00
|
|
|
getInitialState: function() {
|
|
|
|
return {
|
2016-12-08 00:45:18 +01:00
|
|
|
metadata: null,
|
2017-04-11 03:29:07 +02:00
|
|
|
contentType: null,
|
2017-04-13 20:52:26 +02:00
|
|
|
hasSignature: false,
|
|
|
|
signatureIsValid: false,
|
2016-12-08 00:45:18 +01:00
|
|
|
cost: null,
|
2016-12-08 01:38:52 +01:00
|
|
|
costIncludesData: null,
|
2017-04-11 03:29:07 +02:00
|
|
|
uriLookupComplete: null,
|
2016-07-16 19:14:06 +02:00
|
|
|
};
|
|
|
|
},
|
|
|
|
componentWillMount: function() {
|
2017-04-11 03:29:07 +02:00
|
|
|
this._uri = uri.normalizeLbryUri(this.props.uri);
|
|
|
|
document.title = this._uri;
|
2016-08-08 06:47:48 +02:00
|
|
|
|
2017-04-13 20:52:26 +02:00
|
|
|
lbry.resolve({uri: this._uri}).then(({ claim: {txid, nout, has_signature, signature_is_valid, value: {stream: {metadata, source: {contentType}}}}}) => {
|
|
|
|
console.log({txid, nout, claim: {value: {stream: {metadata, source: {contentType}}}}} );
|
2016-12-08 01:38:52 +01:00
|
|
|
this.setState({
|
2017-03-08 08:17:16 +01:00
|
|
|
outpoint: txid + ':' + nout,
|
2017-04-11 03:29:07 +02:00
|
|
|
metadata: metadata,
|
2017-04-13 20:52:26 +02:00
|
|
|
hasSignature: has_signature,
|
|
|
|
signatureIsValid: signature_is_valid,
|
2017-04-11 03:29:07 +02:00
|
|
|
contentType: contentType,
|
|
|
|
uriLookupComplete: true,
|
2016-12-08 01:38:52 +01:00
|
|
|
});
|
|
|
|
});
|
2016-09-02 08:49:50 +02:00
|
|
|
|
2017-04-13 20:52:26 +02:00
|
|
|
lbry.getCostInfo(this._uri).then(({cost, includesData}) => {
|
2016-12-08 01:38:52 +01:00
|
|
|
this.setState({
|
|
|
|
cost: cost,
|
|
|
|
costIncludesData: includesData,
|
|
|
|
});
|
2016-07-16 19:14:06 +02:00
|
|
|
});
|
|
|
|
},
|
2016-07-16 04:58:24 +02:00
|
|
|
render: function() {
|
2016-12-08 00:45:18 +01:00
|
|
|
if (this.state.metadata == null) {
|
2016-07-16 19:14:06 +02:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2017-04-13 20:52:26 +02:00
|
|
|
// <div className="card__media" style={{ backgroundImage: "url('" + metadata.thumbnail + "')" }}></div>
|
|
|
|
|
|
|
|
const
|
|
|
|
metadata = this.state.uriLookupComplete ? this.state.metadata : null,
|
|
|
|
title = this.state.uriLookupComplete ? metadata.title : this._uri;
|
|
|
|
|
2017-04-13 21:37:41 +02:00
|
|
|
console.log(metadata);
|
2016-07-16 04:58:24 +02:00
|
|
|
return (
|
2017-04-13 20:52:26 +02:00
|
|
|
<main className="constrained-page">
|
|
|
|
<section className="show-page-media">
|
|
|
|
{ this.props.contentType && this.props.contentType.startsWith('video/') ?
|
|
|
|
<Video className="video-embedded" uri={this._uri} /> :
|
|
|
|
<Thumbnail src={metadata.thumbnail} /> }
|
|
|
|
</section>
|
|
|
|
<section className="card">
|
|
|
|
<div className="card__inner">
|
|
|
|
<div className="card__title-identity">
|
2017-04-13 21:37:41 +02:00
|
|
|
<span style={{float: "right"}}><FilePrice uri={this._uri} metadata={metadata} /></span>
|
2017-04-13 20:52:26 +02:00
|
|
|
<h1>{title}</h1>
|
|
|
|
{ this.state.uriLookupComplete ?
|
|
|
|
<div>
|
|
|
|
<div className="card__subtitle">
|
|
|
|
<UriIndicator uri={this._uri} hasSignature={this.state.hasSignature} signatureIsValid={this.state.signatureIsValid} />
|
|
|
|
</div>
|
|
|
|
<div className="card__actions">
|
2017-04-13 21:37:41 +02:00
|
|
|
<FileActions uri={this._uri} outpoint={this.state.outpoint} metadata={metadata} contentType={this.state.contentType} />
|
2017-04-13 20:52:26 +02:00
|
|
|
</div>
|
|
|
|
</div> : '' }
|
2016-09-02 08:49:50 +02:00
|
|
|
</div>
|
2017-04-13 20:52:26 +02:00
|
|
|
{ this.state.uriLookupComplete ?
|
|
|
|
<div>
|
|
|
|
<div className="card__content card__subtext card__subtext card__subtext--allow-newlines">
|
|
|
|
{metadata.description}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
: <BusyMessage message="Loading..." /> }
|
|
|
|
</div>
|
|
|
|
<div className="card__content">
|
|
|
|
<FormatItem metadata={metadata} contentType={this.state.contentType} cost={this.state.cost} uri={this._uri} outpoint={this.state.outpoint} costIncludesData={this.state.costIncludesData} />
|
|
|
|
</div>
|
|
|
|
<div className="card__content">
|
|
|
|
<Link href="https://lbry.io/dmca" label="report" className="button-text-help" />
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</main>
|
|
|
|
);
|
2016-07-16 04:58:24 +02:00
|
|
|
}
|
2016-11-22 21:19:08 +01:00
|
|
|
});
|
|
|
|
|
2017-04-11 03:29:07 +02:00
|
|
|
export default ShowPage;
|