# HG changeset patch
# Parent f4d8b015a399e930cd47301654223894099e63f6
diff -r f4d8b015a399 -r 06a2a2a30cd6 app/controllers/wiki_controller.rb
--- a/app/controllers/wiki_controller.rb	Tue May 03 07:33:46 2011 +0000
+++ b/app/controllers/wiki_controller.rb	Wed May 04 02:08:42 2011 +0430
@@ -273,7 +273,7 @@
 
   # Returns the default content of a new wiki page
   def initial_page_content(page)
-    helper = Redmine::WikiFormatting.helper_for(Setting.text_formatting)
+    helper = Redmine::WikiFormatting.helper_for_project(@project)
     extend helper unless self.instance_of?(helper)
     helper.instance_method(:initial_page_content).bind(self).call(page)
   end
diff -r f4d8b015a399 -r 06a2a2a30cd6 app/helpers/application_helper.rb
--- a/app/helpers/application_helper.rb	Tue May 03 07:33:46 2011 +0000
+++ b/app/helpers/application_helper.rb	Wed May 04 02:08:42 2011 +0430
@@ -456,7 +456,7 @@
     project = options[:project] || @project || (obj && obj.respond_to?(:project) ? obj.project : nil)
     only_path = options.delete(:only_path) == false ? false : true
 
-    text = Redmine::WikiFormatting.to_html(Setting.text_formatting, text, :object => obj, :attribute => attr) { |macro, args| exec_macro(macro, obj, args) }
+    text = Redmine::WikiFormatting.to_html(Redmine::WikiFormatting.text_formatting_of(project), text, :object => obj, :attribute => attr) { |macro, args| exec_macro(macro, obj, args) }
     
     @parsed_headings = []
     text = parse_non_pre_blocks(text) do |text|
@@ -931,7 +931,7 @@
   private
 
   def wiki_helper
-    helper = Redmine::WikiFormatting.helper_for(Setting.text_formatting)
+    helper = Redmine::WikiFormatting.helper_for_project(@project)
     extend helper
     return self
   end
diff -r f4d8b015a399 -r 06a2a2a30cd6 app/models/project.rb
--- a/app/models/project.rb	Tue May 03 07:33:46 2011 +0000
+++ b/app/models/project.rb	Wed May 04 02:08:42 2011 +0430
@@ -78,6 +78,7 @@
   validates_format_of :identifier, :with => /^(?!\d+$)[a-z0-9\-]*$/, :if => Proc.new { |p| p.identifier_changed? }
   # reserved words
   validates_exclusion_of :identifier, :in => %w( new )
+  validates_inclusion_of :text_formatting, :in => Redmine::WikiFormatting.format_names, :allow_blank => true
 
   before_destroy :delete_all_members
 
@@ -553,6 +554,7 @@
     'custom_field_values',
     'custom_fields',
     'tracker_ids',
+	'text_formatting',
     'issue_custom_field_ids'
 
   safe_attributes 'enabled_module_names',
diff -r f4d8b015a399 -r 06a2a2a30cd6 app/views/projects/_form.rhtml
--- a/app/views/projects/_form.rhtml	Tue May 03 07:33:46 2011 +0000
+++ b/app/views/projects/_form.rhtml	Wed May 04 02:08:42 2011 +0430
@@ -17,6 +17,8 @@
 <p><%= f.check_box :is_public %></p>
 <%= wikitoolbar_for 'project_description' %>
 
+<p><%= f.select :text_formatting, Redmine::WikiFormatting.format_names, :include_blank => l(:label_default), :label => :setting_text_formatting %></p>
+
 <% @project.custom_field_values.each do |value| %>
 	<p><%= custom_field_tag_with_label :project, value %></p>
 <% end %>
diff -r f4d8b015a399 -r 06a2a2a30cd6 db/migrate/20110502193152_add_text_formatting_to_projects.rb
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/db/migrate/20110502193152_add_text_formatting_to_projects.rb	Wed May 04 02:08:42 2011 +0430
@@ -0,0 +1,9 @@
+class AddTextFormattingToProjects < ActiveRecord::Migration
+  def self.up
+    add_column :projects, :text_formatting, :string
+  end
+
+  def self.down
+    remove_column :projects, :text_formatting
+  end
+end
diff -r f4d8b015a399 -r 06a2a2a30cd6 lib/redmine/wiki_formatting.rb
--- a/lib/redmine/wiki_formatting.rb	Tue May 03 07:33:46 2011 +0000
+++ b/lib/redmine/wiki_formatting.rb	Wed May 04 02:08:42 2011 +0430
@@ -39,6 +39,14 @@
         (entry && entry[:helper]) || Redmine::WikiFormatting::NullFormatter::Helper
       end
       
+      def text_formatting_of(project)
+        project && project.text_formatting && !project.text_formatting.empty? && project.text_formatting || Setting.text_formatting
+      end
+
+      def helper_for_project(project)
+        helper_for(text_formatting(project))
+      end
+
       def format_names
         @@formatters.keys.map
       end
