Browse Source

Updates #wiki_format_provider plugin API with changes to wiki formatting (#20141).

git-svn-id: http://svn.redmine.org/redmine/trunk@14363 e93f8b46-1217-0410-a6f0-8f06a7374b81
tags/3.1.0
Jean-Philippe Lang 9 years ago
parent
commit
0a6f936626
2 changed files with 14 additions and 5 deletions
  1. 11
    4
      lib/redmine/plugin.rb
  2. 3
    1
      lib/redmine/wiki_formatting.rb

+ 11
- 4
lib/redmine/plugin.rb View File

@@ -359,11 +359,18 @@ module Redmine #:nodoc:
# Registers a wiki formatter.
#
# Parameters:
# * +name+ - human-readable name
# * +name+ - formatter name
# * +formatter+ - formatter class, which should have an instance method +to_html+
# * +helper+ - helper module, which will be included by wiki pages
def wiki_format_provider(name, formatter, helper)
Redmine::WikiFormatting.register(name, formatter, helper)
# * +helper+ - helper module, which will be included by wiki pages (optional)
# * +html_parser+ class reponsible for converting HTML to wiki text (optional)
# * +options+ - a Hash of options (optional)
# * :label - label for the formatter displayed in application settings
#
# Examples:
# wiki_format_provider(:custom_formatter, CustomFormatter, :label => "My custom formatter")
#
def wiki_format_provider(name, *args)
Redmine::WikiFormatting.register(name, *args)
end

# Returns +true+ if the plugin can be configured.

+ 3
- 1
lib/redmine/wiki_formatting.rb View File

@@ -35,7 +35,9 @@ module Redmine

formatter, helper, parser = args.any? ?
args :
%w(Formatter Helper HtmlParser).map {|m| "Redmine::WikiFormatting::#{name.classify}::#{m}".constantize}
%w(Formatter Helper HtmlParser).map {|m| "Redmine::WikiFormatting::#{name.classify}::#{m}".constantize rescue nil}

raise "A formatter class is required" if formatter.nil?

@@formatters[name] = {
:formatter => formatter,

Loading…
Cancel
Save