Project

General

Profile

Wiki External Filter plugin released

Added by Alexander Tsvyashchenko almost 15 years ago

Redmine Wiki External Filter plugin allows defining macros that process macro argument using external filter program and render its result in Redmine wiki.

Currently supported macros are plantuml (for UML diagrams drawing), graphviz (for graphs drawing), ritex (for formula drawing) and fortune (simply for fun ;-), but additional ones are easy to add.

plantuml example input:

    {{plantuml(
    Alice -> Bob: Authentication Request
    alt successful case
      Bob -> Alice: Authentication Accepted
    else some kind of failure
      Bob -> Alice: Authentication Failure
      opt
        loop 1000 times
          Alice -> Bob: DNS Attack
        end
      end
    else Another type of failure
      Bob -> Alice: Please repeat
    end
    )}}

and output:

graphviz example input:

    {{graphviz(
    digraph finite_state_machine {
        rankdir=LR;
        size="8,5" 
        node [shape = doublecircle]; LR_0 LR_3 LR_4 LR_8;
        node [shape = circle];
        LR_0 -> LR_2 [ label = "SS(B)" ];
        LR_0 -> LR_1 [ label = "SS(S)" ];
        LR_1 -> LR_3 [ label = "S($end)" ];
        LR_2 -> LR_6 [ label = "SS(b)" ];
        LR_2 -> LR_5 [ label = "SS(a)" ];
        LR_2 -> LR_4 [ label = "S(A)" ];
        LR_5 -> LR_7 [ label = "S(b)" ];
        LR_5 -> LR_5 [ label = "S(a)" ];
        LR_6 -> LR_6 [ label = "S(b)" ];
        LR_6 -> LR_5 [ label = "S(a)" ];
        LR_7 -> LR_8 [ label = "S(b)" ];
        LR_7 -> LR_5 [ label = "S(a)" ];
        LR_8 -> LR_6 [ label = "S(b)" ];
        LR_8 -> LR_5 [ label = "S(a)" ];
    }
    )}}

and output:

ritex example input:

    {{ritex(
    G(y) = \left\{\array{ 1 - e^{-\lambda x} & \text{ if } y \geq 0 \\ 0 & \text{ if } y < 0 }\right.
    )}}

and output:

fortune sample input:

{{fortune}}

and output:

Detailed information is available here: https://www.ndl.kiev.ua/content/redmine-wiki-external-filter-plugin


Replies (80)

RE: Wiki External Filter plugin released - Added by Paul paul over 14 years ago

This is what I get in args.txt:

<a class="external" href="http://www.fileformat.info/format/mpeg/sample/567fd6a0e0da4a8e81bdeb870de3b19c/DELTA.MPG">http://www.fileformat.info/format/mpeg/sample/567fd6a0e0da4a8e81bdeb870de3b19c/DELTA.MPG</a>

Do you see something wrong with it?

RE: Wiki External Filter plugin released - Added by Alexander Tsvyashchenko over 14 years ago

Paul paul wrote:

This is what I get in args.txt:

> <a class="external" href="http://www.fileformat.info/format/mpeg/sample/567fd6a0e0da4a8e81bdeb870de3b19c/DELTA.MPG">http://www.fileformat.info/format/mpeg/sample/567fd6a0e0da4a8e81bdeb870de3b19c/DELTA.MPG</a> >

Do you see something wrong with it?

Yes, the content is wrong: you should have plain URL there, not the HTML-formatted one. If I'm not mistaken, you use Yuya's patch for Textile wiki formatter, right? If that's the case, most likely Yuya's path does not handle this situation yet.

The way I solve all escaping issues in Markdown wiki formatter is that before applying wiki formatting to the text I substitute all macros in the text with unique IDs and then after formatting substitute back the result of macros processing, this way nor macro arguments are escaped, neither macros substitutions results are passed through wiki formatting. I'd recommend going similar route with Textile wiki formatter.

Of course, the best way would be to extend Redmine core to do it in centralized way instead of patching individual wiki formatters, but currently I do not have time for necessary negotiations with Redmine core team and for implementation that would be appropriate to include to the Redmine core.

RE: Wiki External Filter plugin released - Added by Paul paul over 14 years ago

Yuya, would it be possible for you to fix your patch according to Alexander's comments? I wouldn't know where to begin...
Thanks a lot.

RE: Wiki External Filter plugin released - Added by Yuya Nishihara over 14 years ago

Paul paul wrote:

Yuya, would it be possible for you to fix your patch according to Alexander's comments?

Okay, I'll migrate changes from markdown patch to textile, but maybe it'll take some time.

RE: Wiki External Filter plugin released - Added by Yuya Nishihara over 14 years ago

Paul paul wrote:

Yuya, would it be possible for you to fix your patch according to Alexander's comments?

Updated the patch to grab macro argument in early stage. Please try it!

RE: Wiki External Filter plugin released - Added by Paul paul over 14 years ago

Yuya Nishihara wrote:

Paul paul wrote:

Yuya, would it be possible for you to fix your patch according to Alexander's comments?

Updated the patch to grab macro argument in early stage. Please try it!

Gives me an error about the method 'first' not found:

ActionView::TemplateError (undefined method `first' for nil:NilClass) on line #2 of app/views/common/_preview.rhtml:
1: <fieldset class="preview"><legend><%= l(:label_preview) %></legend>
2: <%= textilizable @text, :attachments => @attachements, :object => @previewed %>
3: </fieldset>

    lib/redmine/wiki_formatting/textile/formatter.rb:144:in `inline_macros'
    lib/redmine/wiki_formatting/textile/formatter.rb:140:in `gsub!'
    lib/redmine/wiki_formatting/textile/formatter.rb:140:in `inline_macros'
    lib/redcloth3.rb:1099:in `call'
    lib/redcloth3.rb:1099:in `inline'
    lib/redcloth3.rb:1098:in `each'
    lib/redcloth3.rb:1098:in `inline'
    lib/redcloth3.rb:1097:in `each'
    lib/redcloth3.rb:1097:in `inline'
    lib/redcloth3.rb:306:in `to_html'
    lib/redmine/wiki_formatting/textile/formatter.rb:42:in `to_html'
    lib/redmine/wiki_formatting.rb:47:in `to_html'
    app/helpers/application_helper.rb:427:in `textilizable'
    app/views/common/_preview.rhtml:2:in `_run_rhtml_app47views47common47_preview46rhtml_locals_object_preview'
    app/controllers/wiki_controller.rb:201:in `preview'

RE: Wiki External Filter plugin released - Added by Yuya Nishihara over 14 years ago

Paul paul wrote:

Gives me an error about the method 'first' not found:

Strange. Though I think the code at line 143 is typo of .map(&:strip), anyway Array.each should return self.

Could you try the attached patch? Does it change anything? And could you give me ruby version, the output of ruby -v ?

RE: Wiki External Filter plugin released - Added by Paul paul over 14 years ago

Yuya Nishihara wrote:

Strange. Though I think the code at line 143 is typo of .map(&:strip), anyway Array.each should return self.

Could you try the attached patch? Does it change anything? And could you give me ruby version, the output of ruby -v ?

It works now for Graphviz (as it was before the latest patch). Using it with ffmpeg produces a rails error:

{{video_url(http://www.stockshots.com/images/videoclips/cartoon.avi)}}
Application error
Rails application failed to start properly

ruby -v:

ruby 1.8.7 (2009-12-24 patchlevel 248) [i386-freebsd7]

There is nothing in the production.log - should I look elsewhere?

RE: Wiki External Filter plugin released - Added by Denis Bauer over 14 years ago

I'm still heavily confused as to where textile needs to be changed. My version is by now 1.0.0.devel and my lib/redmine/wiki_formatting/textile/formatter.rb looks like "this":
http://www.redmine.org/projects/redmine/repository/entry/trunk/lib/redmine/wiki_formatting/textile/formatter.rb, which does not have anything resembling the lines that need to be replaced in http://www.redmine.org/attachments/4135/wiki-external-filter-textile-workaround-2010-07-19.patch.
Thanks for your help !!

RE: Wiki External Filter plugin released - Added by Yuya Nishihara over 14 years ago

Denis Bauer wrote:

I'm still heavily confused as to where textile needs to be changed. My version is by now 1.0.0.devel

See r3372, which moves macro processing to lib/redmine/wiki_formatting.rb. My patch is yet migrated to 1.0 series.

RE: Wiki External Filter plugin released - Added by Yuya Nishihara over 14 years ago

Paul paul wrote:

Using it with ffmpeg produces a rails error:

{{video_url(http://www.stockshots.com/images/videoclips/cartoon.avi)}}

Application error
Rails application failed to start properly

When does this error occur? Does it work with ./script/server -e production ?

And what output do you get with the following config:

  video_url:
    description: "echo back" 
    template: text
    outputs:
      - command: "/bin/cat" 
        content_type: "text/plain" 

ruby 1.8.7 (2009-12-24 patchlevel 248) [i386-freebsd7]

There looks nothing bad.

I have it working with textile on Redmine 1.0... - Added by Marc Mengel over 14 years ago

Okay, so there's a tidbit or two here to mention. One is that I had to make a patch that
I suspect was actually wrong, to wit:

*** vendor/plugins/wiki_external_filter/app/controllers/wiki_external_filter_controller.rb.orig 2010-08-05 15:35:52.000000000 -0500
--- vendor/plugins/wiki_external_filter/app/controllers/wiki_external_filter_controller.rb      2010-08-05 15:27:01.000000000 -0500
***************
*** 13,19 ****
      content = read_fragment cache_key

      if (content)
!       send_data content[index], :type => config[macro]['outputs'][index]['content_type'], :disposition => 'inline', :filename => filename
      else
        render_404
      end
--- 13,19 ----
      content = read_fragment cache_key

      if (content)
!       send_data content[index], :type => config[macro]['outputs'][index]['content_type'] || 'text/plain', :disposition => 'inline', :filename => filename
      else
        render_404
      end

This seems wrong, because the type shouldn't have been nil coming out of the cache,
I think, but putting a ...|| 'text/plain' seems to have stopped it complaining that
:text wasn't defined.

the second is that the macro expansion is now factored out of the textile backend,
and is generic. So the overall patch is now applied to the generic code. I'm attaching
said patch, which should work for textile, markdown, whatever...

macro_patch (3.66 KB) macro_patch Patch for not having macro arguments chewed by html-ifying.

1.0 working, redux - Added by Marc Mengel over 14 years ago

I should have said, that :type wasn't defined... sigh.
And here's the patch hopefully showing as a patch.

RE: Wiki External Filter plugin released - Added by Dylan Yee over 14 years ago

I personally like this plug in very much, but it has lack one important thing for me: flow chart. Is it possible to include flow chart macro like Confluence is using?
http://confluence.atlassian.com/display/CONF20/Flowchart+Macro

RE: I have it working with textile on Redmine 1.0... - Added by Alexander Tsvyashchenko over 14 years ago

Hello Marc,

First of all - thank you for the information and the patch!

Marc Mengel wrote:

Okay, so there's a tidbit or two here to mention. One is that I had to make a patch that
I suspect was actually wrong, to wit:
[...]
This seems wrong, because the type shouldn't have been nil coming out of the cache,
I think, but putting a ...|| 'text/plain' seems to have stopped it complaining that
:text wasn't defined.

Yes, it should not happen indeed. Do you have caching configured? There's one known problem if it is not, though you would most likely have additional problems besides content-type in that case ...

the second is that the macro expansion is now factored out of the textile backend,
and is generic. So the overall patch is now applied to the generic code. I'm attaching
said patch, which should work for textile, markdown, whatever...

That's excellent news! Most likely I will upgrade to 1.x branch as soon as 1.0.1 version is out, I will integrate your patch then and hopefully also fix known issues listed here: http://github.com/ndl/wiki_external_filter/issues.

RE: Wiki External Filter plugin released - Added by Alexander Tsvyashchenko over 14 years ago

Dylan Yee wrote:

I personally like this plug in very much, but it has lack one important thing for me: flow chart. Is it possible to include flow chart macro like Confluence is using?
http://confluence.atlassian.com/display/CONF20/Flowchart+Macro

This plugin does not provide drawing functionality on it's own, it just uses external programs for that. This means that if you have (or know about) some program that is able to render flowcharts in the format you like - you can integrate it to wiki_external_filter, but there's no way to add this functionality directly to wiki_external_filter.

Having said that, if you do not mind using graphviz syntax, it's perfectly possible to draw flowcharts in it, and it is already integrated to wiki_external_filter. Here are some inspiring examples: http://www.flickr.com/photos/kentbye/sets/72157601523153827/

RE: Wiki External Filter plugin released - Added by Denis Bauer over 14 years ago

Thanks for the plugin, mark, works nice. However, I have problems with controlling the size of the displayed graphviz image: with no change to the source of the graphviz graph but only by reloading the page the image is sometimes displayed as a large image and sometimes as a tiny one. Specs: redmine 1.0, production, firefox, textile.
Any ideas?

RE: Wiki External Filter plugin released - Added by Victor Gavro about 14 years ago

will it be released for Redmine 1.0 in official repository?...
Redmine 1.0.1 has been released already, so...

Update for Redmine 1.0.2 is ready - Added by Alexander Tsvyashchenko about 14 years ago

Hello All,

I've just switched to Redmine 1.0.2 and hence there are relevant updates to the patches and plugin code.

The patches are available on http://www.ndl.kiev.ua/content/redmine-wiki-external-filter-plugin - see sections marked with "Redmine 1.0.2" text, plugin code is at http://github.com/ndl/wiki_external_filter but there were only minimal changes in the plugin itself and not really relevant to switching to 1.0.2 version so it should be safe to skip this update.

Spam removed - Added by releSickich releSickich almost 14 years ago

...Spam removed by Felix...

RE: Wiki External Filter plugin released - Added by Sven Kilchenmann almost 14 years ago

get in troubles on step 7 (http://www.ndl.kiev.ua/content/redmine-wiki-external-filter-plugin)

sCHween@bscyb:/var/www$ sudo patch -p0 < redmine-1.0.2-macros-escaping.patch
patching file redmine-1.0.2.new/lib/redmine/wiki_formatting.rb
Hunk #1 FAILED at 15.
Hunk #2 FAILED at 44.
Hunk #3 FAILED at 76.
3 out of 3 hunks FAILED -- saving rejects to file redmine-1.0.2.new/lib/redmine/wiki_formatting.rb.rej
sCHween@bscyb:/var/www$ 

what i missed?
Thanks in advance

RE: Wiki External Filter plugin released - Added by Alexander Tsvyashchenko almost 14 years ago

Sven Kilchenmann wrote:

get in troubles on step 7 (http://www.ndl.kiev.ua/content/redmine-wiki-external-filter-plugin)

[...]

what i missed?

Probably telling us what version of Redmine you've tried to apply the patch to? ;-)

RE: Wiki External Filter plugin released - Added by Sven Kilchenmann almost 14 years ago

I've installed Redmine 1.0.3 on an Ubuntu 10.10

Thanks a lot

RE: Wiki External Filter plugin released - Added by Alexander Tsvyashchenko almost 14 years ago

dell-nb:Downloads ndl$ curl http://files.rubyforge.vm.bytemark.co.uk/redmine/redmine-1.0.3.tar.gz -O
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 4724k  100 4724k    0     0   635k      0  0:00:07  0:00:07 --:--:--  729k
dell-nb:Downloads ndl$ curl https://www.ndl.kiev.ua/downloads/redmine-1.0.2-macros-escaping.patch -O 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  3803  100  3803    0     0   8422      0 --:--:-- --:--:-- --:--:--  618k
dell-nb:Downloads ndl$ tar -xzf redmine-1.0.3.tar.gz 
dell-nb:Downloads ndl$ patch -d redmine-1.0.3 -p1 --verbose < redmine-1.0.2-macros-escaping.patch 
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff -urN redmine-1.0.2/lib/redmine/wiki_formatting.rb redmine-1.0.2.new/lib/redmine/wiki_formatting.rb
|--- redmine-1.0.2/lib/redmine/wiki_formatting.rb    2010-02-17 22:47:50.000000000 +0200
|+++ redmine-1.0.2.new/lib/redmine/wiki_formatting.rb    2010-10-12 21:57:19.754024785 +0300
--------------------------
Patching file lib/redmine/wiki_formatting.rb using Plan A...
Hunk #1 succeeded at 15.
Hunk #2 succeeded at 46.
Hunk #3 succeeded at 87.
done

Please verify you're indeed using redmine 1.0.3 and that Ubuntu does not apply any conflicting patches to this file - you might want to compare redmine/lib/redmine/wiki_formatting.rb in your installation to the file from original redmine 1.0.3 distribution.

RE: Wiki External Filter plugin released - Added by Sven Kilchenmann almost 14 years ago

Thank you very much - it works right now.

(26-50/80)