Commit c486be63fc1214836a4ba838e0ccd8ae8cf1b193

Authored by AntonioTerceiro
1 parent 1c6ab32a

ActionItem57: setting slug when setting title



git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@577 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing 1 changed file with 8 additions and 0 deletions   Show diff stats
app/models/article.rb
... ... @@ -18,4 +18,12 @@ class Article < Comatose::Page
18 18 @profile ||= Profile.find_by_identifier(self.full_path.split(/\//).first)
19 19 end
20 20  
  21 + def title=(value)
  22 + super
  23 + # taken from comatose, added a call to transliterate right before downcase.
  24 + if (self[:slug].nil? or self[:slug].empty?) and !self[:title].nil?
  25 + self[:slug] = self[:title].transliterate.downcase.gsub( /[^-a-z0-9~\s\.:;+=_]/, '').gsub(/[\s\.:;=_+]+/, '-').gsub(/[\-]{2,}/, '-').to_s
  26 + end
  27 + end
  28 +
21 29 end
... ...