From 19440f038fdcb115d5decd3c74c0bc5d96b7476d Mon Sep 17 00:00:00 2001 From: Alexander Tsvyashchenko Date: Sat, 27 Mar 2010 01:22:42 +0200 Subject: [PATCH] - More fixes to readme. - Made popen4 optional. --- README.txt | 45 +++++++++++----------- app/helpers/wiki_external_filter_helper.rb | 29 ++++++++++---- 2 files changed, 44 insertions(+), 30 deletions(-) diff --git a/README.txt b/README.txt index 5a2dee7..1d5c433 100644 --- a/README.txt +++ b/README.txt @@ -20,28 +20,28 @@ ones is typically as easy as adding several lines in plugin config file. Installation ============ -Get sources from [github](http://github.com/ndl/wiki_external_filter). - -See [Installing a plugin](http://www.redmine.org/wiki/redmine/Plugins) on -Redmine site. - -Additionally, copy wiki_external_filter.yml from config folder of plugin -directory to the config folder of your redmine installation. - -After installation it's **strongly recommended** to go to plugin settings and -configure caching. Note that RoR file-based caching suggested by default does -not implement proper cache expiration: you should either setup a cron task to -clean cache or do it manually from time to time. - -To successfully use macros with complex argument expressions, it's necessary -to patch core Redmine components as follows: - - * [Change MACROS_RE](http://www.redmine.org/issues/3061) regexp not to stop - too early - in the issue description textile wiki formatter is mentioned, - but in fact this change should be done for whatever wiki formatter you use. - * [Change arguments parsing](http://www.redmine.org/boards/3/topics/4987#message-9854) - again, should be done for whatever wiki formatter you use. - * Additionally, for some of the formatters escaping should be avoided for - macro arguments. +1. It's recommended (but not required) to install + [popen4](http://popen4.rubyforge.org/) library first as without it plugin is + unable to capture stderr output of external command, so it might be hard to debug + it if things go wrong. +2. Get sources from [github](http://github.com/ndl/wiki_external_filter). +3. See [Installing a plugin](http://www.redmine.org/wiki/redmine/Plugins) on + Redmine site. +4. Copy wiki_external_filter.yml from config folder of plugin + directory to the config folder of your redmine installation. +5. After installation it's **strongly recommended** to go to plugin settings and + configure caching. Note that RoR file-based caching suggested by default does + not implement proper cache expiration: you should either setup a cron task to + clean cache or do it manually from time to time. +6. To successfully use macros with complex argument expressions, it's necessary + to patch wiki engine you use as follows: + * [Change MACROS_RE](http://www.redmine.org/issues/3061) regexp not to stop + too early - in the issue description textile wiki formatter is mentioned, + but in fact this change should be done for whatever wiki formatter you use. + * [Change arguments parsing](http://www.redmine.org/boards/3/topics/4987#message-9854) - again, + should be done for whatever wiki formatter you use. + * Additionally, for some of the formatters escaping should be avoided for + macro arguments. [The patch](http://www.ndl.kiev.ua/downloads/redmine_markdown_extra_formatter_fixes.patch.gz) for redmine_markdown_extra_formatter that does all of these (and also additionally fixes code highlighting, although not in very nice way) is @@ -158,6 +158,7 @@ Splash images for videos are generated automatically from the first frame of the Multiple videos per page are supported, player instance is attached to the selected video as in [this example](http://flowplayer.org/demos/installation/multiple-players.html). Required packages installed: + * ffmpeg * RMagick * wget - for video_url only. diff --git a/app/helpers/wiki_external_filter_helper.rb b/app/helpers/wiki_external_filter_helper.rb index d65bf41..db720b1 100644 --- a/app/helpers/wiki_external_filter_helper.rb +++ b/app/helpers/wiki_external_filter_helper.rb @@ -1,5 +1,4 @@ require 'digest/sha2' -require 'open4' module WikiExternalFilterHelper @@ -86,13 +85,27 @@ module WikiExternalFilterHelper c = nil e = nil - Open4::popen4(out['command']) { |pid, fin, fout, ferr| - fin.write out['prolog'] if out.key?('prolog') - fin.write CGI.unescapeHTML(text) - fin.write out['epilog'] if out.key?('epilog') - fin.close - c, e = [fout.read, ferr.read] - } + # If popen4 is available - use it as it provides stderr + # 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.write CGI.unescapeHTML(text) + fin.write 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.write CGI.unescapeHTML(text) + f.write out['epilog'] if out.key?('epilog') + f.close_write + c = f.read + } + end RAILS_DEFAULT_LOGGER.debug("child status: sig=#{$?.termsig}, exit=#{$?.exitstatus}")