fixes #2494: Twitter bookmarklet: support uploading video

This commit is contained in:
r888888888
2015-08-27 14:56:25 -07:00
parent 03bc0ef78b
commit cbe627b01a
8 changed files with 17 additions and 11 deletions

View File

@@ -77,7 +77,7 @@ $preview_flagged_color: #F00;
text-align: center; text-align: center;
} }
@mixin audio-icon { @mixin sound-icon {
content: ""; content: "";
position: absolute; position: absolute;
width: 20px; width: 20px;

View File

@@ -108,12 +108,12 @@ div#c-comments {
} }
} }
&[data-has-audio=true] { &[data-has-sound=true] {
div.preview { div.preview {
position: relative; position: relative;
&:before { &:before {
@include audio-icon; @include sound-icon;
} }
} }
} }

View File

@@ -35,9 +35,9 @@ div#c-moderator-post-queues {
} }
} }
&[data-has-audio=true] { &[data-has-sound=true] {
aside:before { aside:before {
@include audio-icon; @include sound-icon;
} }
} }
} }

View File

@@ -30,8 +30,8 @@ article.post-preview {
@include animated-icon; @include animated-icon;
} }
&[data-has-audio=true]:before { &[data-has-sound=true]:before {
@include audio-icon; @include sound-icon;
} }
} }

View File

@@ -25,7 +25,7 @@ module Sources::Strategies
attrs = TwitterService.new.client.status(status_id).attrs attrs = TwitterService.new.client.status(status_id).attrs
@artist_name = attrs[:user][:name] @artist_name = attrs[:user][:name]
@profile_url = "https://twitter.com/" + attrs[:user][:screen_name] @profile_url = "https://twitter.com/" + attrs[:user][:screen_name]
@image_url = attrs[:entities][:media][0][:media_url] + ":orig" @image_url = image_urls.first
@artist_commentary_title = "" @artist_commentary_title = ""
@artist_commentary_desc = attrs[:text] @artist_commentary_desc = attrs[:text]
end end

View File

@@ -24,7 +24,13 @@ class TwitterService
urls << obj[:media_url] + ":orig" urls << obj[:media_url] + ":orig"
end end
attrs[:extended_entities][:media].each do |obj| attrs[:extended_entities][:media].each do |obj|
urls << obj[:media_url] + ":orig" if obj[:video_info]
largest = obj[:video_info][:variants].select {|x| x[:url] =~ /\.mp4$/}.max_by {|x| x[:bitrate]}
urls.clear
urls << largest[:url] if largest
else
urls << obj[:media_url] + ":orig"
end
end end
urls.uniq urls.uniq
rescue rescue

View File

@@ -87,7 +87,7 @@ class Upload < ActiveRecord::Base
def tag_audio def tag_audio
if is_video? && video.audio_channels.present? if is_video? && video.audio_channels.present?
self.tag_string = "#{tag_string} audio" self.tag_string = "#{tag_string} video_with_sound"
end end
end end

View File

@@ -68,7 +68,7 @@ class PostPresenter < Presenter
def self.data_attributes(post) def self.data_attributes(post)
%{ %{
data-id="#{post.id}" data-id="#{post.id}"
data-has-audio="#{post.has_tag?('audio')}" data-has-sound="#{post.has_tag?('video_with_sound|flash_with_sound')}"
data-tags="#{h(post.tag_string)}" data-tags="#{h(post.tag_string)}"
data-pools="#{post.pool_string}" data-pools="#{post.pool_string}"
data-uploader="#{h(post.uploader_name)}" data-uploader="#{h(post.uploader_name)}"