revamp saved search implementation
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
<meta name="style-usernames" content="<%= CurrentUser.user.style_usernames? %>">
|
||||
<meta name="mobile-mode" content="<%= CurrentUser.mobile_mode? %>">
|
||||
<meta name="last-forum-read-at" content="<%= CurrentUser.user.last_forum_read_at %>">
|
||||
<meta name="disable-categorized-saved-searches" content="<%= CurrentUser.disable_categorized_saved_searches? %>">
|
||||
<meta name="disable-labeled-saved-searches" content="<%= CurrentUser.disable_categorized_saved_searches? %>">
|
||||
<%= auto_discovery_link_tag :atom, posts_path(:format => "atom", :tags => params[:tags]) %>
|
||||
<%= stylesheet_link_tag "application", :media => "screen" %>
|
||||
<% if CurrentUser.user.custom_style.present? %>
|
||||
|
||||
@@ -52,7 +52,11 @@
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<%= render "posts/partials/common/secondary_links" %>
|
||||
<% if params[:tags] =~ /search:/ %>
|
||||
<%= render "saved_searches/secondary_links" %>
|
||||
<% else %>
|
||||
<%= render "posts/partials/common/secondary_links" %>
|
||||
<% end %>
|
||||
|
||||
<%= post_search_count_js %>
|
||||
</div>
|
||||
|
||||
@@ -7,10 +7,6 @@
|
||||
<li><%= link_to "Manage subscriptions", tag_subscriptions_path %></li>
|
||||
<% end %>
|
||||
|
||||
<% if @post_set.is_saved_search? %>
|
||||
<li><%= link_to "Manage saved searches", saved_searches_path %></li>
|
||||
<% end %>
|
||||
|
||||
<li><%= link_to "Random post", random_posts_path(:tags => params[:tags]), :id => "random-post", :rel => "nofollow" %></li>
|
||||
|
||||
<li><%= link_to "Mobile version", mobile_posts_path(:tags => params[:tags]) %></li>
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
<div id="c-saved-searches">
|
||||
<div id="a-edit">
|
||||
<h1>Change Category</h1>
|
||||
|
||||
<%= form_tag(saved_search_category_change_path, :class => "simple_form") do %>
|
||||
<div class="input">
|
||||
<label for="old">Old Category</label>
|
||||
<%= text_field_tag "old", params[:old] %>
|
||||
</div>
|
||||
|
||||
<div class="input">
|
||||
<label for="new">New Category</label>
|
||||
<%= text_field_tag "new" %>
|
||||
</div>
|
||||
|
||||
<%= submit_tag %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= render "saved_searches/secondary_links" %>
|
||||
|
||||
<% content_for(:page_title) do %>
|
||||
Edit Category - <%= Danbooru.config.app_name %>
|
||||
<% end %>
|
||||
@@ -8,12 +8,11 @@
|
||||
<%= hidden_field_tag "saved_search_tags", params[:tags] %>
|
||||
|
||||
<div class="input">
|
||||
<label>
|
||||
<%= text_field_tag "saved_search_category", "", :placeholder => "Category" %>
|
||||
</label>
|
||||
<label for="saved_search_labels">Label</label>
|
||||
<%= text_field_tag "saved_search_labels", "" %>
|
||||
</div>
|
||||
|
||||
<p><label><%= check_box_tag "saved_search_disable_categories" %> Disable categorization</label></p>
|
||||
<p><label><%= check_box_tag "saved_search_disable_labels" %> Disable labels</label></p>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -1,6 +1,6 @@
|
||||
<% content_for(:secondary_links) do %>
|
||||
<menu>
|
||||
<li><%= link_to "Gallery", posts_path(:tags => "search:all") %></li>
|
||||
<li><%= link_to "Listing", saved_searches_path %></li>
|
||||
<li><%= link_to "View posts", posts_path(:tags => "search:all") %></li>
|
||||
<li><%= link_to "Manage saved searches", saved_searches_path %></li>
|
||||
</menu>
|
||||
<% end %>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<% if @saved_search.errors.any? %>
|
||||
Danbooru.error("<%= j @saved_search.errors.full_messages.join(', ') %>");
|
||||
<% else %>
|
||||
Danbooru.notice("Search '<%= j @saved_search.tag_query %>' was saved");
|
||||
Danbooru.notice("Search '<%= j @saved_search.query %>' was saved");
|
||||
<% end %>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Danbooru.notice("Search '<%= j @saved_search.tag_query %>' was deleted");
|
||||
Danbooru.notice("Search '<%= j @saved_search.query %>' was deleted");
|
||||
$("#saved-searches-nav").html("<%= j render('saved_searches/interface', :saved_searches => CurrentUser.user.saved_searches) %>");
|
||||
Danbooru.Post.initialize_saved_searches();
|
||||
$("#saved-search-<%= @saved_search.id %>").remove();
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
<%= error_messages_for :saved_search %>
|
||||
|
||||
<%= simple_form_for(@saved_search) do |f| %>
|
||||
<%= f.input :tag_query %>
|
||||
<%= f.input :category %>
|
||||
<%= f.button :submit, :data => { :disable_with => "Submitting..." } %>
|
||||
<%= f.input :query %>
|
||||
<%= f.input :label_string, :label => "Labels", :hint => "A list of tags to help categorize this search. Space delimited." %>
|
||||
<%= f.button :submit, :value => "Submit", :data => { :disable_with => "Submitting..." } %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,37 +1,38 @@
|
||||
<div id="c-saved-searches">
|
||||
<div id="a-index">
|
||||
<h1>Saved Searches</h1>
|
||||
<h1>
|
||||
Saved Searches
|
||||
<% if params[:label] %>
|
||||
(<%= params[:label] %>)
|
||||
<% end %>
|
||||
</h1>
|
||||
|
||||
<% @categories.each do |category, saved_searches| %>
|
||||
<h2>
|
||||
<% if category.present? %>
|
||||
<%= link_to_if SavedSearch.posts_search_available?, category.tr("_", " "), posts_path(:tags => "search:#{category}") %>
|
||||
(<%= link_to "rename", new_saved_search_category_change_path(:old => category) %>)
|
||||
<% else %>
|
||||
<%= link_to_if SavedSearch.posts_search_available?, SavedSearch::UNCATEGORIZED_NAME, posts_path(:tags => "search:#{SavedSearch::UNCATEGORIZED_NAME}") %>
|
||||
<% end %>
|
||||
</h2>
|
||||
<table class="striped" width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="80%">Tags</th>
|
||||
<th width="20%"></th>
|
||||
<table class="striped" width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="60%">Query</th>
|
||||
<th width="20%">Labels</th>
|
||||
<th width="20%" class="links"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @saved_searches.each do |ss| %>
|
||||
<tr id="saved-search-<%= ss.id %>">
|
||||
<td><%= link_to ss.query, posts_path(:tags => ss.query) %></td>
|
||||
<td>
|
||||
<% ss.labels.each do |label| %>
|
||||
<%= link_to label, posts_path(:tags => "search:#{label}") %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="links">
|
||||
<%= link_to "edit", edit_saved_search_path(ss) %>
|
||||
| <%= link_to "delete", saved_search_path(ss), :method => :delete, :remote => true %>
|
||||
</td>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% saved_searches.each do |saved_search| %>
|
||||
<tr id="saved-search-<%= saved_search.id %>">
|
||||
<td><%= link_to saved_search.tag_query, posts_path(:tags => saved_search.tag_query) %></td>
|
||||
<td>
|
||||
<%= link_to "edit", edit_saved_search_path(saved_search) %>
|
||||
| <%= link_to "delete", saved_search_path(saved_search), :method => :delete, :remote => true %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -30,30 +30,17 @@
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% presenter.subscriptions.each do |subscription| %>
|
||||
<div class="box user-subscription" data-name="<%= subscription.name %>">
|
||||
<h2>
|
||||
Subscription: <%= link_to subscription.pretty_name, posts_path(:tags => "sub:#{user.name}:#{subscription.name}") %>
|
||||
</h2>
|
||||
|
||||
<div class="box">
|
||||
<% presenter.posts_for_subscription(subscription).each do |post| %>
|
||||
<%= PostPresenter.preview(post, :tags => "sub:#{user.name}:#{subscription.name}") %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if CurrentUser.user.id == @user.id && @user.has_saved_searches? && @user.is_gold? %>
|
||||
<% presenter.saved_search_categories.each do |category| %>
|
||||
<div class="box user-saved-search" data-category="<%= category %>">
|
||||
<% presenter.saved_search_labels.each do |label| %>
|
||||
<div class="box user-saved-search" data-label="<%= label %>">
|
||||
<h2>
|
||||
Saved Search: <%= link_to category, posts_path(:tags => "search:#{category}") %>
|
||||
Saved Search: <%= link_to label, posts_path(:tags => "search:#{label}") %>
|
||||
(<%= link_to "manage", saved_searches_path(label: label) %>)
|
||||
</h2>
|
||||
|
||||
<div class="box">
|
||||
<% presenter.posts_for_saved_search_category(category).each do |post| %>
|
||||
<%= PostPresenter.preview(post, :tags => "search:#{category}") %>
|
||||
<% presenter.posts_for_saved_search_category(label).each do |post| %>
|
||||
<%= PostPresenter.preview(post, :tags => "search:#{label}") %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -122,19 +122,6 @@
|
||||
<th>Feedback</th>
|
||||
<td><%= presenter.feedbacks(self) %></td> </tbody>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th>Subscriptions</th>
|
||||
<td>
|
||||
<% presenter.subscriptions.each do |subscription| %>
|
||||
<p>
|
||||
<strong><%= link_to subscription.pretty_name, posts_path(:tags => "sub:#{user.name}:#{subscription.name}") %></strong>
|
||||
–
|
||||
<%= presenter.tag_links_for_subscription(self, subscription) %>
|
||||
</p>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<% if presenter.previous_names(self).present? %>
|
||||
<tr>
|
||||
@@ -148,13 +135,26 @@
|
||||
<tr>
|
||||
<th>Saved Searches</th>
|
||||
<td>
|
||||
<% SavedSearch.categories_for(CurrentUser.user).each do |category| %>
|
||||
<p><%= link_to category, posts_path(tags: "search:#{category}") %></p>
|
||||
<% SavedSearch.labels_for(CurrentUser.user.id).each do |label| %>
|
||||
<%= link_to label, posts_path(tags: "search:#{label}") %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
<tr>
|
||||
<th>Subscriptions</th>
|
||||
<td>
|
||||
<% presenter.subscriptions.each do |subscription| %>
|
||||
<p>
|
||||
<strong><%= link_to subscription.pretty_name, posts_path(:tags => "sub:#{user.name}:#{subscription.name}") %></strong>
|
||||
–
|
||||
<%= presenter.tag_links_for_subscription(self, subscription) %>
|
||||
</p>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th>API Key</th>
|
||||
<td>
|
||||
|
||||
Reference in New Issue
Block a user