Revision: 2195
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 14, 2007 02:28 by tictoc
Initial Code
require 'iconv' module PermalinkFu class << self attr_accessor :translation_to attr_accessor :translation_from def escape(str) s = Iconv.iconv(translation_to, translation_from, str).to_s s.gsub!(/\W+/, ' ') # all non-word chars to spaces s.strip! # ohh la la s.downcase! # s.gsub!(/\ +/, '-') # spaces to dashes, preferred separator char everywhere s end end def has_permalink(attr_name, permalink_field = nil) permalink_field ||= 'permalink' after_validation { |record| record.send("#{permalink_field}=", PermalinkFu.escape(record.send(attr_name).to_s)) if record.send(permalink_field).to_s.empty? } end end PermalinkFu.translation_to = 'ascii//ignore//translit' PermalinkFu.translation_from = 'utf-8'
Initial URL
http://svn.techno-weenie.net/projects/plugins/permalink_fu/
Initial Description
Initial Title
iconv conversion
Initial Tags
Initial Language
Ruby