diff --git a/app/controllers/uploads_controller.rb b/app/controllers/uploads_controller.rb index d777ba39d..0c3057b51 100644 --- a/app/controllers/uploads_controller.rb +++ b/app/controllers/uploads_controller.rb @@ -5,7 +5,6 @@ class UploadsController < ApplicationController def new @source = Sources::Strategies.find(params[:url], params[:ref]) if params[:url].present? - @upload_notice_wiki = WikiPage.titled(Danbooru.config.upload_notice_wiki_page).first @upload, @remote_size = UploadService::ControllerHelper.prepare( url: params[:url], ref: params[:ref] ) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9a52e69b6..7af227464 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -163,6 +163,12 @@ module ApplicationHelper html.html_safe end + def embed_wiki(title, **options) + wiki = WikiPage.find_by(title: title) + text = format_text(wiki&.body) + tag.div(text, class: "prose", **options) + end + def dtext_field(object, name, options = {}) options[:name] ||= name.capitalize options[:input_id] ||= "#{object}_#{name}" diff --git a/app/views/moderation_reports/_new.html.erb b/app/views/moderation_reports/_new.html.erb index e0e948144..0af8a497c 100644 --- a/app/views/moderation_reports/_new.html.erb +++ b/app/views/moderation_reports/_new.html.erb @@ -1,7 +1,5 @@
-
- <%= format_text(WikiPage.titled(Danbooru.config.report_notice_wiki_page).first.try(&:body)) %> -
+ <%= embed_wiki("help:report_notice") %> <%# XXX dtext_field expects there to be a `moderation_report` instance variable. %> <% @moderation_report = moderation_report %> diff --git a/app/views/post_appeals/_new.html.erb b/app/views/post_appeals/_new.html.erb index 3bce7ef08..c418a1b8e 100644 --- a/app/views/post_appeals/_new.html.erb +++ b/app/views/post_appeals/_new.html.erb @@ -1,7 +1,5 @@
-
- <%= format_text(WikiPage.titled(Danbooru.config.appeal_notice_wiki_page).first.try(&:body)) %> -
+ <%= embed_wiki("help:appeal_notice") %> <%# XXX dtext_field expects there to be a `post_appeal` instance variable. %> <% @post_appeal = post_appeal %> diff --git a/app/views/post_flags/_new.html.erb b/app/views/post_flags/_new.html.erb index 6c997c328..00cc67449 100644 --- a/app/views/post_flags/_new.html.erb +++ b/app/views/post_flags/_new.html.erb @@ -1,7 +1,5 @@
-
- <%= format_text(WikiPage.titled(Danbooru.config.flag_notice_wiki_page).first.try(&:body)) %> -
+ <%= embed_wiki("help:flag_notice") %> <%# XXX dtext_field expects there to be a `post_flag` instance variable. %> <% @post_flag = post_flag %> diff --git a/app/views/post_replacements/_new.html.erb b/app/views/post_replacements/_new.html.erb index 63b5f3072..30a63ab92 100644 --- a/app/views/post_replacements/_new.html.erb +++ b/app/views/post_replacements/_new.html.erb @@ -1,7 +1,5 @@
-
- <%= format_text(WikiPage.titled(Danbooru.config.replacement_notice_wiki_page).first.try(&:body)) %> -
+ <%= embed_wiki("help:replacement_notice") %> <%= edit_form_for(post_replacement, url: post_replacements_path(post_id: post_replacement.post_id), method: :post, remote: true) do |f| %> <%= f.input :replacement_file, label: "File", as: :file %> diff --git a/app/views/uploads/new.html.erb b/app/views/uploads/new.html.erb index b46b02cd4..10144ff66 100644 --- a/app/views/uploads/new.html.erb +++ b/app/views/uploads/new.html.erb @@ -3,9 +3,7 @@

Upload

<% if CurrentUser.can_upload? %> -
- <%= format_text(@upload_notice_wiki.try(&:body)) %> -
+ <%= embed_wiki("help:upload_notice", id: "upload-guide-notice") %> <% unless CurrentUser.can_upload_free? %>

Upload limit: <%= CurrentUser.user.presenter.upload_limit(self) %>.

diff --git a/config/danbooru_default_config.rb b/config/danbooru_default_config.rb index d728a7497..ca16e0edb 100644 --- a/config/danbooru_default_config.rb +++ b/config/danbooru_default_config.rb @@ -289,26 +289,6 @@ module Danbooru nil end - def upload_notice_wiki_page - "help:upload_notice" - end - - def flag_notice_wiki_page - "help:flag_notice" - end - - def appeal_notice_wiki_page - "help:appeal_notice" - end - - def report_notice_wiki_page - "help:report_notice" - end - - def replacement_notice_wiki_page - "help:replacement_notice" - end - # The number of posts displayed per page. def posts_per_page 20