mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-13 14:45:12 +01:00
Merge pull request #223 from glitch-soc/glitchsoc/feature/configurable-status-size
Make character limit configurable (from tootsuite/mastodon#5697)
This commit is contained in:
commit
5a9982b425
@ -134,3 +134,6 @@ STREAMING_CLUSTER_NUM=1
|
|||||||
# If you use Docker, you may want to assign UID/GID manually.
|
# If you use Docker, you may want to assign UID/GID manually.
|
||||||
# UID=1000
|
# UID=1000
|
||||||
# GID=1000
|
# GID=1000
|
||||||
|
|
||||||
|
# Maximum allowed character count
|
||||||
|
# MAX_TOOT_CHARS=500
|
||||||
|
@ -19,6 +19,9 @@ import ImmutablePureComponent from 'react-immutable-pure-component';
|
|||||||
import { length } from 'stringz';
|
import { length } from 'stringz';
|
||||||
import { countableText } from '../util/counter';
|
import { countableText } from '../util/counter';
|
||||||
import ComposeAttachOptions from '../../../../glitch/components/compose/attach_options/index';
|
import ComposeAttachOptions from '../../../../glitch/components/compose/attach_options/index';
|
||||||
|
import initialState from '../../../initial_state';
|
||||||
|
|
||||||
|
const maxChars = initialState.max_toot_chars;
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
placeholder: { id: 'compose_form.placeholder', defaultMessage: 'What is on your mind?' },
|
placeholder: { id: 'compose_form.placeholder', defaultMessage: 'What is on your mind?' },
|
||||||
@ -205,7 +208,7 @@ export default class ComposeForm extends ImmutablePureComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const submitDisabled = disabled || this.props.is_uploading || length(text) > 500 || (text.length !== 0 && text.trim().length === 0);
|
const submitDisabled = disabled || this.props.is_uploading || length(text) > maxChars || (text.length !== 0 && text.trim().length === 0);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='compose-form'>
|
<div className='compose-form'>
|
||||||
@ -255,7 +258,7 @@ export default class ComposeForm extends ImmutablePureComponent {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className='compose-form__publish'>
|
<div className='compose-form__publish'>
|
||||||
<div className='character-counter__wrapper'><CharacterCounter max={500} text={text} /></div>
|
<div className='character-counter__wrapper'><CharacterCounter max={maxChars} text={text} /></div>
|
||||||
<div className='compose-form__publish-button-wrapper'>
|
<div className='compose-form__publish-button-wrapper'>
|
||||||
{
|
{
|
||||||
showSideArm ?
|
showSideArm ?
|
||||||
|
@ -2,10 +2,15 @@
|
|||||||
|
|
||||||
class InitialStateSerializer < ActiveModel::Serializer
|
class InitialStateSerializer < ActiveModel::Serializer
|
||||||
attributes :meta, :compose, :accounts,
|
attributes :meta, :compose, :accounts,
|
||||||
:media_attachments, :settings, :push_subscription
|
:media_attachments, :settings, :push_subscription,
|
||||||
|
:max_toot_chars
|
||||||
|
|
||||||
has_many :custom_emojis, serializer: REST::CustomEmojiSerializer
|
has_many :custom_emojis, serializer: REST::CustomEmojiSerializer
|
||||||
|
|
||||||
|
def max_toot_chars
|
||||||
|
StatusLengthValidator::MAX_CHARS
|
||||||
|
end
|
||||||
|
|
||||||
def custom_emojis
|
def custom_emojis
|
||||||
CustomEmoji.local.where(disabled: false)
|
CustomEmoji.local.where(disabled: false)
|
||||||
end
|
end
|
||||||
|
@ -4,7 +4,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer
|
|||||||
include RoutingHelper
|
include RoutingHelper
|
||||||
|
|
||||||
attributes :uri, :title, :description, :email,
|
attributes :uri, :title, :description, :email,
|
||||||
:version, :urls, :stats, :thumbnail
|
:version, :urls, :stats, :thumbnail, :max_toot_chars
|
||||||
|
|
||||||
def uri
|
def uri
|
||||||
Rails.configuration.x.local_domain
|
Rails.configuration.x.local_domain
|
||||||
@ -30,6 +30,10 @@ class REST::InstanceSerializer < ActiveModel::Serializer
|
|||||||
full_asset_url(instance_presenter.thumbnail.file.url) if instance_presenter.thumbnail
|
full_asset_url(instance_presenter.thumbnail.file.url) if instance_presenter.thumbnail
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def max_toot_chars
|
||||||
|
StatusLengthValidator::MAX_CHARS
|
||||||
|
end
|
||||||
|
|
||||||
def stats
|
def stats
|
||||||
{
|
{
|
||||||
user_count: instance_presenter.user_count,
|
user_count: instance_presenter.user_count,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class StatusLengthValidator < ActiveModel::Validator
|
class StatusLengthValidator < ActiveModel::Validator
|
||||||
MAX_CHARS = 512
|
MAX_CHARS = (ENV['MAX_TOOT_CHARS'] || 500).to_i
|
||||||
|
|
||||||
def validate(status)
|
def validate(status)
|
||||||
return unless status.local? && !status.reblog?
|
return unless status.local? && !status.reblog?
|
||||||
|
Loading…
Reference in New Issue
Block a user