recommendations: add search form, allow searching by username.

This commit is contained in:
evazion
2019-12-02 02:04:46 -06:00
parent ae46f7a665
commit efda9f37e1
11 changed files with 57 additions and 40 deletions

View File

@@ -3,7 +3,7 @@
<%= subnav_link_to "Upload", new_upload_path %>
<%= subnav_link_to "Hot", posts_path(:tags => "order:rank", :d => "1") %>
<% if RecommenderService.available_for_user?(CurrentUser.user) %>
<%= subnav_link_to "Recommended", recommended_posts_path(user_id: CurrentUser.id) %>
<%= subnav_link_to "Recommended", recommended_posts_path(search: { user_name: CurrentUser.name }) %>
<% end %>
<% unless CurrentUser.is_anonymous? %>
<%= subnav_link_to "Favorites", posts_path(tags: "ordfav:#{CurrentUser.user.name}") %>

View File

@@ -0,0 +1,9 @@
<section class="recommended-posts user-disable-cropped-<%= Danbooru.config.enable_image_cropping && CurrentUser.user.disable_cropped_thumbnails? %>">
<% if @recs.empty? %>
No recommendations found.
<% end %>
<% @recs.each do |rec| %>
<%= PostPresenter.preview(rec[:post], recommended: 100*rec[:score]) %>
<% end %>
</section>

View File

@@ -1,3 +0,0 @@
<section class="recommended-posts user-disable-cropped-<%= Danbooru.config.enable_image_cropping && CurrentUser.user.disable_cropped_thumbnails? %>">
<%= PostSets::Recommended.new(@posts).presenter.post_previews_html(self) %>
</section>

View File

@@ -0,0 +1,20 @@
<div id="c-recommended-posts">
<div id="a-index">
<h1>Recommended Posts</h1>
<%= search_form_for(recommended_posts_path) do |f| %>
<%= f.input :user_name, label: "User", input_html: { value: params[:search][:user_name], "data-autocomplete": "user" } %>
<%= f.input :post_id, label: "Post", input_html: { value: params[:search][:post_id] } %>
<%= f.submit "Search" %>
<% end %>
<%= render "posts/partials/common/inline_blacklist" %>
<%= render partial: "index" %>
</div>
</div>
<%= render "posts/partials/common/secondary_links" %>
<% content_for(:page_title) do %>
Recommended Posts - <%= Danbooru.config.app_name %>
<% end %>

View File

@@ -0,0 +1 @@
$("#recommended").html("<%= j render "recommended_posts/index" %>");

View File

@@ -1,16 +0,0 @@
<div id="c-recommended-posts">
<div id="a-show">
<h1>Recommended Posts</h1>
<p>Based on your favorites, you may enjoy these posts. Favorite more posts to get more accurate results. These recommendations update every few hours.</p>
<%= render "posts/partials/common/inline_blacklist" %>
<%= render partial: "show" %>
</div>
</div>
<%= render "posts/partials/common/secondary_links" %>
<% content_for(:page_title) do %>
Recommended Posts - <%= Danbooru.config.app_name %>
<% end %>

View File

@@ -1 +0,0 @@
$("#recommended").html("<%= j render "recommended_posts/show" %>");