remove post view counts, add search counts

This commit is contained in:
r888888888
2015-07-27 17:21:17 -07:00
parent fdc62b0e07
commit f87c71cf23
14 changed files with 93 additions and 170 deletions

View File

@@ -1,15 +1,17 @@
module PostsHelper
def post_view_count_js
return nil unless Danbooru.config.enable_view_counts
def post_search_count_js
return nil unless Danbooru.config.enable_post_search_counts
if action_name == "index"
return nil
elsif action_name == "show"
key = "show-#{params[:id]}"
value = session.id
digest = OpenSSL::Digest.new("sha256")
sig = OpenSSL::HMAC.hexdigest(digest, Danbooru.config.shared_remote_key, "#{key},#{value}")
return render("posts/partials/show/view_count", key: key, value: value, sig: sig)
if action_name == "index" && params[:page].nil?
tags = Tag.scan_query(params[:tags]).sort.join(" ")
if tags.present?
key = "ps-#{tags}"
value = session.id
digest = OpenSSL::Digest.new("sha256")
sig = OpenSSL::HMAC.hexdigest(digest, Danbooru.config.shared_remote_key, "#{key},#{value}")
return render("posts/partials/index/search_count", key: key, value: value, sig: sig)
end
end
return nil