Merge pull request #3904 from featheredtoast/all-caps-posts

FEATURE: New setting to allow all caps posts
This commit is contained in:
Robin Ward 2015-11-18 13:30:26 -05:00
commit 146ec4e1ba
4 changed files with 8 additions and 1 deletions

View File

@ -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/"

View File

@ -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:

View File

@ -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

View File

@ -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