Merge branch 'master' of github.com:r888888888/danbooru

This commit is contained in:
Toks
2015-08-30 18:27:02 -04:00
8 changed files with 45 additions and 8 deletions

View File

@@ -77,3 +77,13 @@ $preview_flagged_color: #F00;
text-align: center;
}
@mixin sound-icon {
content: "";
position: absolute;
width: 20px;
height: 20px;
color: white;
background-color: rgba(0,0,0,0.5);
margin: 2px;
text-align: center;
}

View File

@@ -98,7 +98,7 @@ div#c-comments {
}
div.post-preview {
&[data-tags~=animated], &[data-file-ext=swf], &[data-file-ext=webm], &[data-file-ext=zip] {
&[data-tags~=animated], &[data-file-ext=swf], &[data-file-ext=webm], &[data-file-ext=zip], &[data-file-ext=mp4] {
div.preview {
position: relative;
@@ -107,6 +107,16 @@ div#c-comments {
}
}
}
&[data-has-sound=true] {
div.preview {
position: relative;
&:before {
@include sound-icon;
}
}
}
}
div.post {

View File

@@ -29,11 +29,17 @@ div#c-moderator-post-queues {
width: 800px;
}
&[data-tags~=animated], &[data-file-ext=swf], &[data-file-ext=webm], &[data-file-ext=zip] {
&[data-tags~=animated], &[data-file-ext=swf], &[data-file-ext=webm], &[data-file-ext=zip], &[data-file-ext=mp4] {
aside:before {
@include animated-icon;
}
}
&[data-has-sound=true] {
aside:before {
@include sound-icon;
}
}
}
div#moderation-guideline {

View File

@@ -26,9 +26,13 @@ article.post-preview {
margin: auto;
}
&[data-tags~=animated]:before, &[data-file-ext=swf]:before, &[data-file-ext=webm]:before, &[data-file-ext=zip]:before {
&[data-tags~=animated]:before, &[data-file-ext=swf]:before, &[data-file-ext=webm]:before, &[data-file-ext=mp4]:before, &[data-file-ext=zip]:before {
@include animated-icon;
}
&[data-has-sound=true]:before {
@include sound-icon;
}
}
#iqdb-similar {

View File

@@ -25,7 +25,7 @@ module Sources::Strategies
attrs = TwitterService.new.client.status(status_id).attrs
@artist_name = attrs[:user][: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_desc = attrs[:text]
end

View File

@@ -24,7 +24,13 @@ class TwitterService
urls << obj[:media_url] + ":orig"
end
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
urls.uniq
rescue

View File

@@ -85,9 +85,9 @@ class Upload < ActiveRecord::Base
end
end
def validate_no_audio
def tag_audio
if is_video? && video.audio_channels.present?
raise "video must not have audio channels"
self.tag_string = "#{tag_string} video_with_sound"
end
end
@@ -112,7 +112,7 @@ class Upload < ActiveRecord::Base
calculate_hash(file_path)
validate_md5_uniqueness
validate_md5_confirmation
validate_no_audio
tag_audio
validate_video_duration
calculate_file_size(file_path)
if has_dimensions?

View File

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