tweaks to similar posts
This commit is contained in:
@@ -438,6 +438,7 @@
|
||||
$("#comments").show();
|
||||
$("#edit").hide();
|
||||
$("#share").hide();
|
||||
$("#similar").hide();
|
||||
} else if (e.target.hash === "#edit") {
|
||||
$("#edit").show();
|
||||
$("#comments").hide();
|
||||
@@ -445,12 +446,19 @@
|
||||
$("#post_tag_string").focus().selectEnd().height($("#post_tag_string")[0].scrollHeight);
|
||||
$("#related-tags-button").trigger("click");
|
||||
$("#find-artist-button").trigger("click");
|
||||
$("#similar").hide();
|
||||
} else if (e.target.hash === "#similar") {
|
||||
$("#comments").hide();
|
||||
$("#edit").hide();
|
||||
$("#share").hide();
|
||||
$("#similar").show();
|
||||
} else {
|
||||
$("#edit").hide();
|
||||
$("#comments").hide();
|
||||
$("#share").show();
|
||||
addthis.init();
|
||||
}
|
||||
$("#similar").hide();
|
||||
}
|
||||
|
||||
$("#post-sections li").removeClass("active");
|
||||
$(e.target).parent("li").addClass("active");
|
||||
@@ -460,6 +468,9 @@
|
||||
$("#post-sections li:first-child").addClass("active");
|
||||
$("#notes").hide();
|
||||
$("#edit").hide();
|
||||
if ($("#similar").length) {
|
||||
$("#comments").hide();
|
||||
}
|
||||
}
|
||||
|
||||
Danbooru.Post.resize_ugoira_controls = function() {
|
||||
|
||||
@@ -176,7 +176,7 @@ class ApplicationController < ActionController::Base
|
||||
def reset_current_user
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
CurrentUser.root_url = root_url.sub(/\/$/, "")
|
||||
CurrentUser.root_url = root_url
|
||||
end
|
||||
|
||||
def set_started_at_session
|
||||
|
||||
@@ -8,7 +8,7 @@ module PostSets
|
||||
def posts
|
||||
@posts ||= begin
|
||||
response = RecommenderService.similar(@post)
|
||||
post_ids = response.reject {|x| x[0] == @post.id}.slice(0, 5).map {|x| x[0]}
|
||||
post_ids = response.reject {|x| x[0] == @post.id}.slice(0, 6).map {|x| x[0]}
|
||||
::Post.find(post_ids)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,10 +6,16 @@ module RecommenderService
|
||||
end
|
||||
|
||||
def available?(post)
|
||||
return true if Rails.env.development?
|
||||
|
||||
enabled? && CurrentUser.id == 1 && post.created_at > 6.months.ago && post.score >= 10
|
||||
end
|
||||
|
||||
def similar(post)
|
||||
if Danbooru.config.recommender_server == "development"
|
||||
return Post.order("random()").limit(6).map {|x| [x.id, "1.000"]}
|
||||
end
|
||||
|
||||
Cache.get("rss:#{post.id}", 1.day) do
|
||||
resp = HTTParty.get(
|
||||
"#{Danbooru.config.recommender_server}/similar/#{post.id}",
|
||||
|
||||
@@ -82,22 +82,30 @@
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if RecommenderService.available?(@post) %>
|
||||
<%= render "posts/partials/index/similar", post: @post %>
|
||||
<% end %>
|
||||
|
||||
<% if @post.presenter.has_nav_links?(self) %>
|
||||
<%= render "posts/partials/show/nav_links", :post => @post, :position => "bottom" %>
|
||||
<% end %>
|
||||
|
||||
<menu id="post-sections">
|
||||
<% if RecommenderService.available?(@post) %>
|
||||
<li><a href="#similar">Similar</a></li>
|
||||
<% end %>
|
||||
|
||||
<li><a href="#comments">Comments</a></li>
|
||||
|
||||
<% if CurrentUser.is_member? && @post.visible? %>
|
||||
<li><a href="#edit" id="post-edit-link">Edit</a></li>
|
||||
<% end %>
|
||||
|
||||
<li><a href="#share">Share</a></li>
|
||||
</menu>
|
||||
|
||||
<% if RecommenderService.available?(@post) %>
|
||||
<section id="similar">
|
||||
<%= render "posts/partials/index/similar", post: @post %>
|
||||
</section>
|
||||
<% end %>
|
||||
|
||||
<section id="comments">
|
||||
<% if !CurrentUser.user.is_builder? %>
|
||||
<h2>Before commenting, read the <%= link_to "how to comment guide", wiki_pages_path(:search => {:title => "howto:comment"}) %>.</h2>
|
||||
|
||||
Reference in New Issue
Block a user