1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 17:33:14 +01:00

Add twitter text

This commit is contained in:
Brett Sun 2015-11-10 19:33:08 +01:00
parent 2dba4d5156
commit af58687572
2 changed files with 36 additions and 15 deletions

View File

@ -14,6 +14,11 @@ import CollapsibleButton from './../ascribe_collapsible/collapsible_button';
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 = {
video: 315,
@ -27,10 +32,17 @@ let MediaContainer = React.createClass({
},
getInitialState() {
return {timerId: null};
return mergeOptions(
UserStore.getState(),
{
timerId: null
});
},
componentDidMount() {
UserStore.listen(this.onChange);
UserActions.fetchCurrentUser();
if (!this.props.content.digital_work) {
return;
}
@ -51,16 +63,23 @@ let MediaContainer = React.createClass({
window.clearInterval(this.state.timerId);
},
onChange(state) {
this.setState(state);
},
render() {
let thumbnail = this.props.content.thumbnail.thumbnail_sizes && this.props.content.thumbnail.thumbnail_sizes['600x600'] ?
this.props.content.thumbnail.thumbnail_sizes['600x600'] : this.props.content.thumbnail.url_safe;
let mimetype = this.props.content.digital_work.mime;
const { content } = this.props;
const didUserRegisterContent = this.state.currentUser && (this.state.currentUser.username === content.user_registered);
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 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) {
extraData = this.props.content.digital_work.encoding_urls.map(e => { return { url: e.url, type: e.label }; });
if (content.digital_work.encoding_urls) {
extraData = content.digital_work.encoding_urls.map(e => { return { url: e.url, type: e.label }; });
}
if (['video', 'audio'].indexOf(mimetype) > -1) {
@ -76,7 +95,7 @@ let MediaContainer = React.createClass({
panel={
<pre className="">
{'<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>
}/>
);
@ -86,20 +105,21 @@ let MediaContainer = React.createClass({
<MediaPlayer
mimetype={mimetype}
preview={thumbnail}
url={this.props.content.digital_work.url}
url={content.digital_work.url}
extraData={extraData}
encodingStatus={this.props.content.digital_work.isEncoding} />
encodingStatus={content.digital_work.isEncoding} />
<p className="text-center">
<span className="ascribe-social-button-list">
<FacebookShareButton />
<TwitterShareButton />
<TwitterShareButton
text={getLangText('Check out %s ascribed piece', didUserRegisterContent ? 'my latest' : 'this' )} />
</span>
<AclProxy
show={['video', 'audio', 'image'].indexOf(mimetype) === -1 || this.props.content.acl.acl_download}
aclObject={this.props.content.acl}
show={['video', 'audio', 'image'].indexOf(mimetype) === -1 || content.acl.acl_download}
aclObject={content.acl}
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"/>
</Button>
</AclProxy>

View File

@ -19,7 +19,8 @@ let TwitterShareButton = React.createClass({
getDefaultProps() {
return {
count: 'none'
count: 'none',
via: 'ascribeIO'
};
},