Permalinks

I know there are various plugins (i have my own as well) for creating permalinks for clean URLs. I'm curious to know what the core team thinks about including such a feature into rails core or if this is something the core believes should remain a plugin?

We have dasherizer, camelize, etc. and thought it would be nice to have a "permalizer" as well. What are your thoughts?

I would welcome such feature if it would be translating non-english chars to english:

“čćž-šđ”.permalize #-> “ccz-sd”

Rick Olson’s permalink_fu uses Iconv for this, which doesn’t work good with Ruby 1.8.4 (in my experience).

I'm no expert in this sort of area, but I usually do something like

string.chars.normalize :d

Then examine the result and discard anything in the range c >= 0x300 && c < 0x370, which is the range for combining marks

Fred

I ask because I have my own that I've been using and was thinking about submitting it as a patch, but wanted to get some feedback before pursuing it. Here's the basics of it to help generate some further discussion:

require 'iconv'

module Permalizer   def permalize!     permalink!(self)   end

  def permalize     string = self.dup     permalink!(string)   end

  def permalink!(word)     (Iconv.new('US-ASCII//TRANSLIT', 'utf-8').iconv word).gsub(/[^\w\s\-\—]/,'').gsub(/[^\w]|[\_]/,' ').split.join('-').downcase   end end

Mislav Marohni�? wrote:

We have dasherizer, camelize, etc. and thought it would be nice to have a "permalizer" as well. What are your thoughts?

I don't think it's something that belongs in core. There are so many different requirements as to how people want word-based URLs to look like that it doesn't feel like we stand to gain much by standardizing.

Why don’t you submit a patch to permalink_fu ?

Since it doesn't seem like this something that will be added to core, I think I'll probably look at doing that.

Courtenay wrote: