2016-07-16 04:58:24 +02:00
|
|
|
var formatItemStyle = {
|
|
|
|
fontSize: '0.95em',
|
|
|
|
marginTop: '10px',
|
|
|
|
maxHeight: '220px'
|
|
|
|
}, formatItemImgStyle = {
|
|
|
|
maxWidth: '100%',
|
|
|
|
maxHeight: '100%',
|
|
|
|
display: 'block',
|
|
|
|
marginLeft: 'auto',
|
|
|
|
marginRight: 'auto',
|
|
|
|
marginTop: '5px',
|
|
|
|
}, formatHeaderStyle = {
|
|
|
|
fontWeight: 'bold',
|
|
|
|
marginBottom: '5px'
|
|
|
|
}, formatSubheaderStyle = {
|
|
|
|
marginBottom: '10px',
|
|
|
|
fontSize: '0.9em'
|
|
|
|
}, formatItemDescriptionStyle = {
|
|
|
|
color: '#444',
|
|
|
|
marginBottom: '5px',
|
2016-07-16 07:43:12 +02:00
|
|
|
fontSize: '1.2em',
|
2016-07-16 04:58:24 +02:00
|
|
|
}, formatItemMetadataStyle = {
|
|
|
|
color: '#444',
|
|
|
|
marginBottom: '5px',
|
|
|
|
fontSize: '0.9em',
|
|
|
|
}, formatItemCostStyle = {
|
|
|
|
float: 'right'
|
|
|
|
};
|
|
|
|
|
|
|
|
var FormatItem = React.createClass({
|
|
|
|
propTypes: {
|
2016-07-30 09:47:31 +02:00
|
|
|
claimInfo: React.PropTypes.object,
|
|
|
|
amount: React.PropTypes.number,
|
|
|
|
name: React.PropTypes.string,
|
2016-07-16 04:58:24 +02:00
|
|
|
},
|
|
|
|
render: function() {
|
2016-07-30 09:47:31 +02:00
|
|
|
var name = this.props.name;
|
|
|
|
|
|
|
|
var claimInfo = this.props.claimInfo;
|
|
|
|
var thumbnail = claimInfo.thumbnail;
|
|
|
|
var title = claimInfo.title;
|
|
|
|
var description = claimInfo.description;
|
|
|
|
var author = claimInfo.author;
|
|
|
|
var language = claimInfo.language;
|
|
|
|
var license = claimInfo.license;
|
|
|
|
var fileContentType = claimInfo['content-type'];
|
|
|
|
|
|
|
|
var amount = this.props.amount || 0.0;
|
2016-07-16 19:14:06 +02:00
|
|
|
|
2016-07-16 04:58:24 +02:00
|
|
|
return (
|
|
|
|
<div className="row-fluid" style={formatItemStyle}>
|
|
|
|
<div className="span4">
|
2016-07-16 19:14:06 +02:00
|
|
|
<img src={thumbnail} alt={'Photo for ' + title} style={formatItemImgStyle} />
|
2016-07-16 04:58:24 +02:00
|
|
|
</div>
|
|
|
|
<div className="span8">
|
2016-07-16 19:14:06 +02:00
|
|
|
<h4 style={formatItemMetadataStyle}><b>Address:</b> {name}</h4>
|
|
|
|
<h4 style={formatItemMetadataStyle}><b>Content-Type:</b> {fileContentType}</h4>
|
2016-07-16 04:58:24 +02:00
|
|
|
<div style={formatSubheaderStyle}>
|
2016-07-16 19:14:06 +02:00
|
|
|
<div style={formatItemCostStyle}><CreditAmount amount={amount} isEstimate={true}/></div>
|
|
|
|
<WatchLink streamName={name} />
|
2016-07-16 04:58:24 +02:00
|
|
|
|
2016-07-16 19:14:06 +02:00
|
|
|
<DownloadLink streamName={name} />
|
2016-07-16 04:58:24 +02:00
|
|
|
</div>
|
2016-07-16 19:14:06 +02:00
|
|
|
<p style={formatItemDescriptionStyle}>{description}</p>
|
2016-07-16 04:58:24 +02:00
|
|
|
<div>
|
2016-07-16 19:14:06 +02:00
|
|
|
<span style={formatItemMetadataStyle}><b>Author:</b> {author}</span><br />
|
|
|
|
<span style={formatItemMetadataStyle}><b>Language:</b> {language}</span><br />
|
|
|
|
<span style={formatItemMetadataStyle}><b>License:</b> {license}</span><br />
|
2016-07-16 04:58:24 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var FormatsSection = React.createClass({
|
|
|
|
propTypes: {
|
2016-07-30 09:47:31 +02:00
|
|
|
claimInfo: React.PropTypes.object,
|
|
|
|
amount: React.PropTypes.number,
|
2016-07-16 04:58:24 +02:00
|
|
|
name: React.PropTypes.string,
|
|
|
|
},
|
|
|
|
render: function() {
|
2016-07-16 19:14:06 +02:00
|
|
|
var name = this.props.name;
|
2016-07-30 09:47:31 +02:00
|
|
|
var format = this.props.claimInfo;
|
2016-07-16 19:14:06 +02:00
|
|
|
var title = format.title;
|
2016-07-16 04:58:24 +02:00
|
|
|
|
2016-07-16 19:14:06 +02:00
|
|
|
if(format == null)
|
|
|
|
{
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<h1 style={formatHeaderStyle}>Sorry, no results found for "{name}".</h1>
|
|
|
|
</div>);
|
|
|
|
}
|
2016-07-16 04:58:24 +02:00
|
|
|
|
|
|
|
return (
|
2016-07-16 07:19:40 +02:00
|
|
|
<div>
|
2016-07-16 19:14:06 +02:00
|
|
|
<h1 style={formatHeaderStyle}>{title}</h1>
|
2016-07-16 07:19:40 +02:00
|
|
|
{/* In future, anticipate multiple formats, just a guess at what it could look like
|
2016-07-30 09:47:31 +02:00
|
|
|
// var formats = this.props.claimInfo.formats
|
2016-07-16 07:19:40 +02:00
|
|
|
// return (<tbody>{formats.map(function(format,i){ */}
|
2016-07-30 09:47:31 +02:00
|
|
|
<FormatItem name={name} claimInfo={format} amount={this.props.amount} />
|
2016-07-16 07:19:40 +02:00
|
|
|
{/* })}</tbody>); */}
|
|
|
|
</div>);
|
2016-07-16 04:58:24 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var DetailPage = React.createClass({
|
|
|
|
propTypes: {
|
|
|
|
name: React.PropTypes.string,
|
|
|
|
},
|
2016-07-16 19:14:06 +02:00
|
|
|
getInitialState: function() {
|
|
|
|
return {
|
2016-07-30 09:47:31 +02:00
|
|
|
claimInfo: null,
|
|
|
|
amount: null,
|
2016-07-16 19:14:06 +02:00
|
|
|
searching: true,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
componentWillMount: function() {
|
2016-07-30 09:47:31 +02:00
|
|
|
lbry.getClaimInfo(this.props.name, (claimInfo) => {
|
2016-07-16 19:14:06 +02:00
|
|
|
this.setState({
|
2016-07-30 09:47:31 +02:00
|
|
|
claimInfo: claimInfo.value,
|
2016-07-16 19:14:06 +02:00
|
|
|
searching: false,
|
|
|
|
});
|
|
|
|
});
|
2016-07-30 09:47:31 +02:00
|
|
|
|
|
|
|
lbry.getCostEstimate(this.props.name, (amount) => {
|
|
|
|
this.setState({
|
|
|
|
amount: amount,
|
|
|
|
});
|
|
|
|
});
|
2016-07-16 19:14:06 +02:00
|
|
|
},
|
2016-07-16 04:58:24 +02:00
|
|
|
render: function() {
|
2016-07-30 09:47:31 +02:00
|
|
|
if (this.state.claimInfo == null && this.state.searching) {
|
2016-07-16 19:14:06 +02:00
|
|
|
// Still waiting for metadata
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
var name = this.props.name;
|
2016-07-30 09:47:31 +02:00
|
|
|
var claimInfo = this.state.claimInfo;
|
|
|
|
var amount = this.state.amount;
|
2016-07-16 19:14:06 +02:00
|
|
|
|
2016-07-16 04:58:24 +02:00
|
|
|
return (
|
|
|
|
<main className="page">
|
|
|
|
<SubPageLogo />
|
2016-07-30 09:47:31 +02:00
|
|
|
<FormatsSection name={name} claimInfo={claimInfo} amount={amount} />
|
2016-07-16 04:58:24 +02:00
|
|
|
<section>
|
|
|
|
<Link href="/" label="<< Return" />
|
|
|
|
</section>
|
|
|
|
</main>);
|
|
|
|
}
|
|
|
|
});
|