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: {
|
|
|
|
metadata: React.PropTypes.object,
|
|
|
|
name: React.PropTypes.string,
|
|
|
|
amount: React.PropTypes.double,
|
|
|
|
},
|
|
|
|
render: function() {
|
|
|
|
return (
|
|
|
|
<div className="row-fluid" style={formatItemStyle}>
|
|
|
|
<div className="span4">
|
2016-07-16 07:19:40 +02:00
|
|
|
<img src={this.props.metadata.thumbnail} alt={'Photo for ' + this.props.metadata.title} style={formatItemImgStyle} />
|
2016-07-16 04:58:24 +02:00
|
|
|
</div>
|
|
|
|
<div className="span8">
|
2016-07-16 07:43:12 +02:00
|
|
|
<h4 style={formatItemMetadataStyle}><b>Address:</b> {this.props.name}</h4>
|
2016-07-16 04:58:24 +02:00
|
|
|
<div style={formatSubheaderStyle}>
|
|
|
|
<div style={formatItemCostStyle}><CreditAmount amount={this.props.amount} isEstimate={true}/></div>
|
|
|
|
<WatchLink streamName={this.props.name} />
|
|
|
|
|
|
|
|
<DownloadLink streamName={this.props.name} />
|
|
|
|
</div>
|
2016-07-16 07:19:40 +02:00
|
|
|
<p style={formatItemDescriptionStyle}>{this.props.metadata.description}</p>
|
2016-07-16 04:58:24 +02:00
|
|
|
<div>
|
2016-07-16 07:43:12 +02:00
|
|
|
<span style={formatItemMetadataStyle}><b>Author:</b> {this.props.metadata.author}</span><br />
|
|
|
|
<span style={formatItemMetadataStyle}><b>Language:</b> {this.props.metadata.language}</span><br />
|
|
|
|
<span style={formatItemMetadataStyle}><b>License:</b> {this.props.metadata.license}</span><br />
|
2016-07-16 04:58:24 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var FormatsSection = React.createClass({
|
|
|
|
propTypes: {
|
|
|
|
name: React.PropTypes.string,
|
|
|
|
},
|
|
|
|
getInitialState: function() {
|
|
|
|
return {
|
|
|
|
metadata: null,
|
|
|
|
amount: 0.0,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
componentWillMount: function() {
|
|
|
|
lbry.resolveName(this.props.name, (metadata) => {
|
|
|
|
this.setState({
|
|
|
|
metadata: metadata,
|
|
|
|
})
|
|
|
|
});
|
|
|
|
lbry.search(this.props.name, (results) => {
|
|
|
|
this.setState({
|
|
|
|
amount: (results ? results[0].cost_est : 0.0)
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
render: function() {
|
|
|
|
if (this.state.metadata == null) {
|
|
|
|
// Still waiting for metadata
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
var format = this.state.metadata;
|
|
|
|
|
|
|
|
return (
|
2016-07-16 07:19:40 +02:00
|
|
|
<div>
|
2016-07-16 07:43:12 +02:00
|
|
|
<h1 style={formatHeaderStyle}>{this.state.metadata.title}</h1>
|
2016-07-16 07:19:40 +02:00
|
|
|
{/* In future, anticipate multiple formats, just a guess at what it could look like
|
|
|
|
// var formats = metadata.formats
|
|
|
|
// return (<tbody>{formats.map(function(format,i){ */}
|
|
|
|
<FormatItem metadata={format} amount={this.state.amount} name={this.props.name}/>
|
|
|
|
{/* })}</tbody>); */}
|
|
|
|
</div>);
|
2016-07-16 04:58:24 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var DetailPage = React.createClass({
|
|
|
|
propTypes: {
|
|
|
|
name: React.PropTypes.string,
|
|
|
|
},
|
|
|
|
render: function() {
|
|
|
|
return (
|
|
|
|
<main className="page">
|
|
|
|
<SubPageLogo />
|
2016-07-16 07:19:40 +02:00
|
|
|
<FormatsSection name={this.props.name}/>
|
2016-07-16 04:58:24 +02:00
|
|
|
<section>
|
|
|
|
<Link href="/" label="<< Return" />
|
|
|
|
</section>
|
|
|
|
</main>);
|
|
|
|
}
|
|
|
|
});
|