diff --git a/app/controllers/artist_commentaries_controller.rb b/app/controllers/artist_commentaries_controller.rb deleted file mode 100644 index 5d5b7161a..000000000 --- a/app/controllers/artist_commentaries_controller.rb +++ /dev/null @@ -1,41 +0,0 @@ -class ArtistCommentariesController < ApplicationController - respond_to :html, :json, :js - before_action :admin_only - - def index - @commentaries = ArtistCommentary.search(search_params).paginate(params[:page], :limit => params[:limit]) - respond_with(@commentaries) - end - - def show - if params[:id] - @commentary = ArtistCommentary.find(params[:id]) - else - @commentary = ArtistCommentary.find_by_post_id!(params[:post_id]) - end - - respond_with(@commentary) do |format| - format.html { redirect_to post_path(@commentary.post) } - end - end - - def create_or_update - @artist_commentary = ArtistCommentary.find_or_initialize_by(post_id: params.dig(:artist_commentary, :post_id)) - @artist_commentary.update(commentary_params) - respond_with(@artist_commentary) - end - - def revert - @artist_commentary = ArtistCommentary.find_by_post_id!(params[:id]) - @version = @artist_commentary.versions.find(params[:version_id]) - @artist_commentary.revert_to!(@version) - end - -private - - def commentary_params - params.fetch(:artist_commentary, {}).except(:post_id).permit(%i[ - original_description original_title translated_description translated_title - ]) - end -end diff --git a/app/controllers/artist_commentary_versions_controller.rb b/app/controllers/artist_commentary_versions_controller.rb deleted file mode 100644 index fc2c3f91e..000000000 --- a/app/controllers/artist_commentary_versions_controller.rb +++ /dev/null @@ -1,9 +0,0 @@ -class ArtistCommentaryVersionsController < ApplicationController - respond_to :html, :json - before_action :admin_only - - def index - @commentary_versions = ArtistCommentaryVersion.search(search_params).paginate(params[:page], :limit => params[:limit]) - respond_with(@commentary_versions) - end -end diff --git a/app/javascript/src/javascripts/autocomplete.js.erb b/app/javascript/src/javascripts/autocomplete.js.erb index 86eb116c5..e3aec4a0e 100644 --- a/app/javascript/src/javascripts/autocomplete.js.erb +++ b/app/javascript/src/javascripts/autocomplete.js.erb @@ -103,7 +103,6 @@ Autocomplete.initialize_tag_autocomplete = function() { case "comm": case "noter": case "noteupdater": - case "artcomm": case "fav": case "favoritedby": case "appealer": diff --git a/app/javascript/src/javascripts/uploads.js b/app/javascript/src/javascripts/uploads.js index dd624cda8..4100dc3fd 100644 --- a/app/javascript/src/javascripts/uploads.js +++ b/app/javascript/src/javascripts/uploads.js @@ -16,11 +16,6 @@ Upload.initialize_all = function() { } this.initialize_similar(); this.initialize_submit(); - - $("#toggle-artist-commentary").on("click.danbooru", function(e) { - Upload.toggle_commentary(); - e.preventDefault(); - }); } if ($("#iqdb-similar").length) { @@ -95,16 +90,6 @@ Upload.initialize_image = function() { $("#image-resize-to-window-link").on("click.danbooru", Upload.update_scale); } -Upload.toggle_commentary = function() { - if ($(".artist-commentary").is(":visible")) { - $("#toggle-artist-commentary").text("show »"); - } else { - $("#toggle-artist-commentary").text("« hide"); - } - - $(".artist-commentary").slideToggle(); -}; - $(function() { Upload.initialize_all(); }); diff --git a/app/logical/post_query_builder.rb b/app/logical/post_query_builder.rb index 508b1e06d..1780f317b 100644 --- a/app/logical/post_query_builder.rb +++ b/app/logical/post_query_builder.rb @@ -421,14 +421,6 @@ class PostQueryBuilder when "note_asc" relation = relation.order("posts.last_noted_at ASC NULLS FIRST") - when "artcomm" - relation = relation.joins("INNER JOIN artist_commentaries ON artist_commentaries.post_id = posts.id") - relation = relation.order("artist_commentaries.updated_at DESC") - - when "artcomm_asc" - relation = relation.joins("INNER JOIN artist_commentaries ON artist_commentaries.post_id = posts.id") - relation = relation.order("artist_commentaries.updated_at ASC") - when "mpixels", "mpixels_desc" relation = relation.where(Arel.sql("posts.image_width is not null and posts.image_height is not null")) # Use "w*h/1000000", even though "w*h" would give the same result, so this can use diff --git a/app/models/artist_commentary.rb b/app/models/artist_commentary.rb deleted file mode 100644 index 2632d4a7d..000000000 --- a/app/models/artist_commentary.rb +++ /dev/null @@ -1,139 +0,0 @@ -class ArtistCommentary < ApplicationRecord - class RevertError < Exception ; end - - before_validation :trim_whitespace - validates :post_id, uniqueness: true - validates :original_title, length: { maximum: 150 } - validates :translated_title, length: { maximum: 150 } - validates :original_description, length: { maximum: Danbooru.config.wiki_page_max_size } - validates :translated_description, length: { maximum: Danbooru.config.wiki_page_max_size } - belongs_to :post, required: true - has_many :versions, -> {order("artist_commentary_versions.id ASC")}, :class_name => "ArtistCommentaryVersion", :dependent => :destroy, :foreign_key => :post_id, :primary_key => :post_id - has_one :previous_version, -> {order(id: :desc)}, :class_name => "ArtistCommentaryVersion", :foreign_key => :post_id, :primary_key => :post_id - after_save :create_version - - module SearchMethods - def text_matches(query) - query = "*#{query}*" unless query =~ /\*/ - escaped_query = query.to_escaped_for_sql_like - where("original_title ILIKE ? ESCAPE E'\\\\' OR original_description ILIKE ? ESCAPE E'\\\\' OR translated_title ILIKE ? ESCAPE E'\\\\' OR translated_description ILIKE ? ESCAPE E'\\\\'", escaped_query, escaped_query, escaped_query, escaped_query) - end - - def post_tags_match(query) - where(post_id: PostQueryBuilder.new(query).build.reorder("")) - end - - def deleted - where(original_title: "", original_description: "", translated_title: "", translated_description: "") - end - - def undeleted - where("original_title != '' OR original_description != '' OR translated_title != '' OR translated_description != ''") - end - - def search(params) - q = super - - if params[:text_matches].present? - q = q.text_matches(params[:text_matches]) - end - - if params[:post_id].present? - q = q.where(post_id: params[:post_id].split(",").map(&:to_i)) - end - - if params[:original_present].to_s.truthy? - q = q.where("(original_title != '') or (original_description != '')") - elsif params[:original_present].to_s.falsy? - q = q.where("(original_title = '') and (original_description = '')") - end - - if params[:translated_present].to_s.truthy? - q = q.where("(translated_title != '') or (translated_description != '')") - elsif params[:translated_present].to_s.falsy? - q = q.where("(translated_title = '') and (translated_description = '')") - end - - if params[:post_tags_match].present? - q = q.post_tags_match(params[:post_tags_match]) - end - - q = q.deleted if params[:is_deleted] == "yes" - q = q.undeleted if params[:is_deleted] == "no" - - q.apply_default_order(params) - end - end - - def trim_whitespace - self.original_title = (original_title || '').gsub(/\A[[:space:]]+|[[:space:]]+\z/, "") - self.translated_title = (translated_title || '').gsub(/\A[[:space:]]+|[[:space:]]+\z/, "") - self.original_description = (original_description || '').gsub(/\A[[:space:]]+|[[:space:]]+\z/, "") - self.translated_description = (translated_description || '').gsub(/\A[[:space:]]+|[[:space:]]+\z/, "") - end - - def original_present? - original_title.present? || original_description.present? - end - - def translated_present? - translated_title.present? || translated_description.present? - end - - def any_field_present? - original_present? || translated_present? - end - - module VersionMethods - def create_version - return unless saved_changes? - - if merge_version? - merge_version - else - create_new_version - end - end - - def merge_version? - previous_version && previous_version.updater == CurrentUser.user && previous_version.updated_at > 1.hour.ago - end - - def merge_version - previous_version.update( - original_title: original_title, - original_description: original_description, - translated_title: translated_title, - translated_description: translated_description, - ) - end - - def create_new_version - versions.create( - :original_title => original_title, - :original_description => original_description, - :translated_title => translated_title, - :translated_description => translated_description - ) - end - - def revert_to(version) - if post_id != version.post_id - raise RevertError.new("You cannot revert to a previous artist commentary of another post.") - end - - self.original_description = version.original_description - self.original_title = version.original_title - self.translated_description = version.translated_description - self.translated_title = version.translated_title - end - - def revert_to!(version) - revert_to(version) - save! - end - end - - extend SearchMethods - include VersionMethods -end diff --git a/app/models/artist_commentary_version.rb b/app/models/artist_commentary_version.rb deleted file mode 100644 index 806eadabc..000000000 --- a/app/models/artist_commentary_version.rb +++ /dev/null @@ -1,19 +0,0 @@ -class ArtistCommentaryVersion < ApplicationRecord - belongs_to :post - belongs_to_updater - scope :for_user, ->(user_id) {where("updater_id = ?", user_id)} - - def self.search(params) - q = super - - if params[:updater_id] - q = q.where("updater_id = ?", params[:updater_id].to_i) - end - - if params[:post_id] - q = q.where("post_id = ?", params[:post_id].to_i) - end - - q.apply_default_order(params) - end -end diff --git a/app/models/tag.rb b/app/models/tag.rb index 6e7ca1a79..2f2c96085 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -14,7 +14,7 @@ class Tag < ApplicationRecord ] METATAGS = %w[ - -user user -approver approver commenter comm noter noteupdater artcomm + -user user -approver approver commenter comm noter noteupdater -pool pool ordpool -fav fav -favoritedby favoritedby md5 -rating rating note -note -locked locked width height mpixels ratio score favcount filesize source -source id -id date age order limit -status status tagcount parent -parent @@ -24,7 +24,7 @@ class Tag < ApplicationRecord deletedby -deletedby votedup voteddown -votedup -voteddown duration ] + TagCategory.short_name_list.map {|x| "#{x}tags"} + COUNT_METATAGS + BOOLEAN_METATAGS - SUBQUERY_METATAGS = %w[commenter comm noter noteupdater artcomm flagger -flagger appealer -appealer] + SUBQUERY_METATAGS = %w[commenter comm noter noteupdater flagger -flagger appealer -appealer] ORDER_METATAGS = %w[ id id_desc @@ -35,7 +35,6 @@ class Tag < ApplicationRecord comment comment_asc comment_bumped comment_bumped_asc note note_asc - artcomm artcomm_asc mpixels mpixels_asc portrait landscape filesize filesize_asc diff --git a/app/views/artist_commentaries/_form.html.erb b/app/views/artist_commentaries/_form.html.erb deleted file mode 100644 index efc8918c1..000000000 --- a/app/views/artist_commentaries/_form.html.erb +++ /dev/null @@ -1,35 +0,0 @@ -

If the artist of this image posted some interesting additional information about this work, you can copy it here. <%= link_to "View help.", help_page_path(id: "artist_commentary") %>

- -
-
- - <%= select_tag :commentary_source_type, options_for_select(%w[Source Post]) %> - <%= text_field_tag :commentary_source, post.source %> - <%= text_field_tag :commentary_post_id, post.parent_id, :style => "display: none;" %> - <%= button_tag "Fetch" %> -
-
- -<%= form_tag(create_or_update_artist_commentaries_path(:format => :js), :remote => true, :id => "edit-commentary", :class => "simple_form", :method => :put) do %> - <%= hidden_field :artist_commentary, :post_id, :value => post.id %> - -
- - <%= text_field :artist_commentary, :original_title, :value => post.artist_commentary.try(:original_title) %> -
- -
- - <%= text_area :artist_commentary, :original_description, :size => "40x6", :value => post.artist_commentary.try(:original_description) %> -
- -
- - <%= text_field :artist_commentary, :translated_title, :value => post.artist_commentary.try(:translated_title) %> -
- -
- - <%= text_area :artist_commentary, :translated_description, :size => "40x6", :value => post.artist_commentary.try(:translated_description) %> -
-<% end %> diff --git a/app/views/artist_commentaries/_quick_search.html.erb b/app/views/artist_commentaries/_quick_search.html.erb deleted file mode 100644 index 5c24eb488..000000000 --- a/app/views/artist_commentaries/_quick_search.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -<%= form_tag(artist_commentaries_path, :method => :get) do %> - <%= text_field "search", "text_matches", :id => "quick_search_text_matches", :placeholder => "Search commentary" %> -<% end %> diff --git a/app/views/artist_commentaries/_secondary_links.html.erb b/app/views/artist_commentaries/_secondary_links.html.erb deleted file mode 100644 index 368057014..000000000 --- a/app/views/artist_commentaries/_secondary_links.html.erb +++ /dev/null @@ -1,10 +0,0 @@ -<% content_for(:secondary_links) do %> - -
  • <%= render "artist_commentaries/quick_search" %>
  • - <%= subnav_link_to "Search", search_artist_commentaries_path %> - <%= subnav_link_to "Listing", artist_commentaries_path %> - <%= subnav_link_to "Recent changes", artist_commentary_versions_path %> - <%= subnav_link_to "Translation requests", artist_commentaries_path(:search => {:post_tags_match => "commentary_request"}) %> - <%= subnav_link_to "Help", help_page_path(id: "artist_commentary") %> -
    -<% end %> diff --git a/app/views/artist_commentaries/_show.html.erb b/app/views/artist_commentaries/_show.html.erb deleted file mode 100644 index 3c6d378bf..000000000 --- a/app/views/artist_commentaries/_show.html.erb +++ /dev/null @@ -1,40 +0,0 @@ -

    Description

    - - - <% if artist_commentary.original_present? && artist_commentary.translated_present? %> -
  • Original
  • | -
  • Translated
  • - <% elsif artist_commentary.original_present? %> -
  • Original
  • - <% elsif artist_commentary.translated_present? %> -
  • Translated
  • - <% end %> -
    - -<% if artist_commentary.original_present? %> - <%= tag.section id: "original-artist-commentary", style: ("display: none" if artist_commentary.translated_present?) do %> -

    <%= artist_commentary.original_title %>

    -
    - <%= format_text(artist_commentary.original_description) %> -
    - <% end %> -<% end %> - -<% if artist_commentary.translated_present? %> -
    -

    - <% if artist_commentary.translated_title.present? %> - <%= artist_commentary.translated_title %> - <% else %> - <%= artist_commentary.original_title %> - <% end %> -

    -
    - <% if artist_commentary.translated_description.present? %> - <%= format_text(artist_commentary.translated_description, :disable_mentions => true) %> - <% else %> - <%= format_text(artist_commentary.original_description) %> - <% end %> -
    -
    -<% end %> diff --git a/app/views/artist_commentaries/create_or_update.js.erb b/app/views/artist_commentaries/create_or_update.js.erb deleted file mode 100644 index 345366b9b..000000000 --- a/app/views/artist_commentaries/create_or_update.js.erb +++ /dev/null @@ -1 +0,0 @@ -location.reload(); diff --git a/app/views/artist_commentaries/index.html.erb b/app/views/artist_commentaries/index.html.erb deleted file mode 100644 index 5c1c96e33..000000000 --- a/app/views/artist_commentaries/index.html.erb +++ /dev/null @@ -1,44 +0,0 @@ -
    -
    -

    Artist Commentary

    - - <%= render "posts/partials/common/inline_blacklist" %> - - - - - - - - - - - <% @commentaries.each do |commentary| %> - - - - - - <% end %> - -
    PostOriginalTranslated
    <%= PostPresenter.preview(commentary.post, :tags => "status:any") %> -

    <%= h(commentary.original_title) %>

    -
    - <%= format_text(commentary.original_description) %> -
    -
    -

    <%= h(commentary.translated_title) %>

    -
    - <%= format_text(commentary.translated_description) %> -
    -
    - - <%= numbered_paginator(@commentaries) %> -
    -
    - -<%= render "secondary_links" %> - -<% content_for(:page_title) do %> - Artist Commentary -<% end %> diff --git a/app/views/artist_commentaries/revert.js.erb b/app/views/artist_commentaries/revert.js.erb deleted file mode 100644 index 345366b9b..000000000 --- a/app/views/artist_commentaries/revert.js.erb +++ /dev/null @@ -1 +0,0 @@ -location.reload(); diff --git a/app/views/artist_commentaries/search.html.erb b/app/views/artist_commentaries/search.html.erb deleted file mode 100644 index b0ff83a61..000000000 --- a/app/views/artist_commentaries/search.html.erb +++ /dev/null @@ -1,20 +0,0 @@ -
    - -
    - -<%= render "secondary_links" %> - -<% content_for(:page_title) do %> - Search Artist Commentary -<% end %> diff --git a/app/views/artist_commentary_versions/_revert_listing.html.erb b/app/views/artist_commentary_versions/_revert_listing.html.erb deleted file mode 100644 index a1ea7298f..000000000 --- a/app/views/artist_commentary_versions/_revert_listing.html.erb +++ /dev/null @@ -1,50 +0,0 @@ -
    - - - - - - - <% if CurrentUser.is_moderator? %> - - <% end %> - - - <% if CurrentUser.is_member? %> - - <% end %> - - - - <% @commentary_versions.each do |commentary_version| %> - - - - - <% if CurrentUser.is_moderator? %> - - <% end %> - - - <% if CurrentUser.is_member? %> - - <% end %> - - <% end %> - -
    PostOriginalTranslatedIP AddressEdited ByDate
    <%= link_to commentary_version.post_id, post_path(commentary_version.post_id) %> -

    <%= h(commentary_version.original_title) %>

    -
    - <%= format_text(commentary_version.original_description) %> -
    -
    -

    <%= h(commentary_version.translated_title) %>

    -
    - <%= format_text(commentary_version.translated_description) %> -
    -
    - <%= link_to_ip commentary_version.updater_ip_addr %> - <%= link_to_user commentary_version.updater %><%= compact_time commentary_version.updated_at %> - <%= link_to "Revert to", revert_artist_commentary_path(commentary_version.post_id, :version_id => commentary_version.id, format: :json), class: 'revert-item-link', 'data-noun': 'comment' %> -
    -
    diff --git a/app/views/artist_commentary_versions/_standard_listing.html.erb b/app/views/artist_commentary_versions/_standard_listing.html.erb deleted file mode 100644 index 0dcc7b70c..000000000 --- a/app/views/artist_commentary_versions/_standard_listing.html.erb +++ /dev/null @@ -1,44 +0,0 @@ -
    - - - - - - - - <% if CurrentUser.is_moderator? %> - - <% end %> - - - - - - <% @commentary_versions.each do |commentary_version| %> - - - - - - <% if CurrentUser.is_moderator? %> - - <% end %> - - - - <% end %> - -
    PostVersionOriginalTranslatedIP AddressEdited ByDate
    <%= PostPresenter.preview(commentary_version.post, :tags => "status:any") %><%= link_to "#{commentary_version.post_id}.#{commentary_version.id}»", artist_commentary_versions_path(search: {post_id: commentary_version.post_id}) %> -

    <%= h(commentary_version.original_title) %>

    -
    - <%= format_text(commentary_version.original_description) %> -
    -
    -

    <%= h(commentary_version.translated_title) %>

    -
    - <%= format_text(commentary_version.translated_description) %> -
    -
    - <%= link_to_ip commentary_version.updater_ip_addr %> - <%= link_to_user commentary_version.updater %><%= compact_time commentary_version.updated_at %>
    -
    diff --git a/app/views/artist_commentary_versions/index.html.erb b/app/views/artist_commentary_versions/index.html.erb deleted file mode 100644 index 9b5cbf7a7..000000000 --- a/app/views/artist_commentary_versions/index.html.erb +++ /dev/null @@ -1,22 +0,0 @@ -
    -
    -

    Artist Commentary Changes

    - - <%= render "posts/partials/common/inline_blacklist" %> - - <% if params.dig(:search, :post_id).present? %> - <%= render "revert_listing" %> - <% else %> - <%= render "standard_listing" %> - <% end %> - - <%= numbered_paginator(@commentary_versions) %> - -
    -
    - -<%= render "artist_commentaries/secondary_links" %> - -<% content_for(:page_title) do %> - Artist Commentary Versions -<% end %> diff --git a/app/views/posts/show.html.erb b/app/views/posts/show.html.erb index ada455537..7d5911e98 100644 --- a/app/views/posts/show.html.erb +++ b/app/views/posts/show.html.erb @@ -150,12 +150,12 @@ <% if @post.description.present? %>
    -