From 8a1535b683007bce8674c0d11b14597b700af790 Mon Sep 17 00:00:00 2001
From: Anton Orel <eagle.anton@gmail.com>
Date: Mon, 16 Apr 2012 12:39:00 +0400
Subject: [PATCH] Allow comma in wiki page title

---
 app/models/wiki.rb                         |    4 ++--
 app/models/wiki_page.rb                    |    2 +-
 app/views/projects/settings/_wiki.html.erb |    2 +-
 config/routes.rb                           |   12 ++++++------
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/app/models/wiki.rb b/app/models/wiki.rb
index 6cdfa24..ed37dfe 100644
--- a/app/models/wiki.rb
+++ b/app/models/wiki.rb
@@ -24,7 +24,7 @@ class Wiki < ActiveRecord::Base
   acts_as_watchable
 
   validates_presence_of :start_page
-  validates_format_of :start_page, :with => /^[^,\.\/\?\;\|\:]*$/
+  validates_format_of :start_page, :with => /^[^\.\/\;\|\:]*$/
 
   safe_attributes 'start_page'
 
@@ -89,7 +89,7 @@ class Wiki < ActiveRecord::Base
   # turn a string into a valid page title
   def self.titleize(title)
     # replace spaces with _ and remove unwanted caracters
-    title = title.gsub(/\s+/, '_').delete(',./?;|:') if title
+    title = title.gsub(/\s+/, '_').delete('./?;|:') if title
     # upcase the first letter
     title = (title.slice(0..0).upcase + (title.slice(1..-1) || '')) if title
     title
diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb
index 6088e48..53bd784 100644
--- a/app/models/wiki_page.rb
+++ b/app/models/wiki_page.rb
@@ -40,7 +40,7 @@ class WikiPage < ActiveRecord::Base
   attr_accessor :redirect_existing_links
 
   validates_presence_of :title
-  validates_format_of :title, :with => /^[^,\.\/\?\;\|\s]*$/
+  validates_format_of :title, :with => /^[^\.\/\?\;\|\s]*$/
   validates_uniqueness_of :title, :scope => :wiki_id, :case_sensitive => false
   validates_associated :content
 
diff --git a/app/views/projects/settings/_wiki.html.erb b/app/views/projects/settings/_wiki.html.erb
index 0ef494b..53bfeb2 100644
--- a/app/views/projects/settings/_wiki.html.erb
+++ b/app/views/projects/settings/_wiki.html.erb
@@ -5,7 +5,7 @@
 
 <div class="box tabular">
 <p><%= f.text_field :start_page, :size => 60, :required => true %>
-<em class="info"><%= l(:text_unallowed_characters) %>: , . / ? ; : |</em></p>
+<em class="info"><%= l(:text_unallowed_characters) %>: . / ? ; : |</em></p>
 </div>
 
 <div class="contextual">
diff --git a/config/routes.rb b/config/routes.rb
index f1b6ff0..3788f7b 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -20,9 +20,9 @@ ActionController::Routing::Routes.draw do |map|
               :conditions => {:method => :get}
 
   map.connect 'projects/:id/wiki', :controller => 'wikis',
-              :action => 'edit', :conditions => {:method => :post}
+              :action => 'edit', :conditions => {:method => :post}, :requirements => { :id => /.*/ }
   map.connect 'projects/:id/wiki/destroy', :controller => 'wikis',
-              :action => 'destroy', :conditions => {:method => [:get, :post]}
+              :action => 'destroy', :conditions => {:method => [:get, :post]}, :requirements => { :id => /.*/ }
 
   map.with_options :controller => 'messages' do |messages_routes|
     messages_routes.with_options :conditions => {:method => :get} do |messages_views|
@@ -179,9 +179,9 @@ ActionController::Routing::Routes.draw do |map|
 
     project.wiki_start_page 'wiki', :controller => 'wiki', :action => 'show', :conditions => {:method => :get}
     project.wiki_index 'wiki/index', :controller => 'wiki', :action => 'index', :conditions => {:method => :get}
-    project.wiki_diff 'wiki/:id/diff/:version', :controller => 'wiki', :action => 'diff', :version => nil
-    project.wiki_diff 'wiki/:id/diff/:version/vs/:version_from', :controller => 'wiki', :action => 'diff'
-    project.wiki_annotate 'wiki/:id/annotate/:version', :controller => 'wiki', :action => 'annotate'
+    project.wiki_diff 'wiki/:id/diff/:version', :controller => 'wiki', :action => 'diff', :version => nil, :requirements => { :id => /.*/ }
+    project.wiki_diff 'wiki/:id/diff/:version/vs/:version_from', :controller => 'wiki', :action => 'diff', :requirements => { :id => /.*/ }
+    project.wiki_annotate 'wiki/:id/annotate/:version', :controller => 'wiki', :action => 'annotate', :requirements => { :id => /.*/ }
     project.resources :wiki, :except => [:new, :create], :member => {
       :rename => [:get, :post],
       :history => :get,
@@ -191,7 +191,7 @@ ActionController::Routing::Routes.draw do |map|
     }, :collection => {
       :export => :get,
       :date_index => :get
-    }
+    }, :requirements => { :id => /.*/ }
   end
 
   map.connect 'news', :controller => 'news', :action => 'index'
-- 
1.7.10

