From c486be63fc1214836a4ba838e0ccd8ae8cf1b193 Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Thu, 27 Sep 2007 20:20:08 +0000 Subject: [PATCH] ActionItem57: setting slug when setting title --- app/models/article.rb | 8 ++++++++ 1 file changed, 8 insertions(+), 0 deletions(-) diff --git a/app/models/article.rb b/app/models/article.rb index 737eb84..338a0db 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -18,4 +18,12 @@ class Article < Comatose::Page @profile ||= Profile.find_by_identifier(self.full_path.split(/\//).first) end + def title=(value) + super + # taken from comatose, added a call to transliterate right before downcase. + if (self[:slug].nil? or self[:slug].empty?) and !self[:title].nil? + self[:slug] = self[:title].transliterate.downcase.gsub( /[^-a-z0-9~\s\.:;+=_]/, '').gsub(/[\s\.:;=_+]+/, '-').gsub(/[\-]{2,}/, '-').to_s + end + end + end -- libgit2 0.21.2