mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 18:35:23 +08:00
FEATURE: New setting to allow all caps posts
Adds a setting to ignore text_sentinel's check on all caps content.
This commit is contained in:
parent
0ede6b5ed6
commit
cf86f27415
|
@ -1059,6 +1059,7 @@ en:
|
||||||
title_max_word_length: "The maximum allowed word length, in characters, in a topic title."
|
title_max_word_length: "The maximum allowed word length, in characters, in a topic title."
|
||||||
title_min_entropy: "The minimum entropy (unique characters, non-english count for more) required for a topic title."
|
title_min_entropy: "The minimum entropy (unique characters, non-english count for more) required for a topic title."
|
||||||
body_min_entropy: "The minimum entropy (unique characters, non-english count for more) required for a post body."
|
body_min_entropy: "The minimum entropy (unique characters, non-english count for more) required for a post body."
|
||||||
|
allow_uppercase_posts: "Allow all caps in a topic title or a post body."
|
||||||
|
|
||||||
title_fancy_entities: "Convert common ASCII characters to fancy HTML entities in topic titles, ala SmartyPants http://daringfireball.net/projects/smartypants/"
|
title_fancy_entities: "Convert common ASCII characters to fancy HTML entities in topic titles, ala SmartyPants http://daringfireball.net/projects/smartypants/"
|
||||||
|
|
||||||
|
|
|
@ -377,6 +377,7 @@ posting:
|
||||||
default: 255
|
default: 255
|
||||||
max: 255
|
max: 255
|
||||||
title_min_entropy: 10
|
title_min_entropy: 10
|
||||||
|
allow_uppercase_posts: false
|
||||||
title_prettify: true
|
title_prettify: true
|
||||||
title_fancy_entities: true
|
title_fancy_entities: true
|
||||||
min_private_message_title_length:
|
min_private_message_title_length:
|
||||||
|
|
|
@ -73,7 +73,7 @@ class TextSentinel
|
||||||
|
|
||||||
def seems_quiet?
|
def seems_quiet?
|
||||||
# We don't allow all upper case content in english
|
# We don't allow all upper case content in english
|
||||||
not((@text =~ /[A-Z]+/) && !(@text =~ /[^[:ascii:]]/) && (@text == @text.upcase))
|
SiteSetting.allow_uppercase_posts || not((@text =~ /[A-Z]+/) && !(@text =~ /[^[:ascii:]]/) && (@text == @text.upcase))
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -74,6 +74,11 @@ describe TextSentinel do
|
||||||
expect(TextSentinel.new(valid_string.upcase)).not_to be_valid
|
expect(TextSentinel.new(valid_string.upcase)).not_to be_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "allows all caps topics when loud posts are allowed" do
|
||||||
|
SiteSetting.stubs(:allow_uppercase_posts).returns(true)
|
||||||
|
expect(TextSentinel.new(valid_string.upcase)).to be_valid
|
||||||
|
end
|
||||||
|
|
||||||
it "enforces the minimum entropy" do
|
it "enforces the minimum entropy" do
|
||||||
expect(TextSentinel.new(valid_string, min_entropy: 16)).to be_valid
|
expect(TextSentinel.new(valid_string, min_entropy: 16)).to be_valid
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user