views: add embed_wiki helper.

Also remove options to configure names of wiki notice pages. These names
generally don't need to be changed and we already hardcode links to wiki
pages in other places anyway.
This commit is contained in:
evazion
2020-01-27 13:04:28 -06:00
parent af044c45db
commit 588280c8cc
8 changed files with 11 additions and 36 deletions

View File

@@ -5,7 +5,6 @@ class UploadsController < ApplicationController
def new def new
@source = Sources::Strategies.find(params[:url], params[:ref]) if params[:url].present? @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( @upload, @remote_size = UploadService::ControllerHelper.prepare(
url: params[:url], ref: params[:ref] url: params[:url], ref: params[:ref]
) )

View File

@@ -163,6 +163,12 @@ module ApplicationHelper
html.html_safe html.html_safe
end 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 = {}) def dtext_field(object, name, options = {})
options[:name] ||= name.capitalize options[:name] ||= name.capitalize
options[:input_id] ||= "#{object}_#{name}" options[:input_id] ||= "#{object}_#{name}"

View File

@@ -1,7 +1,5 @@
<div class="report-dialog-body"> <div class="report-dialog-body">
<div class="prose"> <%= embed_wiki("help:report_notice") %>
<%= format_text(WikiPage.titled(Danbooru.config.report_notice_wiki_page).first.try(&:body)) %>
</div>
<%# XXX dtext_field expects there to be a `moderation_report` instance variable. %> <%# XXX dtext_field expects there to be a `moderation_report` instance variable. %>
<% @moderation_report = moderation_report %> <% @moderation_report = moderation_report %>

View File

@@ -1,7 +1,5 @@
<div class="appeal-dialog-body"> <div class="appeal-dialog-body">
<div class="prose"> <%= embed_wiki("help:appeal_notice") %>
<%= format_text(WikiPage.titled(Danbooru.config.appeal_notice_wiki_page).first.try(&:body)) %>
</div>
<%# XXX dtext_field expects there to be a `post_appeal` instance variable. %> <%# XXX dtext_field expects there to be a `post_appeal` instance variable. %>
<% @post_appeal = post_appeal %> <% @post_appeal = post_appeal %>

View File

@@ -1,7 +1,5 @@
<div class="flag-dialog-body"> <div class="flag-dialog-body">
<div class="prose"> <%= embed_wiki("help:flag_notice") %>
<%= format_text(WikiPage.titled(Danbooru.config.flag_notice_wiki_page).first.try(&:body)) %>
</div>
<%# XXX dtext_field expects there to be a `post_flag` instance variable. %> <%# XXX dtext_field expects there to be a `post_flag` instance variable. %>
<% @post_flag = post_flag %> <% @post_flag = post_flag %>

View File

@@ -1,7 +1,5 @@
<div class="replace-image-dialog-body"> <div class="replace-image-dialog-body">
<div class="prose"> <%= embed_wiki("help:replacement_notice") %>
<%= format_text(WikiPage.titled(Danbooru.config.replacement_notice_wiki_page).first.try(&:body)) %>
</div>
<%= edit_form_for(post_replacement, url: post_replacements_path(post_id: post_replacement.post_id), method: :post, remote: true) do |f| %> <%= 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 %> <%= f.input :replacement_file, label: "File", as: :file %>

View File

@@ -3,9 +3,7 @@
<h1>Upload</h1> <h1>Upload</h1>
<% if CurrentUser.can_upload? %> <% if CurrentUser.can_upload? %>
<div id="upload-guide-notice" class="prose"> <%= embed_wiki("help:upload_notice", id: "upload-guide-notice") %>
<%= format_text(@upload_notice_wiki.try(&:body)) %>
</div>
<% unless CurrentUser.can_upload_free? %> <% unless CurrentUser.can_upload_free? %>
<p>Upload limit: <strong><%= CurrentUser.user.presenter.upload_limit(self) %></strong>.</p> <p>Upload limit: <strong><%= CurrentUser.user.presenter.upload_limit(self) %></strong>.</p>

View File

@@ -289,26 +289,6 @@ module Danbooru
nil nil
end 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. # The number of posts displayed per page.
def posts_per_page def posts_per_page
20 20