Project

General

Profile

Feature #8095 » per-project-formatting.diff

Ebrahim Mohammadi, 2011-05-04 00:09

View differences:

app/controllers/wiki_controller.rb Tue May 03 07:33:46 2011 +0000 → app/controllers/wiki_controller.rb Wed May 04 02:08:42 2011 +0430
# 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
app/helpers/application_helper.rb Tue May 03 07:33:46 2011 +0000 → app/helpers/application_helper.rb Wed May 04 02:08:42 2011 +0430
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|
......
private
def wiki_helper
helper = Redmine::WikiFormatting.helper_for(Setting.text_formatting)
helper = Redmine::WikiFormatting.helper_for_project(@project)
extend helper
return self
end
app/models/project.rb Tue May 03 07:33:46 2011 +0000 → app/models/project.rb Wed May 04 02:08:42 2011 +0430
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
......
'custom_field_values',
'custom_fields',
'tracker_ids',
'text_formatting',
'issue_custom_field_ids'
safe_attributes 'enabled_module_names',
app/views/projects/_form.rhtml Tue May 03 07:33:46 2011 +0000 → app/views/projects/_form.rhtml Wed May 04 02:08:42 2011 +0430
<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 %>
/dev/null Thu Jan 01 00:00:00 1970 +0000 → db/migrate/20110502193152_add_text_formatting_to_projects.rb Wed May 04 02:08:42 2011 +0430
class AddTextFormattingToProjects < ActiveRecord::Migration
def self.up
add_column :projects, :text_formatting, :string
end
def self.down
remove_column :projects, :text_formatting
end
end
lib/redmine/wiki_formatting.rb Tue May 03 07:33:46 2011 +0000 → lib/redmine/wiki_formatting.rb Wed May 04 02:08:42 2011 +0430
(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
(1-1/3)