Works with Redmine 2.3 (no patch required)
This commit is contained in:
parent
b93256fc74
commit
2700f0f2a8
|
@ -7,7 +7,7 @@ NOT THE ORIGINAL
|
|||
================
|
||||
|
||||
This is a fork.
|
||||
**NOTE works only on Redmine > v2.0**
|
||||
**NOTE tested only on Redmine v2.3**
|
||||
|
||||
Overview
|
||||
========
|
||||
|
|
|
@ -61,10 +61,8 @@ module WikiExternalFilterHelper
|
|||
Rails.logger.debug "cache saved: #{cache_key} expires #{expires.seconds}"
|
||||
rescue
|
||||
Rails.logger.error "Failed to save cache: #{cache_key}, result content #{result[:content]}, error: $!"
|
||||
end
|
||||
else
|
||||
raise "please set expires time under plugins settings"
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
raise "Error applying external filter: stdout is #{result[:content]}, stderr is #{result[:errors]}"
|
||||
end
|
||||
|
@ -94,7 +92,7 @@ module WikiExternalFilterHelper
|
|||
content = []
|
||||
errors = ""
|
||||
|
||||
text = text.gsub("<br />", "\n")
|
||||
text = text.gsub("<br />", "\n") if text
|
||||
Rails.logger.debug "\n Text #{text} \n"
|
||||
|
||||
info['outputs'].each do |out|
|
||||
|
@ -107,22 +105,21 @@ module WikiExternalFilterHelper
|
|||
# redirection so we can get more info in the case of error.
|
||||
begin
|
||||
require 'open4'
|
||||
|
||||
Open4::popen4(out['command']) { |pid, fin, fout, ferr|
|
||||
fin.write out['prolog'] if out.key?('prolog')
|
||||
fin.puts out['prolog'] if out.key?('prolog')
|
||||
fin.write text
|
||||
fin.write out['epilog'] if out.key?('epilog')
|
||||
fin.write "\n"+out['epilog'] if out.key?('epilog')
|
||||
fin.close
|
||||
c, e = [fout.read, ferr.read]
|
||||
}
|
||||
rescue LoadError
|
||||
IO.popen(out['command'], 'r+b') { |f|
|
||||
f.write out['prolog'] if out.key?('prolog')
|
||||
f.puts out['prolog']+"\n" if out.key?('prolog')
|
||||
f.write text
|
||||
f.write out['epilog'] if out.key?('epilog')
|
||||
f.write "\n"+out['epilog'] if out.key?('epilog')
|
||||
f.close_write
|
||||
c = f.read
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
Rails.logger.debug("child status: sig=#{$?.termsig}, exit=#{$?.exitstatus}")
|
||||
|
|
16
init.rb
16
init.rb
|
@ -25,22 +25,6 @@ Redmine::Plugin.register :wiki_external_filter do
|
|||
m = WikiExternalFilterHelper::Macro.new(self, args, text, obj.respond_to?('page') ? obj.page.attachments : nil, name, info)
|
||||
m.render.html_safe
|
||||
end
|
||||
|
||||
# code borrowed from wiki latex plugin
|
||||
# code borrowed from wiki template macro
|
||||
desc info['description']
|
||||
macro (name + "_include").to_sym do |obj, args, text|
|
||||
page = Wiki.find_page(args.to_s, :project => @project)
|
||||
raise 'Page not found' if page.nil? || !User.current.allowed_to?(:view_wiki_pages, page.wiki.project)
|
||||
|
||||
@included_wiki_pages ||= []
|
||||
raise 'Circular inclusion detected' if @included_wiki_pages.include?(page.title)
|
||||
@included_wiki_pages << page.title
|
||||
m = WikiExternalFilterHelper::Macro.new(self, args, page.content.text, page.attachments, name, info)
|
||||
@included_wiki_pages.pop
|
||||
m.render_block(args.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Reference in New Issue