During RubyConf I had a chance to sit next to John Long of RadintCMS fame. He’s a cool guy and Radiant is awesome for simple websites. I’m using Radiant for a few of my customers simple websites.

Not to be outdone in the coding arena, here are my important contributions to RadiantCMS. I call this collection of code “Inappropriate Text Filters.”

Markdown? Textile? You got nothing on me:

Filter #1: piglatin_filter.rb
class PigLatinFilter < TextFilter::Base
register 'PigLatin'
def filter(text)
text.split.collect{|word| pig(word)}.join(" ")
end
def pig(word)
leadingCap = word =~ /^A-Z/
word.downcase!
res = case word
when /^aeiouy/
word+"way"
when /^([^aeiouy]+)(.*)/
$2+$1+"ay"
else
word
end
leadingCap ? res.capitalize : res
end
end

Filter #2: crypt_filter.rb
class CryptoFilter < TextFilter::Base
register 'Crypto'
def filter(text)
text.crypt("da_salt_")
end
end

Filter #3: reverse_filter.rb
class ReverseFilter < TextFilter::Base
register 'Reverse'
def filter(text)
text.split.collect{|word| word.reverse!}.join(" ")
end
end