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:
@@ -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]
|
||||
)
|
||||
|
||||
@@ -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}"
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
<div class="report-dialog-body">
|
||||
<div class="prose">
|
||||
<%= format_text(WikiPage.titled(Danbooru.config.report_notice_wiki_page).first.try(&:body)) %>
|
||||
</div>
|
||||
<%= embed_wiki("help:report_notice") %>
|
||||
|
||||
<%# XXX dtext_field expects there to be a `moderation_report` instance variable. %>
|
||||
<% @moderation_report = moderation_report %>
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
<div class="appeal-dialog-body">
|
||||
<div class="prose">
|
||||
<%= format_text(WikiPage.titled(Danbooru.config.appeal_notice_wiki_page).first.try(&:body)) %>
|
||||
</div>
|
||||
<%= embed_wiki("help:appeal_notice") %>
|
||||
|
||||
<%# XXX dtext_field expects there to be a `post_appeal` instance variable. %>
|
||||
<% @post_appeal = post_appeal %>
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
<div class="flag-dialog-body">
|
||||
<div class="prose">
|
||||
<%= format_text(WikiPage.titled(Danbooru.config.flag_notice_wiki_page).first.try(&:body)) %>
|
||||
</div>
|
||||
<%= embed_wiki("help:flag_notice") %>
|
||||
|
||||
<%# XXX dtext_field expects there to be a `post_flag` instance variable. %>
|
||||
<% @post_flag = post_flag %>
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
<div class="replace-image-dialog-body">
|
||||
<div class="prose">
|
||||
<%= format_text(WikiPage.titled(Danbooru.config.replacement_notice_wiki_page).first.try(&:body)) %>
|
||||
</div>
|
||||
<%= 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 %>
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
<h1>Upload</h1>
|
||||
|
||||
<% if CurrentUser.can_upload? %>
|
||||
<div id="upload-guide-notice" class="prose">
|
||||
<%= format_text(@upload_notice_wiki.try(&:body)) %>
|
||||
</div>
|
||||
<%= embed_wiki("help:upload_notice", id: "upload-guide-notice") %>
|
||||
|
||||
<% unless CurrentUser.can_upload_free? %>
|
||||
<p>Upload limit: <strong><%= CurrentUser.user.presenter.upload_limit(self) %></strong>.</p>
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user