posts/index: fix search count tracking.
* Eliminate "&ms=1" url param. * Only track simple single-tag searches (not multi-tag searches, metatags, negated tags, etc).
This commit is contained in:
@@ -13,19 +13,14 @@ module PostsHelper
|
|||||||
params[:tags] =~ /order:rank/ || params[:action] =~ /searches|viewed/
|
params[:tags] =~ /order:rank/ || params[:action] =~ /searches|viewed/
|
||||||
end
|
end
|
||||||
|
|
||||||
def missed_post_search_count_js
|
def missed_post_search_count_js(post_set)
|
||||||
return unless post_search_counts_enabled?
|
tags = post_set.query.normalize_query
|
||||||
return unless params[:ms] == "1" && @post_set.post_count == 0 && @post_set.query.is_single_term?
|
sig = generate_reportbooru_signature(tags)
|
||||||
|
|
||||||
sig = generate_reportbooru_signature(params[: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
|
def post_search_count_js(post_set)
|
||||||
return unless post_search_counts_enabled?
|
tags = post_set.query.normalize_query
|
||||||
return unless params[:action] == "index" && params[:page].nil? && params[:tags].present?
|
|
||||||
|
|
||||||
tags = PostQueryBuilder.new(params[:tags]).normalize_query
|
|
||||||
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
|
||||||
|
|||||||
@@ -39,8 +39,6 @@
|
|||||||
<%= render "posts/partials/index/posts", :post_set => @post_set %>
|
<%= render "posts/partials/index/posts", :post_set => @post_set %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= post_search_count_js %>
|
|
||||||
|
|
||||||
<div id="saved-searches-nav">
|
<div id="saved-searches-nav">
|
||||||
<%= render "saved_searches/interface" %>
|
<%= render "saved_searches/interface" %>
|
||||||
</div>
|
</div>
|
||||||
@@ -51,6 +49,14 @@
|
|||||||
<%= 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.post_count == 0 %>
|
||||||
|
<%= missed_post_search_count_js %>
|
||||||
|
<% else %>
|
||||||
|
<%= post_search_count_js %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<% content_for(:html_header) do %>
|
<% content_for(:html_header) do %>
|
||||||
<%= render "posts/partials/index/seo_meta_tags" %>
|
<%= render "posts/partials/index/seo_meta_tags" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -11,6 +11,5 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<%= text_field_tag("tags", tags, :id => tags_dom_id, :"data-shortcut" => "q", :"data-autocomplete" => "tag-query") %>
|
<%= text_field_tag("tags", tags, :id => tags_dom_id, :"data-shortcut" => "q", :"data-autocomplete" => "tag-query") %>
|
||||||
<button id="search-box-submit" type="submit"><i class="fas fa-search"></i></button>
|
<button id="search-box-submit" type="submit"><i class="fas fa-search"></i></button>
|
||||||
<%= hidden_field_tag "ms", "1" %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -10,8 +10,6 @@
|
|||||||
<% atom_feed_tag "Posts: #{@post_set.tag_string}", posts_url(tags: @post_set.tag_string, format: :atom) %>
|
<% atom_feed_tag "Posts: #{@post_set.tag_string}", posts_url(tags: @post_set.tag_string, format: :atom) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= missed_post_search_count_js %>
|
|
||||||
|
|
||||||
<% if @post_set.hide_from_crawler? %>
|
<% if @post_set.hide_from_crawler? %>
|
||||||
<meta name="robots" content="nofollow,noindex">
|
<meta name="robots" content="nofollow,noindex">
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
Reference in New Issue
Block a user