forked from e621ng/e621ng
Descriptions on posts
This commit is contained in:
parent
b75446c669
commit
7b750ac862
@ -130,6 +130,7 @@ private
|
||||
tag_string old_tag_string
|
||||
parent_id old_parent_id
|
||||
source old_source
|
||||
description old_description
|
||||
rating old_rating
|
||||
has_embedded_notes
|
||||
]
|
||||
|
@ -66,9 +66,7 @@ class UploadsController < ApplicationController
|
||||
|
||||
def upload_params
|
||||
permitted_params = %i[
|
||||
file direct_url source tag_string rating parent_id description artist_commentary_title
|
||||
artist_commentary_desc include_artist_commentary referer_url
|
||||
md5_confirmation as_pending
|
||||
file direct_url source tag_string rating parent_id description description referer_url md5_confirmation as_pending
|
||||
]
|
||||
|
||||
params.require(:upload).permit(permitted_params)
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
module PostIndex
|
||||
def self.included(base)
|
||||
base.settings index: { number_of_shards: 5, number_of_replicas: 1 } do
|
||||
base.settings index: { number_of_shards: 10, number_of_replicas: 1 } do
|
||||
mappings dynamic: false, _all: { enabled: false } do
|
||||
indexes :created_at, type: 'date'
|
||||
indexes :updated_at, type: 'date'
|
||||
@ -44,6 +44,7 @@ module PostIndex
|
||||
indexes :rating, type: 'keyword'
|
||||
indexes :file_ext, type: 'keyword'
|
||||
indexes :source, type: 'keyword'
|
||||
indexes :description, type: 'text'
|
||||
|
||||
indexes :rating_locked, type: 'boolean'
|
||||
indexes :note_locked, type: 'boolean'
|
||||
@ -193,11 +194,12 @@ module PostIndex
|
||||
mpixels: (image_width.to_f * image_height / 1_000_000).round(2),
|
||||
aspect_ratio: (image_width.to_f / [image_height, 1].max).round(2),
|
||||
|
||||
tags: tag_string.split(" "),
|
||||
md5: md5,
|
||||
rating: rating,
|
||||
file_ext: file_ext,
|
||||
source: source_array,
|
||||
tags: tag_string.split(" "),
|
||||
md5: md5,
|
||||
rating: rating,
|
||||
file_ext: file_ext,
|
||||
source: source_array,
|
||||
description: description,
|
||||
|
||||
rating_locked: is_rating_locked,
|
||||
note_locked: is_note_locked,
|
||||
|
@ -736,7 +736,7 @@
|
||||
data.append('upload[tag_string]', this.tags);
|
||||
data.append('upload[rating]', this.rating);
|
||||
data.append('upload[source]', this.sources.join('\n'));
|
||||
data.append('upload[artist_commentary_desc]', this.description);
|
||||
data.append('upload[description]', this.description);
|
||||
data.append('upload[parent_id]', this.parentID);
|
||||
jQuery.ajax('/uploads.json', {
|
||||
contentType: false,
|
||||
|
@ -172,6 +172,13 @@ class ElasticPostQueryBuilder
|
||||
add_range_relation(q[column], column, must)
|
||||
end
|
||||
|
||||
if q[:description]
|
||||
must.push({match: {description: q[:description]}})
|
||||
end
|
||||
if q[:description_neg]
|
||||
must_not.push({match: {description: q[:description_neg]}})
|
||||
end
|
||||
|
||||
if q[:md5]
|
||||
must.push(should(*(q[:md5].map {|m| {term: {md5: m}}})))
|
||||
end
|
||||
|
@ -37,10 +37,6 @@ class UploadService
|
||||
return @post.warnings.full_messages
|
||||
end
|
||||
|
||||
def include_artist_commentary?
|
||||
params[:include_artist_commentary].to_s.truthy?
|
||||
end
|
||||
|
||||
def create_post_from_upload(upload)
|
||||
@post = convert_to_post(upload)
|
||||
@post.save!
|
||||
@ -53,13 +49,6 @@ class UploadService
|
||||
)
|
||||
end
|
||||
|
||||
if params[:artist_commentary_desc].strip
|
||||
@post.create_artist_commentary(
|
||||
:original_title => params[:artist_commentary_title],
|
||||
:original_description => params[:artist_commentary_desc]
|
||||
)
|
||||
end
|
||||
|
||||
upload.update(status: "completed", post_id: @post.id)
|
||||
|
||||
@post
|
||||
@ -69,6 +58,7 @@ class UploadService
|
||||
Post.new.tap do |p|
|
||||
p.has_cropped = true
|
||||
p.tag_string = upload.tag_string
|
||||
p.description = upload.description.strip
|
||||
p.md5 = upload.md5
|
||||
p.file_ext = upload.file_ext
|
||||
p.image_width = upload.image_width
|
||||
|
@ -20,6 +20,7 @@ class Post < ApplicationRecord
|
||||
before_validation :remove_parent_loops
|
||||
validates_uniqueness_of :md5, :on => :create, message: ->(obj, data) {"duplicate: #{Post.find_by_md5(obj.md5).id}"}
|
||||
validates_inclusion_of :rating, in: %w(s q e), message: "rating must be s, q, or e"
|
||||
validates_length_of :description, maximum: 50000
|
||||
validate :tag_names_are_valid, if: :should_process_tags?
|
||||
validate :added_tags_are_valid, if: :should_process_tags?
|
||||
validate :removed_tags_are_valid, if: :should_process_tags?
|
||||
@ -46,7 +47,6 @@ class Post < ApplicationRecord
|
||||
user_status_counter :post_count, foreign_key: :uploader_id
|
||||
belongs_to :parent, class_name: "Post", optional: true
|
||||
has_one :upload, :dependent => :destroy
|
||||
has_one :artist_commentary, :dependent => :destroy
|
||||
has_one :pixiv_ugoira_frame_data, :class_name => "PixivUgoiraFrameData", :dependent => :destroy
|
||||
has_many :flags, :class_name => "PostFlag", :dependent => :destroy
|
||||
has_many :appeals, :class_name => "PostAppeal", :dependent => :destroy
|
||||
@ -1449,7 +1449,7 @@ class Post < ApplicationRecord
|
||||
end
|
||||
|
||||
def saved_change_to_watched_attributes?
|
||||
saved_change_to_rating? || saved_change_to_source? || saved_change_to_parent_id? || saved_change_to_tag_string? || saved_change_to_locked_tags?
|
||||
saved_change_to_rating? || saved_change_to_source? || saved_change_to_parent_id? || saved_change_to_tag_string? || saved_change_to_locked_tags? || saved_change_to_description?
|
||||
end
|
||||
|
||||
def merge_version?
|
||||
@ -1470,6 +1470,7 @@ class Post < ApplicationRecord
|
||||
self.rating = target.rating
|
||||
self.source = target.source
|
||||
self.parent_id = target.parent_id
|
||||
self.description = target.description
|
||||
end
|
||||
|
||||
def revert_to!(target)
|
||||
|
@ -67,7 +67,8 @@ class PostArchive < ApplicationRecord
|
||||
updater_id: CurrentUser.id,
|
||||
updater_ip_addr: CurrentUser.ip_addr,
|
||||
tags: post.tag_string,
|
||||
locked_tags: post.locked_tags
|
||||
locked_tags: post.locked_tags,
|
||||
description: post.description
|
||||
})
|
||||
end
|
||||
|
||||
@ -97,6 +98,7 @@ class PostArchive < ApplicationRecord
|
||||
self.rating_changed = prev.nil? || rating != prev.try(:rating)
|
||||
self.parent_changed = prev.nil? || parent_id != prev.try(:parent_id)
|
||||
self.source_changed = prev.nil? || source != prev.try(:source)
|
||||
self.description_changed = prev.nil? || description != prev.try(:description)
|
||||
end
|
||||
|
||||
def tag_array
|
||||
|
@ -19,7 +19,7 @@ class Tag < ApplicationRecord
|
||||
-source id -id date age order limit -status status tagcount parent -parent
|
||||
child pixiv_id pixiv search upvote downvote voted filetype -filetype flagger
|
||||
-flagger appealer -appealer disapproval -disapproval set -set randseed -voted
|
||||
-upvote -downvote
|
||||
-upvote -downvote description -description
|
||||
] + TagCategory.short_name_list.map {|x| "#{x}tags"} + COUNT_METATAGS + COUNT_METATAG_SYNONYMS
|
||||
|
||||
SUBQUERY_METATAGS = %w[commenter comm noter noteupdater artcomm flagger -flagger appealer -appealer]
|
||||
@ -750,6 +750,12 @@ class Tag < ApplicationRecord
|
||||
when "-filetype"
|
||||
q[:filetype_neg] = g2.downcase
|
||||
|
||||
when "description"
|
||||
q[:description] = g2
|
||||
|
||||
when "-description"
|
||||
q[:description_neg] = g2
|
||||
|
||||
when "pixiv_id", "pixiv"
|
||||
if g2.downcase == "any" || g2.downcase == "none"
|
||||
q[:pixiv_id] = g2.downcase
|
||||
|
@ -612,8 +612,7 @@ class User < ApplicationRecord
|
||||
# extra attributes returned for /users/:id.json but not for /users.json.
|
||||
def full_attributes
|
||||
[
|
||||
:wiki_page_version_count, :artist_version_count,
|
||||
:artist_commentary_version_count, :pool_version_count,
|
||||
:wiki_page_version_count, :artist_version_count, :pool_version_count,
|
||||
:forum_post_count, :comment_count,
|
||||
:appeal_count, :flag_count, :positive_feedback_count,
|
||||
:neutral_feedback_count, :negative_feedback_count, :upload_limit
|
||||
@ -655,10 +654,6 @@ class User < ApplicationRecord
|
||||
user_status.artist_edit_count
|
||||
end
|
||||
|
||||
def artist_commentary_version_count
|
||||
ArtistCommentaryVersion.for_user(id).count
|
||||
end
|
||||
|
||||
def pool_version_count
|
||||
user_status.pool_edit_count
|
||||
end
|
||||
|
@ -112,10 +112,6 @@ class UserPresenter
|
||||
template.link_to(user.artist_version_count, template.artist_versions_path(:search => {:updater_id => user.id}))
|
||||
end
|
||||
|
||||
def artist_commentary_version_count(template)
|
||||
template.link_to(user.artist_commentary_version_count, template.artist_commentary_versions_path(:search => {:updater_id => user.id}))
|
||||
end
|
||||
|
||||
def forum_post_count(template)
|
||||
template.link_to(user.forum_post_count, template.forum_posts_path(:search => {:creator_id => user.id}))
|
||||
end
|
||||
|
@ -66,6 +66,11 @@
|
||||
<%= f.text_area :source, size: '60x5', spellcheck: false %>
|
||||
</div>
|
||||
|
||||
<div class="input">
|
||||
<%= f.label :description, "Description" %>
|
||||
<%= f.text_area :description, size: '60x5', spellcheck: true %>
|
||||
</div>
|
||||
|
||||
<% if Danbooru.config.iqdbs_server %>
|
||||
<div class="input" id="iqdb-similar" style="display: none;"></div>
|
||||
<% end %>
|
||||
|
@ -13,7 +13,6 @@
|
||||
<% if post.has_notes? %>
|
||||
<li id="copy-all-notes-list"><%= link_to "Copy notes", "#", :id => "copy-notes" %></li>
|
||||
<% end %>
|
||||
<li id="add-artist-commentary-list"><%= link_to "Add commentary", "#", :id => "add-commentary" %></li>
|
||||
<li><%= link_to "Find similar", iqdb_queries_path(:post_id => post.id) %></li>
|
||||
|
||||
<% if post.is_status_locked? %>
|
||||
|
@ -24,10 +24,9 @@
|
||||
<section id="post-history">
|
||||
<h1>History</h1>
|
||||
<ul>
|
||||
<li><%= fast_link_to "Tags", post_versions_path(:search => {:post_id => @post.id}) %></li>
|
||||
<li><%= fast_link_to "Tags/Desc", post_versions_path(:search => {:post_id => @post.id}) %></li>
|
||||
<li><%= fast_link_to "Notes", note_versions_path(:search => {:post_id => @post.id}) %></li>
|
||||
<li><%= fast_link_to "Moderation", post_events_path(@post.id) %></li>
|
||||
<li><%= fast_link_to "Commentary", artist_commentary_versions_path(:search => {:post_id => @post.id}) %></li>
|
||||
<li><%= fast_link_to "Replacements", post_replacements_path(:search => {:post_id => @post.id}) %></li>
|
||||
</ul>
|
||||
</section>
|
||||
@ -85,9 +84,14 @@
|
||||
<% end %>
|
||||
</section>
|
||||
|
||||
<% if @post.artist_commentary && @post.artist_commentary.any_field_present? %>
|
||||
<% if @post.description.present? %>
|
||||
<div id="artist-commentary">
|
||||
<%= render "artist_commentaries/show", :artist_commentary => @post.artist_commentary %>
|
||||
<h3>Description</h3>
|
||||
<section id="original-artist-commentary">
|
||||
<div class="prose">
|
||||
<%= format_text(@post.description, disable_mentions: true, max_thumbs: 0) %>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
@ -140,10 +144,6 @@
|
||||
<div id="add-to-pool-dialog" title="Add to pool" style="display: none;">
|
||||
<%= render "pool_elements/new" %>
|
||||
</div>
|
||||
|
||||
<div id="add-commentary-dialog" title="Add artist commentary" style="display: none;">
|
||||
<%= render "artist_commentaries/form", :post => @post %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
|
@ -97,12 +97,6 @@
|
||||
<li><%= link_to("Help", wiki_pages_path(title: "help:blips")) %></li>
|
||||
<li><%= link_to("Listing", blips_path) %></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><h1>Artist commentary</h1></li>
|
||||
<li><%= link_to("Help", help_page_path(id: "artist_commentary")) %></li>
|
||||
<li><%= link_to("Listing", artist_commentaries_path) %></li>
|
||||
<li><%= link_to("Changes", artist_commentary_versions_path) %></li>
|
||||
</ul>
|
||||
</section>
|
||||
<section>
|
||||
<ul>
|
||||
|
@ -97,11 +97,6 @@
|
||||
<td><%= presenter.artist_version_count(self) %></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th>Commentary Changes</th>
|
||||
<td><%= presenter.artist_commentary_version_count(self) %></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th>Pool Changes</th>
|
||||
<td><%= presenter.pool_version_count(self) %></td>
|
||||
@ -138,7 +133,7 @@
|
||||
<th>Feedback</th>
|
||||
<td><%= presenter.feedbacks(self) %></td> </tbody>
|
||||
</tr>
|
||||
|
||||
|
||||
<% if presenter.previous_names(self).present? %>
|
||||
<tr>
|
||||
<th>Previous Names</th>
|
||||
|
@ -240,10 +240,6 @@ Rails.application.routes.draw do
|
||||
resources :posts, :only => [:index, :show, :update] do
|
||||
resources :events, :only => [:index], :controller => "post_events"
|
||||
resources :replacements, :only => [:index, :new, :create], :controller => "post_replacements"
|
||||
resource :artist_commentary, :only => [:index, :show] do
|
||||
collection {put :create_or_update}
|
||||
member {put :revert}
|
||||
end
|
||||
resource :votes, :controller => "post_votes", :only => [:create, :destroy]
|
||||
collection do
|
||||
get :random
|
||||
@ -282,7 +278,6 @@ Rails.application.routes.draw do
|
||||
put :revert
|
||||
end
|
||||
end
|
||||
resources :artist_commentary_versions, :only => [:index]
|
||||
resource :related_tag, :only => [:show, :update]
|
||||
get "related_tag/bulk" => "related_tags#bulk"
|
||||
get "reports/uploads" => "reports#uploads"
|
||||
|
5
db/migrate/20190714122705_add_post_description.rb
Normal file
5
db/migrate/20190714122705_add_post_description.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddPostDescription < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :posts, :description, :text, null: false, default: ''
|
||||
end
|
||||
end
|
@ -1926,7 +1926,8 @@ CREATE TABLE public.posts (
|
||||
tag_count_meta integer DEFAULT 0 NOT NULL,
|
||||
locked_tags text,
|
||||
tag_count_species integer DEFAULT 0 NOT NULL,
|
||||
tag_count_invalid integer DEFAULT 0 NOT NULL
|
||||
tag_count_invalid integer DEFAULT 0 NOT NULL,
|
||||
description text DEFAULT ''::text NOT NULL
|
||||
);
|
||||
|
||||
|
||||
@ -5124,6 +5125,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||
('20190602115848'),
|
||||
('20190604125828'),
|
||||
('20190613025850'),
|
||||
('20190623070654');
|
||||
('20190623070654'),
|
||||
('20190714122705');
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user