integrate with ccs
This commit is contained in:
2
.env
2
.env
@@ -80,3 +80,5 @@
|
|||||||
# export DANBOORU_AWS_SQS_REGION=
|
# export DANBOORU_AWS_SQS_REGION=
|
||||||
# export DANBOORU_IQDBS_AUTH_KEY=
|
# export DANBOORU_IQDBS_AUTH_KEY=
|
||||||
# export DANBOORU_IQDBS_SERVER=
|
# export DANBOORU_IQDBS_SERVER=
|
||||||
|
# export DANBOORU_CCS_SERVER=
|
||||||
|
# export DANBOORU_CCS_KEY=
|
||||||
@@ -150,6 +150,31 @@
|
|||||||
}
|
}
|
||||||
$dest.append(Danbooru.RelatedTag.build_html("artist", tags, "artist", true));
|
$dest.append(Danbooru.RelatedTag.build_html("artist", tags, "artist", true));
|
||||||
}
|
}
|
||||||
|
if (Danbooru.meta("ccs-server")) {
|
||||||
|
if (Danbooru.RelatedTag.recent_ccs) {
|
||||||
|
if (Danbooru.RelatedTag.recent_ccs.length) {
|
||||||
|
Danbooru.RelatedTag.build_ccs($dest);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Danbooru.RelatedTag.recent_ccs = []; // semaphore to only make 1 call
|
||||||
|
Danbooru.RelatedTag.fetch_ccs($dest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Danbooru.RelatedTag.fetch_ccs = function($dest) {
|
||||||
|
$.getJSON(Danbooru.meta("ccs-server") + "/query", {
|
||||||
|
"url": Danbooru.meta("image-url"),
|
||||||
|
"ref": Danbooru.meta("image-ref"),
|
||||||
|
"sig": Danbooru.meta("image-sig")
|
||||||
|
}, function(data) {
|
||||||
|
Danbooru.RelatedTag.recent_ccs = data.filter(function(x) {return x[0] > 0.25;});
|
||||||
|
Danbooru.RelatedTag.recent_ccs = $.map(Danbooru.RelatedTag.recent_ccs, function(x) {return [[x[1], 4]];});
|
||||||
|
|
||||||
|
if (Danbooru.RelatedTag.recent_ccs.length) {
|
||||||
|
Danbooru.RelatedTag.build_ccs($dest);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Danbooru.RelatedTag.build_recent_and_frequent = function($dest) {
|
Danbooru.RelatedTag.build_recent_and_frequent = function($dest) {
|
||||||
@@ -174,6 +199,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Danbooru.RelatedTag.build_ccs = function($dest) {
|
||||||
|
if (Danbooru.RelatedTag.recent_ccs) {
|
||||||
|
$dest.append(this.build_html("Guessed Characters", Danbooru.RelatedTag.recent_ccs, "ccs"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Danbooru.RelatedTag.build_translated = function($dest) {
|
Danbooru.RelatedTag.build_translated = function($dest) {
|
||||||
if (Danbooru.RelatedTag.translated_tags && Danbooru.RelatedTag.translated_tags.length) {
|
if (Danbooru.RelatedTag.translated_tags && Danbooru.RelatedTag.translated_tags.length) {
|
||||||
$dest.append(this.build_html("Translated Tags", Danbooru.RelatedTag.translated_tags, "translated"));
|
$dest.append(this.build_html("Translated Tags", Danbooru.RelatedTag.translated_tags, "translated"));
|
||||||
|
|||||||
9
app/helpers/uploads_helper.rb
Normal file
9
app/helpers/uploads_helper.rb
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
module UploadsHelper
|
||||||
|
def ccs_build_sig(url)
|
||||||
|
return nil unless Danbooru.config.ccs_server.present?
|
||||||
|
|
||||||
|
ref = ImageProxy.fake_referer_for(url)
|
||||||
|
digest = OpenSSL::Digest.new("sha256")
|
||||||
|
OpenSSL::HMAC.hexdigest(digest, Danbooru.config.ccs_key, "#{url},#{ref}")
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -31,6 +31,7 @@ module Sources::Strategies
|
|||||||
@tags = attrs[:entities][:hashtags].map do |text:, indices:|
|
@tags = attrs[:entities][:hashtags].map do |text:, indices:|
|
||||||
[text, "https://twitter.com/hashtag/#{text}"]
|
[text, "https://twitter.com/hashtag/#{text}"]
|
||||||
end
|
end
|
||||||
|
rescue Twitter::Error::Forbidden
|
||||||
end
|
end
|
||||||
|
|
||||||
def image_urls
|
def image_urls
|
||||||
|
|||||||
@@ -141,4 +141,13 @@
|
|||||||
Upload - <%= Danbooru.config.app_name %>
|
Upload - <%= Danbooru.config.app_name %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<% if CurrentUser.is_moderator? && Danbooru.config.ccs_server.present? && @normalized_url %>
|
||||||
|
<% content_for(:html_header) do %>
|
||||||
|
<%= tag("meta", name: "ccs-server", content: Danbooru.config.ccs_server) %>
|
||||||
|
<%= tag("meta", name: "image-url", content: @normalized_url) %>
|
||||||
|
<%= tag("meta", name: "image-ref", content: ImageProxy.fake_referer_for(@normalized_url)) %>
|
||||||
|
<%= tag("meta", name: "image-sig", content: ccs_build_sig(@normalized_url)) %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<%= render "posts/partials/common/secondary_links" %>
|
<%= render "posts/partials/common/secondary_links" %>
|
||||||
|
|||||||
Reference in New Issue
Block a user