Project

General

Profile

Wiki External Filter plugin released

Added by Alexander Tsvyashchenko over 14 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)

Imprezy na jachtach - Added by Effesspeeceda Effesspeeceda over 13 years ago

Artistically, I appreciated you all again. After my prolonged companionship in the forum is not, I could not learn the open sesame to your old profile and started a new one. I'm glad that I am again with you.

RE: Wiki External Filter plugin released - Added by Stefan Bellus over 13 years ago

I install plug in according to www.ndl.kiev.ua/content/redmine-wiki-external-filter-plugin
But I get Error executing the plantuml macro (undefined method `page' for #).
What can be wrong?

RE: Wiki External Filter plugin released - Added by Stefan Bellus over 13 years ago

Stefan Bellus wrote:

I install plug in according to www.ndl.kiev.ua/content/redmine-wiki-external-filter-plugin
But I get Error executing the plantuml macro (undefined method `page' for #).
What can be wrong?

Preview is working correctly, only when I press submit above message is displayed instead of UML.

RE: Wiki External Filter plugin released - Added by Stefan Bellus over 13 years ago

Stefan Bellus wrote:

I install plug in according to www.ndl.kiev.ua/content/redmine-wiki-external-filter-plugin
But I get Error executing the plantuml macro (undefined method `page' for #).
What can be wrong?

ok now I got it. It is only possible to use this plug-in in Wiki. It is not possible to use it in:
  1. Issues descriptions
  2. Issues history
  3. Blogs (www.redmine.org/boards/3/topics/5782)

Is it possible to change this, plug in to be usable also in fields mentioned above?

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

Stefan Bellus wrote:

[skipped]

ok now I got it. It is only possible to use this plug-in in Wiki. It is not possible to use it in:
  1. Issues descriptions
  2. Issues history
  3. Blogs (www.redmine.org/boards/3/topics/5782)

Is it possible to change this, plug in to be usable also in fields mentioned above?

Please try getting the latest plugin version from github.com, I hope I've fixed this issue in the last commit.

Thanks for reporting it!

RE: Wiki External Filter plugin released - Added by Stefan Bellus over 13 years ago

Thank you for your fast respond and FIX. Now it is working perfectly.

RE: Wiki External Filter plugin released - Added by Stefan Bellus over 13 years ago

Stefan Bellus wrote:

Thank you for your fast respond and FIX. Now it is working perfectly.

The formating is not very nice for large UML drawings. It is outside description area. But I don't plan it to use it for large UML drawings. Thank you again for perfect work.

RE: Wiki External Filter plugin released - Added by Sam Nguyen over 13 years ago

If you are using the markdown_extra_formatter plugin alongside the wiki_external_filter plugin, you will get errors if you have blank lines in your PlantUML code. This is because Markdown will convert them into <p> tags.

Adjust your plantuml filter to use this command to fix it by stripping all tags

- command: "/bin/sed -e 's/<[^>]*>//g' | /usr/bin/plantuml -pipe" 

RE: Wiki External Filter plugin released - Added by Hans Schmidt about 13 years ago

Hi,

in Redmine 1.2.1 the Plugin does not work.

production.log ::debug

Processing WikiExternalFilterController#filter (for ***.***.***.*** at 2011-07-26 15:21:33) [GET]
I, [2011-07-26T15:21:33.972663 #12175]  INFO -- :   Parameters: {"name"=>"8c8000772a6d91d2b1363d0852469994ffa36e6bd27f87d6d1e4c38fa9102926", "macro"=>"plantuml", "action"=>"filter", "index"=>"0", "controller"=>"wiki_external_filter"}
D, [2011-07-26T15:21:33.975365 #12175] DEBUG -- :   [4;36;1mSQL (0.2ms)[0m   [0;1mSELECT max(`settings`.updated_on) AS max_updated_on FROM `settings` [0m
D, [2011-07-26T15:21:33.978998 #12175] DEBUG -- :   [4;35;1mUser Load (0.2ms)[0m   [0mSELECT * FROM `users` WHERE (`users`.`id` = 5) AND (users.status = 1) AND ( (`users`.`type` = 'User' OR `users`.`type` = 'AnonymousUser' ) ) [0m
D, [2011-07-26T15:21:33.991598 #12175] DEBUG -- : Cached fragment hit: views/wiki_external_filter/plantuml/8c8000772a6d91d2b1363d0852469994ffa36e6bd27f87d6d1e4c38fa9102926 (0.1ms)
I, [2011-07-26T15:21:33.994562 #12175]  INFO -- : Rendering template within layouts/base
I, [2011-07-26T15:21:33.994777 #12175]  INFO -- : Rendering common/error (404)
D, [2011-07-26T15:21:34.000345 #12175] DEBUG -- :   [4;36;1mUserPreference Load (0.2ms)[0m   [0;1mSELECT * FROM `user_preferences` WHERE (`user_preferences`.user_id = 5) LIMIT 1[0m
D, [2011-07-26T15:21:34.186964 #12175] DEBUG -- : Rendered code_review/_html_header (0.1ms)
D, [2011-07-26T15:21:34.192807 #12175] DEBUG -- : Rendered hooks/opensearch/_view_layouts_base_html_head (1.0ms)
D, [2011-07-26T15:21:34.200825 #12175] DEBUG -- : Rendered wiki_extensions/_html_header (0.2ms)
D, [2011-07-26T15:21:34.205290 #12175] DEBUG -- :   [4;35;1mProject Load (0.2ms)[0m   [0mSELECT * FROM `projects` WHERE (projects.status=1 AND projects.id IN (SELECT em.project_id FROM enabled_modules em WHERE em.name='stuff_to_do_module')) [0m
D, [2011-07-26T15:21:34.217904 #12175] DEBUG -- :   [4;36;1mFavouriteProject Load Including Associations (5.7ms)[0m   [0;1mSELECT `favourite_projects`.`id` AS t0_r0, `favourite_projects`.`user_id` AS t0_r1, `favourite_projects`.`project_id` AS t0_r2, `projects`.`id` AS t1_r0, `projects`.`name` AS t1_r1, `projects`.`description` AS t1_r2, `projects`.`homepage` AS t1_r3, `projects`.`is_public` AS t1_r4, `projects`.`parent_id` AS t1_r5, `projects`.`created_on` AS t1_r6, `projects`.`updated_on` AS t1_r7, `projects`.`identifier` AS t1_r8, `projects`.`status` AS t1_r9, `projects`.`lft` AS t1_r10, `projects`.`rgt` AS t1_r11, `projects`.`customer_id` AS t1_r12, `projects`.`dmsf_description` AS t1_r13 FROM `favourite_projects` LEFT OUTER JOIN `projects` ON `projects`.id = `favourite_projects`.project_id WHERE (user_id = 5) ORDER BY projects.name[0m
D, [2011-07-26T15:21:34.224293 #12175] DEBUG -- :   [4;35;1mMember Load Including Associations (3.5ms)[0m   [0mSELECT `members`.`id` AS t0_r0, `members`.`user_id` AS t0_r1, `members`.`project_id` AS t0_r2, `members`.`created_on` AS t0_r3, `members`.`mail_notification` AS t0_r4, `members`.`dmsf_mail_notification` AS t0_r5, `projects`.`id` AS t1_r0, `projects`.`name` AS t1_r1, `projects`.`description` AS t1_r2, `projects`.`homepage` AS t1_r3, `projects`.`is_public` AS t1_r4, `projects`.`parent_id` AS t1_r5, `projects`.`created_on` AS t1_r6, `projects`.`updated_on` AS t1_r7, `projects`.`identifier` AS t1_r8, `projects`.`status` AS t1_r9, `projects`.`lft` AS t1_r10, `projects`.`rgt` AS t1_r11, `projects`.`customer_id` AS t1_r12, `projects`.`dmsf_description` AS t1_r13, `roles`.`id` AS t2_r0, `roles`.`name` AS t2_r1, `roles`.`position` AS t2_r2, `roles`.`assignable` AS t2_r3, `roles`.`builtin` AS t2_r4, `roles`.`permissions` AS t2_r5, `roles`.`issues_visibility` AS t2_r6 FROM `members` LEFT OUTER JOIN `projects` ON `projects`.id = `members`.project_id LEFT OUTER JOIN `member_roles` ON (`members`.`id` = `member_roles`.`member_id`) LEFT OUTER JOIN `roles` ON (`roles`.`id` = `member_roles`.`role_id`) WHERE (`members`.user_id = 5 AND (projects.status=1)) ORDER BY projects.name[0m
D, [2011-07-26T15:21:34.237903 #12196] DEBUG -- :   [4;36;1mSQL (0.2ms)[0m   [0;1mSET NAMES 'utf8'[0m
D, [2011-07-26T15:21:34.249046 #12196] DEBUG -- :   [4;35;1mSQL (7.5ms)[0m   [0mSET SQL_AUTO_IS_NULL=0[0m
D, [2011-07-26T15:21:34.293177 #12175] DEBUG -- : Rendered code_review/_body_bottom (0.3ms)
I, [2011-07-26T15:21:34.302104 #12175]  INFO -- : Completed in 329ms (View: 309, DB: 0) | 404 Not Found [http://my.redmine/wiki_external_filter/filter?index=0&macro=plantuml&name=8c8000772a6d91d2b1363d0852469994ffa36e6bd27f87d6d1e4c38fa9102926]
D, [2011-07-26T15:21:34.337123 #12200] DEBUG -- :   [4;36;1mSQL (0.3ms)[0m   [0;1mSET NAMES 'utf8'[0m
D, [2011-07-26T15:21:34.349010 #12200] DEBUG -- :   [4;35;1mSQL (8.2ms)[0m   [0mSET SQL_AUTO_IS_NULL=0[0m
D, [2011-07-26T15:21:34.389195 #12202] DEBUG -- :   [4;36;1mSQL (0.2ms)[0m   [0;1mSET NAMES 'utf8'[0m
D, [2011-07-26T15:21:34.392193 #12202] DEBUG -- :   [4;35;1mSQL (0.2ms)[0m   [0mSET SQL_AUTO_IS_NULL=0[0m
D, [2011-07-26T15:21:34.456809 #12204] DEBUG -- :   [4;36;1mSQL (0.3ms)[0m   [0;1mSET NAMES 'utf8'[0m
D, [2011-07-26T15:21:34.459688 #12204] DEBUG -- :   [4;35;1mSQL (0.2ms)[0m   [0mSET SQL_AUTO_IS_NULL=0[0m

plz update ur plugin for version 1.2.1 (without core patches).
Thanks!

RE: Wiki External Filter plugin released - Added by Claus Ilginnis almost 13 years ago

yes indeed - I wanted to use the plantuml
and tried to fix it the way described in 1.2 but it didnt work.

so please update you plugin

Thanks

RE: Wiki External Filter plugin released - Added by kiran patil almost 13 years ago

Claus Ilginnis wrote:

yes indeed - I wanted to use the plantuml
and tried to fix it the way described in 1.2 but it didnt work.

so please update you plugin

Thanks

Yes, it is not working in 1.2.1. Please update the plugin.

RE: Wiki External Filter plugin released - Added by Claus Ilginnis almost 13 years ago

Sorry but I see no change on the installation instructions and
I see your last commit on your repo at gtihub from february...
Do I look in the wrong place ?

RE: Wiki External Filter plugin released - Added by Ja Young Na almost 13 years ago

You can use in 1.2.1, using 'memcached' configuration

  • edit your config/environments/production.rb
config.action_controller.perform_caching = true
config.action_controller.cache_store = :mem_cache_store, "localhost" 
  • set non-zero value at "Cache expiration time" in Wiki External Filter Plugin setting, redmine's administrator page
  • Don't forget install memcached. if you're using ubuntu,
apt-get install memcached
  • restart redmine

ps, How can I install ritex ?

RE: Wiki External Filter plugin released - Added by Rafa Diaz Novo almost 13 years ago

I have it working in the 1.2.0 version.

What I had done was:

  1. Install and configure the 1.2.0 version.
  2. Apply the two patches for the 1.0.2 that you can find in the wiki external plugin home page.
  3. After that my UML diagrams still missing and what I found instead was something like
{{_macros_grabbed(91ab9e7da9786a0as6a0sfasdf)}}

Then I modify the application_helper.rb file and change this (line 493):

return '' if text.blank?
    project = options[:project] || @project || (obj && obj.respond_to?(:project) ? obj.project : nil)
    only_path = options.delete(:only_path) == false ? false : true

    text = Redmine::WikiFormatting.to_html(Setting.text_formatting, text, :object => obj, :attribute => attr) 

with this:

return '' if text.blank?
    project = options[:project] || @project || (obj && obj.respond_to?(:project) ? obj.project : nil)
    only_path = options.delete(:only_path) == false ? false : true

    text = Redmine::WikiFormatting.to_html(Setting.text_formatting, text, :object => obj, :attribute => attr) { |macro, args| exec_macro(macro, obj, args) }

After that the dot and ritex are working again.

RE: Wiki External Filter plugin released - Added by Benoit Pothier over 12 years ago

I've managed to make if work for plant UML with redmine 1.3.

  1. Apply the patch joined
  2. Create /usr/bin/plantuml with the following code (change the PATH to where you have installed plantuml)
    #!/bin/dash
    /bin/sed -e 's/<br..>/\n/g' | /usr/bin/java -Djava.io.tmpdir=/var/tmp -jar /opt/plantuml/plantuml.jar $*
    
  3. Activate caching in the plugin options

Restart apache and it should work

RE: Wiki External Filter plugin released - Added by Sergey Kovalev over 12 years ago

Thank you for the patch, it's really useful, but I still can't run plantuml. It works fine under 1.2. But after migrating to 1.3 it doesn't process the text at all.
What I do:
1. Checkout source of Redmine-1.3
2. Copy old config/wiki_external_filter.yml
3. Clone wiki_external_plugin from git
4. Apply redmine_1.3_wiki_external_filter.patch
5. Configure caching to file store
6. Run redmine migrating scripts

What should I do else? May be I forgot something?..

RE: Wiki External Filter plugin released - Added by Benoit Pothier over 12 years ago

Hello,

You can create an alternative plantuml file to debug:

#!/bin/dash
tee /tmp/debug1.txt | /bin/sed -e 's/<br..>/\n/g' | tee /tmp/debug2.txt | /usr/bin/java -Djava.io.tmpdir=/var/tmp -jar /opt/plantuml/plantuml.jar $* | tee /tmp/output.png

Do you have something in debug1.txt?

RE: Wiki External Filter plugin released - Added by Sergey Kovalev over 12 years ago

No, there is nothing, like the script doest not run at all.
I looked into redmine-1.2 debug log - it write lines about WikiExternalFilterController.
But there is no mention of it under redmine-1.3.
Still have no idea where to dig :-\

RE: Wiki External Filter plugin released - Added by Benoit Pothier over 12 years ago

Try the fortune filter first. This way you will be sure that WikiExternalFilterController is properly setup. Check that wiki_external_filter.yml has the proper path to the fortune binary.

RE: Wiki External Filter plugin released - Added by Sergey Kovalev over 12 years ago

Fortune works fine. I'll try to dig more...

RE: Wiki External Filter plugin released - Added by Sergey Kovalev over 12 years ago

Hmm. I have "pre" tag, written right after a "{{plantuml(" line and "/pre" tag at the end of block, before )}}.
If I remove theese tags - macro starts, but it have bad input text - it's full of tags.

RE: Wiki External Filter plugin released - Added by Sergey Kovalev over 12 years ago

It seems, that problem in macro content managing. It can process simple diagrams, but when you plant empty lines, or "== xyz ==" lines - it becames completely broken.
I guess, we should not process tags in plantuml running script, but should process "pre" tags to completely remove possibility of any automatical tag, like it was in previous patches.

RE: Wiki External Filter plugin released - Added by Benoit Pothier over 12 years ago

I add the same kind of problem since. Empty lines are nor working. You can remove additional parasite tags with additional filters. This is not a clean way to do it, but it works for me:

/bin/sed -e 's/<br..>/\n/g'  -e 's/<\/\?del>/-/g' -e 's/<\/\?ul>//g' -e 's/<\/\?li>//g' -e 's/<\/\?p>//g' | /usr/bin/java -Djava.io.tmpdir=/var/tmp -jar /usr/bin/plantuml.jar $* 

I

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

Hello All,

Sorry, I don't really have the time to follow-up on this thread, but recently I had to upgrade my own installation to 1.3.0, so I ported the patches to 1.3.0, they're available now on my plugin homepage http://www.ndl.kiev.ua/content/redmine-wiki-external-filter-plugin, tagged with "Redmine 1.3.0" label. I also added a bit more sophistication to macros substitution to make sure they're not improperly substituted if they're inside "pre" blocks or are escaped.

On my test cases everything appears to work, no changes to plugin itself were necessary.

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

Sorry, messed up formatting, please ignore.

(51-75/80)