github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

heavysixer / name_nanny

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 5
    • 1
  • Source
  • Commits
  • Network (1)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Click here to lend your support to: name_nanny and make a donation at www.pledgie.com ! Edit Pledgie Setup

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Simple plugin to encourage user’s to be on their best behavior when they choosing a username or filling out a form. 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 “hoar”,”h0ar”,”wh0r3” (you get the picture). — Read more

  cancel

http://www.locusfoc.us

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Added a proper README and removed the .freeze statement because it appeard 
to be causing a memory leak according to bleakhouse. 
heavysixer (author)
Thu May 29 11:50:16 -0700 2008
commit  58ab5de0d2b84503c62bc02e29a8b9ee2f431915
tree    ec0b4f3f3e15954e2a1a247c12da828b6cd7de41
parent  55e9e2b15d6aa9c084fc3d89eeadecd11e564189
name_nanny /
name age
history
message
file README Loading commit data...
file init.rb
directory lib/
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
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server