patch.diff
| app/models/wiki_macro.rb | ||
|---|---|---|
| 17 | 17 |
"{{#{name}}}"
|
| 18 | 18 |
end |
| 19 | 19 | |
| 20 |
def exec(args, params) |
|
| 20 |
def exec(args, params, text)
|
|
| 21 | 21 |
self.content.gsub(MACRO_ARGUMENT_RE) do |match| |
| 22 | 22 |
escape = $1 |
| 23 | 23 |
if $2 |
| ... | ... | |
| 27 | 27 |
index = $3.to_i |
| 28 | 28 |
(index > 0 && index <= args.size) ? self.escape(args[index-1], escape) : '' |
| 29 | 29 |
else |
| 30 |
'' # TODO self.class.escape(text)
|
|
| 30 |
h(text)
|
|
| 31 | 31 |
end |
| 32 | 32 |
end |
| 33 | 33 |
end |
| ... | ... | |
| 47 | 47 |
macro_name = self.name.to_sym |
| 48 | 48 |
Redmine::WikiFormatting::Macros.register do |
| 49 | 49 |
desc macro_desc |
| 50 |
macro macro_name do |obj, args| # TODO ..., text for Redmine > 1.4 |
|
| 50 |
macro macro_name do |obj, args, text| # TODO ..., text for Redmine > 1.4
|
|
| 51 | 51 |
named = {}
|
| 52 | 52 |
unnamed = [] |
| 53 | 53 |
args.each do |arg| |
| ... | ... | |
| 58 | 58 |
unnamed << arg |
| 59 | 59 |
end |
| 60 | 60 |
end |
| 61 |
wiki_macro.reload.exec(unnamed, named) # TODO text, ... |
|
| 61 |
wiki_macro.reload.exec(unnamed, named, text) # TODO text, ...
|
|
| 62 | 62 |
end |
| 63 | 63 |
end |
| 64 | 64 |
end |
| init.rb | ||
|---|---|---|
| 87 | 87 |
end |
| 88 | 88 |
end |
| 89 | 89 |
end |
| 90 | ||
| 91 |
WikiMacro.register_all! |
|
| 92 | ||
| 93 | 90 |
end |
| lib/wiking_macros_definitions_patch.rb | ||
|---|---|---|
| 7 | 7 |
base.class_eval do |
| 8 | 8 |
unloadable |
| 9 | 9 | |
| 10 |
alias_method_chain :macro_exists?, :custom |
|
| 10 | 11 |
alias_method_chain :exec_macro, :custom |
| 11 | 12 |
end |
| 12 | 13 |
end |
| 13 | 14 | |
| 14 | 15 |
module InstanceMethods |
| 15 | 16 | |
| 16 |
def exec_macro_with_custom(name, obj, args) |
|
| 17 |
def macro_exists_with_custom?(name) |
|
| 18 |
unless macro_exists_without_custom?(name) |
|
| 19 |
macro = WikiMacro.find_by_name(name) |
|
| 20 |
return false unless macro |
|
| 21 |
macro.register! |
|
| 22 |
end |
|
| 23 |
true |
|
| 24 |
end |
|
| 25 | ||
| 26 |
def exec_macro_with_custom(name, obj, args, text) |
|
| 17 | 27 |
method_name = "macro_#{name.downcase}"
|
| 18 | 28 |
unless respond_to?(method_name) |
| 19 | 29 |
macro = WikiMacro.find_by_name(name) |
| ... | ... | |
| 25 | 35 |
macro.register! unless available_macros.has_key?(macro.name.to_sym) |
| 26 | 36 |
end |
| 27 | 37 |
end |
| 28 |
exec_macro_without_custom(name, obj, args) |
|
| 38 |
exec_macro_without_custom(name, obj, args, text)
|
|
| 29 | 39 |
end |
| 30 | 40 | |
| 31 | 41 |
end |