Remove /meta_searches/tags page.

This was a search page that let you search for tags, aliases, and
implications at the same time. It never got much use and it's been
broken for a while now (the search form passed the wrong param to the
controller).
This commit is contained in:
evazion
2020-01-07 11:10:56 -06:00
parent 2aa3ced372
commit 1ab6a353ca
11 changed files with 1 additions and 212 deletions

View File

@@ -1,6 +0,0 @@
class MetaSearchesController < ApplicationController
def tags
@meta_search = MetaSearches::Tag.new(params)
@meta_search.load_all
end
end

View File

@@ -304,7 +304,7 @@ module ApplicationHelper
when "artists", "artist_versions"
/^\/artist/
when "tags", "meta_searches"
when "tags"
/^\/tags/
when "pools", "pool_versions"

View File

@@ -1,30 +0,0 @@
class MetaSearches::Tag
MAX_RESULTS = 25
attr_reader :search_params, :tags, :tag_aliases, :tag_implications
def initialize(search_params)
@search_params = search_params
end
def load_all
load_tags
load_tag_aliases
load_tag_implications
end
def load_tags
@tags = ::Tag.name_matches(name_param).limit(MAX_RESULTS)
end
def load_tag_aliases
@tag_aliases = TagAlias.name_matches(name_param).limit(MAX_RESULTS)
end
def load_tag_implications
@tag_implications = TagImplication.name_matches(name_param).limit(MAX_RESULTS)
end
def name_param
search_params[:name] || ""
end
end

View File

@@ -1,122 +0,0 @@
<div id="c-meta-searches">
<div id="a-tags">
<h1>MetaSearch Tags</h1>
<section>
<%= search_form_for(meta_searches_tags_path) do |f| %>
<%= f.input :name, input_html: { value: params.dig(:search, :name), "data-autocomplete": "tag" } %>
<%= f.submit "Search" %>
<% end %>
</section>
<section>
<h2>Tags</h2>
<% if @meta_search.tags.empty? %>
<p>No results</p>
<% else %>
<table width="100%" class="striped">
<thead>
<tr>
<th>Name</th>
<th>Count</th>
<th></th>
</tr>
</thead>
<tbody>
<% @meta_search.tags.each do |tag| %>
<tr>
<td><%= tag.name %></td>
<td><%= tag.post_count %></td>
<td>
<% if tag.editable_by?(CurrentUser.user) %>
<%= link_to "edit", edit_tag_path(tag) %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
</section>
<section>
<h2>Tag Aliases</h2>
<% if @meta_search.tag_aliases.empty? %>
<p>No results</p>
<% else %>
<table width="100%" class="striped">
<thead>
<tr>
<th>From</th>
<th>To</th>
<th></th>
</tr>
</thead>
<tbody>
<% @meta_search.tag_aliases.each do |tag_alias| %>
<tr>
<td><%= tag_alias.antecedent_name %></td>
<td><%= tag_alias.consequent_name %></td>
<td>
<%= link_to "Show", tag_alias_path(tag_alias) %>
<% if tag_alias.deletable_by?(CurrentUser.user) %>
| <%= link_to "Delete", tag_alias_path(tag_alias), :remote => true, :method => :delete, :data => {:confirm => "Are you sure you want to delete this alias?"} %>
<% end %>
<% if CurrentUser.is_admin? && tag_alias.is_pending? %>
| <%= link_to "Approve", approve_tag_alias_path(tag_alias), :remote => true, :method => :post %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
</section>
<section>
<h2>Tag Implications</h2>
<% if @meta_search.tag_implications.empty? %>
<p>No results</p>
<% else %>
<table width="100%" class="striped">
<thead>
<tr>
<th>From</th>
<th>To</th>
<th></th>
</tr>
</thead>
<tbody>
<% @meta_search.tag_implications.each do |tag_implication| %>
<tr>
<td><%= tag_implication.antecedent_name %></td>
<td><%= tag_implication.consequent_name %></td>
<td>
<%= link_to "Show", tag_implication_path(tag_implication) %>
<% if tag_implication.deletable_by?(CurrentUser.user) %>
| <%= link_to "Delete", tag_implication_path(tag_implication), :remote => true, :method => :delete, :data => {:confirm => "Are you sure you want to delete this implication?"} %>
<% end %>
<% if CurrentUser.user.is_admin? && tag_implication.is_pending? %>
| <%= link_to "Approve", approve_tag_implication_path(tag_implication), :remote => true, :method => :post %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
</section>
</div>
</div>
<%= render "tags/secondary_links" %>
<% content_for(:page_title) do %>
MetaSearch - Tags - <%= Danbooru.config.app_name %>
<% end %>

View File

@@ -54,7 +54,6 @@
<li><%= link_to("Aliases", tag_aliases_path) %></li>
<li><%= link_to("Implications", tag_implications_path) %></li>
<li><%= link_to("Listing", tags_path) %></li>
<li><%= link_to("Search", meta_searches_tags_path) %></li>
</ul>
<ul>
<li><h1>Notes</h1></li>

View File

@@ -1,6 +1,5 @@
<% content_for(:secondary_links) do %>
<%= subnav_link_to "Listing", tag_aliases_path %>
<%= subnav_link_to "MetaSearch", meta_searches_tags_path %>
<%= subnav_link_to "Request alias", new_bulk_update_request_path %>
<%= subnav_link_to "Help", wiki_page_path("help:tag_aliases") %>
<% end %>

View File

@@ -1,6 +1,5 @@
<% content_for(:secondary_links) do %>
<%= subnav_link_to "Listing", tag_implications_path %>
<%= subnav_link_to "MetaSearch", meta_searches_tags_path %>
<%= subnav_link_to "Request implication", new_bulk_update_request_path %>
<%= subnav_link_to "Help", wiki_page_path("help:tag_implications") %>
<% end %>

View File

@@ -1,7 +1,6 @@
<% content_for(:secondary_links) do %>
<%= quick_search_form_for(:name_matches, tags_path, "tags", autocomplete: "tag") %>
<%= subnav_link_to "Listing", tags_path %>
<%= subnav_link_to "MetaSearch", meta_searches_tags_path %>
<%= subnav_link_to "Related tags", related_tag_path %>
<%= subnav_link_to "Cheatsheet", wiki_page_path("help:cheatsheet") %>
<%= subnav_link_to "Help", wiki_page_path("help:tags") %>

View File

@@ -402,7 +402,6 @@ Rails.application.routes.draw do
get "/static/terms_of_service" => "static#terms_of_service", :as => "terms_of_service"
get "/static/contact" => "static#contact", :as => "contact"
get "/static/dtext_help" => "static#dtext_help", :as => "dtext_help"
get "/meta_searches/tags" => "meta_searches#tags", :as => "meta_searches_tags"
get "/intro" => redirect("/explore/posts/intro")

View File

@@ -1,12 +0,0 @@
require 'test_helper'
class MetaSearchesControllerTest < ActionDispatch::IntegrationTest
context "The meta searches controller" do
context "tags action" do
should "work" do
get meta_searches_tags_path, params: {name: "long_hair"}
assert_response :success
end
end
end
end

View File

@@ -1,36 +0,0 @@
require "test_helper"
module MetaSearches
class TagTest < ActionMailer::TestCase
context "The tag metasearch" do
setup do
CurrentUser.user = FactoryBot.create(:user)
CurrentUser.ip_addr = "127.0.0.1"
FactoryBot.create(:post, :tag_string => "xxx")
FactoryBot.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb")
FactoryBot.create(:tag_implication, :antecedent_name => "ccc", :consequent_name => "ddd")
end
should "find the tag" do
meta_search = MetaSearches::Tag.new(:name => "xxx")
meta_search.load_all
assert_equal(1, meta_search.tags.size)
assert_equal("xxx", meta_search.tags.first.name)
end
should "find the alias" do
meta_search = MetaSearches::Tag.new(:name => "aaa")
meta_search.load_all
assert_equal(1, meta_search.tag_aliases.size)
assert_equal("aaa", meta_search.tag_aliases.first.antecedent_name)
end
should "find the implication" do
meta_search = MetaSearches::Tag.new(:name => "ccc")
meta_search.load_all
assert_equal(1, meta_search.tag_implications.size)
assert_equal("ccc", meta_search.tag_implications.first.antecedent_name)
end
end
end
end