lib/permalink_fu.rb
# This method does the actual permalink escaping.
This method does the actual permalink escaping.
This method does the actual permalink escaping .
def escape(string)
      result = ActiveSupport::Inflector.transliterate(string.to_s)
      result = Iconv.iconv(translation_to, translation_from, result).to_s if translation_to && translation_from
      result.gsub!(/[^\x00-\x7F]+/, '') 
      result.gsub!(/[^\w_ \-]+/i,   '') 
      result.gsub!(/[ \-]+/i,      '-') 
      result.gsub!(/^\-|\-$/i,      '') 
      result.downcase!
      result.size.zero? ? random_permalink(string) : result
    rescue
      random_permalink(string)
    end
def escape ( string ) result = ActiveSupport :: Inflector . transliterate ( string . to_s ) result = Iconv . iconv ( translation_to , translation_from , result ) . to_s if translation_to && translation_from result . gsub! ( / [^ \x00 - \x7F ]+ / , '' ) result . gsub! ( / [^ \w _  \- ]+ /i , '' ) result . gsub! ( / [  \- ]+ /i , '-' ) result . gsub! ( / ^ \- | \- $ /i , '' ) result . downcase! result . size . zero? ? random_permalink ( string ) : result rescue random_permalink ( string ) end
This method does the actual permalink escaping.
This method does the actual permalink escaping .
# Remove anything non-ASCII entirely (e.g. diacritics). # Remove unwanted chars. # No more than one of the separator in a row. # Remove leading/trailing separator.
string