heavysixer / name_nanny
- Source
- Commits
- Network (1)
- Issues (0)
- Downloads (0)
- Wiki (1)
- Graphs
-
Branch:
master
heavysixer (author)
Thu May 29 11:50:16 -0700 2008
README
= NameNanny
I needed functionality to encourage user’s to be on their best behavior when they choosing a username or filling out a fo
rm. Bad behavior can come in many forms but specifically, I wanted to prevent people from registering usernames like
“administrator”, “root”, “abuse”,”support” etc. I also didn’t want people to pick names like “whore” or even “h
oar”,”h0ar”,”wh0r3” (you get the picture). It occurred to me that others would like this functionality too, so I created
the name_nanny plug-in which can be employed in a couple of ways.
== Example usage
In the model you can use:
validates_wholesomeness_of :login
This will check the login against values in two text files in the plug-in directory “badwords.txt”, and “res
trictedwords.txt”. By default a match returns an non-descript error like “this username is already taken”. I chose a gene
ralized error to dissuade users from trying to hack around the filter and find a word i missed.
If you are filtering the body of text you may want to allow words like “administrator” in the body of the document. Ther
efore namenanny has a second method called “bleeptext”, which you can use thusly:
def before_save
%w(description, title, author, tags).each do |column|
if self[column.to_sym]
self[column.to_sym] = bleep_text(self[column.to_sym])
end
end
end
A sample output might look like this:
p = Post.new
p.description = "Step two: put your dick in a box."
p.save
puts p.description = "Step two: put your bleeep in a box."
You can also replace the bleeptext method with a smurftext method, which produces an equally hilarious: “Step two: put yo
ur smurf in a box.”
== Authors, credits, contact
Authors:: Mark Daggett
Original announcement:: http://locusfoc.us/2007/2/13/name-nanny-plugin


