Converts a string to a URL style permalink.
class String
def to_permalink
s = self
s = Iconv.iconv('ascii//ignore//translit', 'utf-8', s).to_s
s.gsub!(/^W+|W+$/, '')
s.gsub!(/W+/, '-')
s.strip!
s.downcase!
s.squeeze!(' ')
s.gsub(/ +/, '-')
end
end


Leave a Reply