config: remove enable_post_search_counts option.
Enable by default if reportbooru is configured, otherwise disable.
This commit is contained in:
@@ -5,8 +5,8 @@ module PostsHelper
|
|||||||
end.join("").html_safe
|
end.join("").html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
def post_search_counts_enabled?
|
def reportbooru_enabled?
|
||||||
Danbooru.config.enable_post_search_counts && Danbooru.config.reportbooru_server.present? && Danbooru.config.reportbooru_key.present?
|
Danbooru.config.reportbooru_server.present? && Danbooru.config.reportbooru_key.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def discover_mode?
|
def discover_mode?
|
||||||
@@ -14,17 +14,21 @@ module PostsHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def missed_post_search_count_js(tags)
|
def missed_post_search_count_js(tags)
|
||||||
|
return unless reportbooru_enabled?
|
||||||
|
|
||||||
sig = generate_reportbooru_signature(tags)
|
sig = generate_reportbooru_signature(tags)
|
||||||
render "posts/partials/index/missed_search_count", sig: sig
|
render "posts/partials/index/missed_search_count", sig: sig
|
||||||
end
|
end
|
||||||
|
|
||||||
def post_search_count_js(tags)
|
def post_search_count_js(tags)
|
||||||
|
return unless reportbooru_enabled?
|
||||||
|
|
||||||
sig = generate_reportbooru_signature("ps-#{tags}")
|
sig = generate_reportbooru_signature("ps-#{tags}")
|
||||||
render "posts/partials/index/search_count", sig: sig
|
render "posts/partials/index/search_count", sig: sig
|
||||||
end
|
end
|
||||||
|
|
||||||
def post_view_count_js
|
def post_view_count_js
|
||||||
return unless post_search_counts_enabled?
|
return unless reportbooru_enabled?
|
||||||
|
|
||||||
msg = generate_reportbooru_signature(params[:id])
|
msg = generate_reportbooru_signature(params[:id])
|
||||||
render "posts/partials/show/view_count", msg: msg
|
render "posts/partials/show/view_count", msg: msg
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
<%= render "posts/partials/common/secondary_links" %>
|
<%= render "posts/partials/common/secondary_links" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if post_search_counts_enabled? && @post_set.query.is_simple_tag? && @post_set.current_page == 1 %>
|
<% if @post_set.query.is_simple_tag? && @post_set.current_page == 1 %>
|
||||||
<% if @post_set.post_count == 0 %>
|
<% if @post_set.post_count == 0 %>
|
||||||
<%= missed_post_search_count_js(@post_set.query.to_s) %>
|
<%= missed_post_search_count_js(@post_set.query.to_s) %>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
|||||||
@@ -440,12 +440,6 @@ module Danbooru
|
|||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
# Enables recording of popular searches, missed searches, and post view
|
|
||||||
# counts. Requires Reportbooru to be configured and running - see below.
|
|
||||||
def enable_post_search_counts
|
|
||||||
false
|
|
||||||
end
|
|
||||||
|
|
||||||
# reportbooru options - see https://github.com/r888888888/reportbooru
|
# reportbooru options - see https://github.com/r888888888/reportbooru
|
||||||
def reportbooru_server
|
def reportbooru_server
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user