add plain-text console formatting option
parent
0fb1e7888e
commit
90130014dd
|
@ -77,6 +77,10 @@ const messages = defineMessages({
|
|||
defaultMessage: 'Markdown',
|
||||
id: 'compose.content-type.markdown',
|
||||
},
|
||||
console: {
|
||||
defaultMessage: 'Console',
|
||||
id: 'compose.content-type.console',
|
||||
},
|
||||
plain: {
|
||||
defaultMessage: 'Plain text',
|
||||
id: 'compose.content-type.plain',
|
||||
|
@ -258,6 +262,11 @@ class ComposerOptions extends ImmutablePureComponent {
|
|||
name: 'text/plain',
|
||||
text: <FormattedMessage {...messages.plain} />,
|
||||
},
|
||||
console: {
|
||||
icon: 'terminal',
|
||||
name: 'text/console',
|
||||
text: <FormattedMessage {...messages.console} />,
|
||||
},
|
||||
html: {
|
||||
icon: 'code',
|
||||
name: 'text/html',
|
||||
|
@ -355,6 +364,7 @@ class ComposerOptions extends ImmutablePureComponent {
|
|||
contentTypeItems.xbbcode,
|
||||
contentTypeItems.html,
|
||||
contentTypeItems.plain,
|
||||
contentTypeItems.console,
|
||||
]}
|
||||
onChange={onChangeContentType}
|
||||
onModalClose={onModalClose}
|
||||
|
|
|
@ -504,6 +504,11 @@ class Bangtags
|
|||
'plain' => 'text/plain',
|
||||
'plaintext' => 'text/plain',
|
||||
|
||||
'c' => 'text/console',
|
||||
'console' => 'text/console',
|
||||
'terminal' => 'text/console',
|
||||
'monospace' => 'text/console',
|
||||
|
||||
'm' => 'text/markdown',
|
||||
'md' => 'text/markdown',
|
||||
'markdown' => 'text/markdown',
|
||||
|
|
|
@ -229,6 +229,7 @@ class Formatter
|
|||
else
|
||||
html = simple_format(html, {}, sanitize: false)
|
||||
html = html.delete("\n")
|
||||
html = format_console(html) if status.content_type == 'text/console'
|
||||
end
|
||||
|
||||
unless status.footer.blank?
|
||||
|
@ -247,13 +248,17 @@ class Formatter
|
|||
html.html_safe # rubocop:disable Rails/OutputSafety
|
||||
end
|
||||
|
||||
def format_console(html)
|
||||
"<pre><code>#{html}</code></pre>"
|
||||
end
|
||||
|
||||
def format_markdown(html)
|
||||
html = markdown_formatter.render(html)
|
||||
end
|
||||
|
||||
def format_bbcode(html)
|
||||
html = bbcode_formatter(html)
|
||||
html = html.gsub(/<hr>.*<\/hr>/im, '<hr />')
|
||||
html.gsub(/<hr>.*<\/hr>/im, '<hr />')
|
||||
end
|
||||
|
||||
def format_bbdown(html)
|
||||
|
|
|
@ -88,7 +88,7 @@ class Status < ApplicationRecord
|
|||
validates_with DisallowedHashtagsValidator
|
||||
validates :reblog, uniqueness: { scope: :account }, if: :reblog?
|
||||
validates :visibility, exclusion: { in: %w(direct limited) }, if: :reblog?
|
||||
validates :content_type, inclusion: { in: %w(text/plain text/markdown text/x-bbcode text/x-bbcode+markdown text/html) }, allow_nil: true
|
||||
validates :content_type, inclusion: { in: %w(text/plain text/console text/markdown text/x-bbcode text/x-bbcode+markdown text/html) }, allow_nil: true
|
||||
|
||||
accepts_nested_attributes_for :poll
|
||||
|
||||
|
|
|
@ -40,7 +40,9 @@ class ActivityPub::NoteSerializer < ActivityPub::Serializer
|
|||
end
|
||||
|
||||
def source
|
||||
{ 'source' => object.proper.text, 'mediaType' => object.proper.content_type || 'text/plain' }
|
||||
content_type = object.proper.content_type || 'text/plain'
|
||||
content_type = 'text/plain+console' if content_type == 'text/console'
|
||||
{ 'source' => object.proper.text, 'mediaType' => content_type }
|
||||
end
|
||||
|
||||
def content_map
|
||||
|
|
|
@ -7,7 +7,7 @@ class ImportService < BaseService
|
|||
include JsonLdHelper
|
||||
|
||||
ROWS_PROCESSING_LIMIT = 20_000
|
||||
CONTENT_TYPES = %w(text/bbcode+markdown text/markdown text/bbcode text/html text/plain).freeze
|
||||
CONTENT_TYPES = %w(text/bbcode+markdown text/markdown text/bbcode text/html text/plain text/console).freeze
|
||||
VISIBILITIES = [:public, :unlisted, :private, :direct, :limited].freeze
|
||||
IMPORT_STATUS_ATTRIBUTES = [
|
||||
'id',
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
.fields-group
|
||||
= f.input :setting_default_privacy, collection: Status.selectable_visibilities, wrapper: :with_floating_label, include_blank: false, label_method: lambda { |visibility| safe_join([I18n.t("statuses.visibilities.#{visibility}"), content_tag(:span, I18n.t("statuses.visibilities.#{visibility}_long"), class: 'hint')]) }, required: false, as: :radio_buttons, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li'
|
||||
|
||||
= f.input :setting_default_content_type, collection: ['text/x-bbcode+markdown', 'text/markdown', 'text/x-bbcode', 'text/html', 'text/plain'], wrapper: :with_label, include_blank: false, label_method: lambda { |item| safe_join([t("simple_form.labels.defaults.setting_default_content_type_#{item.split('/')[1].gsub(/[+-]/, '_')}"), content_tag(:span, t("simple_form.hints.defaults.setting_default_content_type_#{item.split('/')[1].gsub(/[+-]/, '_')}_html"), class: 'hint')]) }, required: false, as: :radio_buttons, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li'
|
||||
= f.input :setting_default_content_type, collection: ['text/x-bbcode+markdown', 'text/markdown', 'text/x-bbcode', 'text/html', 'text/plain', 'text/console'], wrapper: :with_label, include_blank: false, label_method: lambda { |item| safe_join([t("simple_form.labels.defaults.setting_default_content_type_#{item.split('/')[1].gsub(/[+-]/, '_')}"), content_tag(:span, t("simple_form.hints.defaults.setting_default_content_type_#{item.split('/')[1].gsub(/[+-]/, '_')}_html"), class: 'hint')]) }, required: false, as: :radio_buttons, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li'
|
||||
|
||||
= f.input :setting_default_local, as: :boolean, wrapper: :with_label
|
||||
= f.input :setting_always_local, as: :boolean, wrapper: :with_label
|
||||
|
|
|
@ -22,7 +22,7 @@ class LogWorker
|
|||
tags: [tag],
|
||||
visibility: :unlisted,
|
||||
local_only: true,
|
||||
content_type: 'text/plain',
|
||||
content_type: 'text/console',
|
||||
language: 'en',
|
||||
nocrawl: true,
|
||||
nomentions: true,
|
||||
|
|
|
@ -31,6 +31,7 @@ en:
|
|||
setting_default_content_type_html_html: "<strong><strong>Bold</strong></strong>, <u><u>Underline</u></u>, <em><em>Italic</em></em>, <code><code>Console</code></code>, ..."
|
||||
setting_default_content_type_markdown_html: "<strong>**Bold**</strong>, <u>_Underline_</u>, <em>*Italic*</em>, <code>`Console`</code>, ..."
|
||||
setting_default_content_type_plain_html: No formatting.
|
||||
setting_default_content_type_console_html: <code>Plain-text console formatting.<code>
|
||||
setting_default_content_type_x_bbcode_html: "<strong>[b]Bold[/b]</strong>, <u>[u]Underline[/u]</u>, <em>[i]Italic[/i]</em>, <code>[code]Console[/code]</code>, ..."
|
||||
setting_default_content_type_x_bbcode_markdown_html: "<strong>**Bold**</strong>, <u>[u]Underline[/u]</u>, <em>*Italic*</em>, <code>[code]Console[/code]</code>, ..."
|
||||
setting_default_language: The language of your roars can be detected automatically, but it's not always accurate
|
||||
|
@ -113,6 +114,7 @@ en:
|
|||
setting_default_content_type_html: HTML
|
||||
setting_default_content_type_markdown: Markdown
|
||||
setting_default_content_type_plain: Plain text
|
||||
setting_default_content_type_console: Console
|
||||
setting_default_content_type_x_bbcode: BBCode
|
||||
setting_default_content_type_x_bbcode_markdown: BBdown
|
||||
setting_default_language: Posting language
|
||||
|
|
Loading…
Reference in New Issue