if (e.button === 0) {
e.preventDefault();
hashHistory.push(`/accounts/${id}`);
- e.stopPropagation();
}
+
+ e.stopPropagation();
},
render () {
);
}.bind(this));
+ const noMoreAllowed = (this.props.media.some(m => m.get('type') === 'video')) || (this.props.media.size > 3);
+
return (
<div style={{ marginBottom: '20px', padding: '10px', paddingTop: '0' }}>
- <UploadButton onSelectFile={this.props.onSelectFile} disabled={this.props.is_uploading || this.props.media.size > 3} />
+ <UploadButton onSelectFile={this.props.onSelectFile} disabled={this.props.is_uploading || noMoreAllowed } />
<div style={{ marginTop: '10px', overflow: 'hidden' }}>
{uploads}
import { fetchStatus } from '../../actions/statuses';
import Immutable from 'immutable';
import EmbeddedStatus from '../../components/status';
+import { favourite, reblog } from '../../actions/interactions';
+import { replyCompose } from '../../actions/compose';
function selectStatus(state, id) {
let status = state.getIn(['timelines', 'statuses', id]);
}
},
+ handleFavouriteClick (status) {
+ this.props.dispatch(favourite(status));
+ },
+
+ handleReplyClick (status) {
+ this.props.dispatch(replyCompose(status));
+ },
+
+ handleReblogClick (status) {
+ this.props.dispatch(reblog(status));
+ },
+
renderChildren (list) {
- return list.map(s => <EmbeddedStatus status={s} key={s.get('id')} />);
+ return list.map(s => <EmbeddedStatus status={s} key={s.get('id')} onReply={this.handleReplyClick} onFavourite={this.handleFavouriteClick} onReblog={this.handleReblogClick} />);
},
render () {
return (
<div>
{this.renderChildren(ancestors)}
- <EmbeddedStatus status={status} />
+ <EmbeddedStatus status={status} onReply={this.handleReplyClick} onFavourite={this.handleFavouriteClick} onReblog={this.handleReblogClick} />
{this.renderChildren(descendants)}
</div>
);
--- /dev/null
+class MediaController < ApplicationController
+ before_action :set_media_attachment
+
+ def show
+ redirect TagManager.instance.url_for(@media_attachment.status)
+ end
+
+ private
+
+ def set_media_attachment
+ @media_attachment = MediaAttachment.where.not(status_id: nil).find(params[:id])
+ end
+end
belongs_to :account, inverse_of: :media_attachments
belongs_to :status, inverse_of: :media_attachments
- has_attached_file :file, styles: lambda { |f| f.instance.image? ? { small: '510x680>' } : { small: { format: 'webm' } } }, processors: lambda { |f| f.video? ? [:transcoder] : [:thumbnail] }
+ has_attached_file :file, styles: lambda { |f| f.instance.image? ? { small: '510x680>' } : { small: { convert_options: { output: { vf: 'scale="min(510\, iw):min(680\, ih)":force_original_aspect_ratio=decrease' } }, format: 'png', time: 1 } } }, processors: lambda { |f| f.video? ? [:transcoder] : [:thumbnail] }
validates_attachment_content_type :file, content_type: IMAGE_MIME_TYPES + VIDEO_MIME_TYPES
validates_attachment_size :file, less_than: 4.megabytes
def video?
VIDEO_MIME_TYPES.include? file_content_type
end
+
+ def type
+ image? ? 'image' : 'video'
+ end
end
object @media
-attribute :id
+attribute :id, :type
node(:url) { |media| full_asset_url(media.file.url) }
node(:preview_url) { |media| full_asset_url(media.file.url(:small)) }
+node(:text_url) { |media| medium_url(media) }
end
resource :settings, only: [:show, :update]
+ resources :media, only: [:show]
namespace :api do
# PubSubHubbub