mirror of
https://github.com/ascribe/onion.git
synced 2025-02-14 21:10:27 +01:00
Add twitter text
This commit is contained in:
parent
2dba4d5156
commit
af58687572
@ -14,6 +14,11 @@ import CollapsibleButton from './../ascribe_collapsible/collapsible_button';
|
|||||||
|
|
||||||
import AclProxy from '../acl_proxy';
|
import AclProxy from '../acl_proxy';
|
||||||
|
|
||||||
|
import UserActions from '../../actions/user_actions';
|
||||||
|
import UserStore from '../../stores/user_store';
|
||||||
|
|
||||||
|
import { mergeOptions } from '../../utils/general_utils.js';
|
||||||
|
import { getLangText } from '../../utils/lang_utils.js';
|
||||||
|
|
||||||
const EMBED_IFRAME_HEIGHT = {
|
const EMBED_IFRAME_HEIGHT = {
|
||||||
video: 315,
|
video: 315,
|
||||||
@ -27,10 +32,17 @@ let MediaContainer = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
return {timerId: null};
|
return mergeOptions(
|
||||||
|
UserStore.getState(),
|
||||||
|
{
|
||||||
|
timerId: null
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
UserStore.listen(this.onChange);
|
||||||
|
UserActions.fetchCurrentUser();
|
||||||
|
|
||||||
if (!this.props.content.digital_work) {
|
if (!this.props.content.digital_work) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -51,16 +63,23 @@ let MediaContainer = React.createClass({
|
|||||||
window.clearInterval(this.state.timerId);
|
window.clearInterval(this.state.timerId);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onChange(state) {
|
||||||
|
this.setState(state);
|
||||||
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let thumbnail = this.props.content.thumbnail.thumbnail_sizes && this.props.content.thumbnail.thumbnail_sizes['600x600'] ?
|
const { content } = this.props;
|
||||||
this.props.content.thumbnail.thumbnail_sizes['600x600'] : this.props.content.thumbnail.url_safe;
|
const didUserRegisterContent = this.state.currentUser && (this.state.currentUser.username === content.user_registered);
|
||||||
let mimetype = this.props.content.digital_work.mime;
|
|
||||||
|
let thumbnail = content.thumbnail.thumbnail_sizes && content.thumbnail.thumbnail_sizes['600x600'] ?
|
||||||
|
content.thumbnail.thumbnail_sizes['600x600'] : content.thumbnail.url_safe;
|
||||||
|
let mimetype = content.digital_work.mime;
|
||||||
let embed = null;
|
let embed = null;
|
||||||
let extraData = null;
|
let extraData = null;
|
||||||
let isEmbedDisabled = mimetype === 'video' && this.props.content.digital_work.isEncoding !== undefined && this.props.content.digital_work.isEncoding !== 100;
|
let isEmbedDisabled = mimetype === 'video' && content.digital_work.isEncoding !== undefined && content.digital_work.isEncoding !== 100;
|
||||||
|
|
||||||
if (this.props.content.digital_work.encoding_urls) {
|
if (content.digital_work.encoding_urls) {
|
||||||
extraData = this.props.content.digital_work.encoding_urls.map(e => { return { url: e.url, type: e.label }; });
|
extraData = content.digital_work.encoding_urls.map(e => { return { url: e.url, type: e.label }; });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (['video', 'audio'].indexOf(mimetype) > -1) {
|
if (['video', 'audio'].indexOf(mimetype) > -1) {
|
||||||
@ -76,7 +95,7 @@ let MediaContainer = React.createClass({
|
|||||||
panel={
|
panel={
|
||||||
<pre className="">
|
<pre className="">
|
||||||
{'<iframe width="560" height="' + height + '" src="https://embed.ascribe.io/content/'
|
{'<iframe width="560" height="' + height + '" src="https://embed.ascribe.io/content/'
|
||||||
+ this.props.content.bitcoin_id + '" frameborder="0" allowfullscreen></iframe>'}
|
+ content.bitcoin_id + '" frameborder="0" allowfullscreen></iframe>'}
|
||||||
</pre>
|
</pre>
|
||||||
}/>
|
}/>
|
||||||
);
|
);
|
||||||
@ -86,20 +105,21 @@ let MediaContainer = React.createClass({
|
|||||||
<MediaPlayer
|
<MediaPlayer
|
||||||
mimetype={mimetype}
|
mimetype={mimetype}
|
||||||
preview={thumbnail}
|
preview={thumbnail}
|
||||||
url={this.props.content.digital_work.url}
|
url={content.digital_work.url}
|
||||||
extraData={extraData}
|
extraData={extraData}
|
||||||
encodingStatus={this.props.content.digital_work.isEncoding} />
|
encodingStatus={content.digital_work.isEncoding} />
|
||||||
<p className="text-center">
|
<p className="text-center">
|
||||||
<span className="ascribe-social-button-list">
|
<span className="ascribe-social-button-list">
|
||||||
<FacebookShareButton />
|
<FacebookShareButton />
|
||||||
<TwitterShareButton />
|
<TwitterShareButton
|
||||||
|
text={getLangText('Check out %s ascribed piece', didUserRegisterContent ? 'my latest' : 'this' )} />
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<AclProxy
|
<AclProxy
|
||||||
show={['video', 'audio', 'image'].indexOf(mimetype) === -1 || this.props.content.acl.acl_download}
|
show={['video', 'audio', 'image'].indexOf(mimetype) === -1 || content.acl.acl_download}
|
||||||
aclObject={this.props.content.acl}
|
aclObject={content.acl}
|
||||||
aclName="acl_download">
|
aclName="acl_download">
|
||||||
<Button bsSize="xsmall" className="ascribe-margin-1px" href={this.props.content.digital_work.url} target="_blank">
|
<Button bsSize="xsmall" className="ascribe-margin-1px" href={content.digital_work.url} target="_blank">
|
||||||
Download <Glyphicon glyph="cloud-download"/>
|
Download <Glyphicon glyph="cloud-download"/>
|
||||||
</Button>
|
</Button>
|
||||||
</AclProxy>
|
</AclProxy>
|
||||||
|
@ -19,7 +19,8 @@ let TwitterShareButton = React.createClass({
|
|||||||
|
|
||||||
getDefaultProps() {
|
getDefaultProps() {
|
||||||
return {
|
return {
|
||||||
count: 'none'
|
count: 'none',
|
||||||
|
via: 'ascribeIO'
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user