per-project-formatting.diff

Ebrahim Mohammadi, 2011-05-04 00:09

Download (4.09 KB)

View differences:

app/controllers/wiki_controller.rb Wed May 04 02:08:42 2011 +0430
273 273

  
274 274
  # Returns the default content of a new wiki page
275 275
  def initial_page_content(page)
276
    helper = Redmine::WikiFormatting.helper_for(Setting.text_formatting)
276
    helper = Redmine::WikiFormatting.helper_for_project(@project)
277 277
    extend helper unless self.instance_of?(helper)
278 278
    helper.instance_method(:initial_page_content).bind(self).call(page)
279 279
  end
app/helpers/application_helper.rb Wed May 04 02:08:42 2011 +0430
456 456
    project = options[:project] || @project || (obj && obj.respond_to?(:project) ? obj.project : nil)
457 457
    only_path = options.delete(:only_path) == false ? false : true
458 458

  
459
    text = Redmine::WikiFormatting.to_html(Setting.text_formatting, text, :object => obj, :attribute => attr) { |macro, args| exec_macro(macro, obj, args) }
459
    text = Redmine::WikiFormatting.to_html(Redmine::WikiFormatting.text_formatting_of(project), text, :object => obj, :attribute => attr) { |macro, args| exec_macro(macro, obj, args) }
460 460
    
461 461
    @parsed_headings = []
462 462
    text = parse_non_pre_blocks(text) do |text|
......
931 931
  private
932 932

  
933 933
  def wiki_helper
934
    helper = Redmine::WikiFormatting.helper_for(Setting.text_formatting)
934
    helper = Redmine::WikiFormatting.helper_for_project(@project)
935 935
    extend helper
936 936
    return self
937 937
  end
app/models/project.rb Wed May 04 02:08:42 2011 +0430
78 78
  validates_format_of :identifier, :with => /^(?!\d+$)[a-z0-9\-]*$/, :if => Proc.new { |p| p.identifier_changed? }
79 79
  # reserved words
80 80
  validates_exclusion_of :identifier, :in => %w( new )
81
  validates_inclusion_of :text_formatting, :in => Redmine::WikiFormatting.format_names, :allow_blank => true
81 82

  
82 83
  before_destroy :delete_all_members
83 84

  
......
553 554
    'custom_field_values',
554 555
    'custom_fields',
555 556
    'tracker_ids',
557
	'text_formatting',
556 558
    'issue_custom_field_ids'
557 559

  
558 560
  safe_attributes 'enabled_module_names',
app/views/projects/_form.rhtml Wed May 04 02:08:42 2011 +0430
17 17
<p><%= f.check_box :is_public %></p>
18 18
<%= wikitoolbar_for 'project_description' %>
19 19

  
20
<p><%= f.select :text_formatting, Redmine::WikiFormatting.format_names, :include_blank => l(:label_default), :label => :setting_text_formatting %></p>
21

  
20 22
<% @project.custom_field_values.each do |value| %>
21 23
	<p><%= custom_field_tag_with_label :project, value %></p>
22 24
<% end %>
db/migrate/20110502193152_add_text_formatting_to_projects.rb Wed May 04 02:08:42 2011 +0430
1
class AddTextFormattingToProjects < ActiveRecord::Migration
2
  def self.up
3
    add_column :projects, :text_formatting, :string
4
  end
5

  
6
  def self.down
7
    remove_column :projects, :text_formatting
8
  end
9
end
lib/redmine/wiki_formatting.rb Wed May 04 02:08:42 2011 +0430
39 39
        (entry && entry[:helper]) || Redmine::WikiFormatting::NullFormatter::Helper
40 40
      end
41 41
      
42
      def text_formatting_of(project)
43
        project && project.text_formatting && !project.text_formatting.empty? && project.text_formatting || Setting.text_formatting
44
      end
45

  
46
      def helper_for_project(project)
47
        helper_for(text_formatting(project))
48
      end
49

  
42 50
      def format_names
43 51
        @@formatters.keys.map
44 52
      end