Patch #31302

Customizable wiki assets in plugin

Added by Masato NODA 15 days ago. Updated 8 days ago.

Status:NewStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Plugin API
Target version:4.1.0

Description

Hi.

If we want to customize assets used in wiki from our plugin, we will override heads_for_wiki_formatter directly.

ex:
https://github.com/pinzolo/redmine_persist_wfmt/blob/master/lib/patches/helper/markdown_helper_patch.rb#L8
https://github.com/wate/graphviz/blob/master/lib/graphviz_helper_patch.rb#L19

But this means that only the last plugins loaded will be reflected.

So, I created a patch to separate the definitions of assets.
Please check this.

customizable-wiki-assets.patch Magnifier (3.22 KB) Masato NODA, 2019-05-05 14:57

customizable-wiki-assets-fix.patch Magnifier (3.22 KB) Masato NODA, 2019-05-05 18:38

History

#1 Updated by Go MAEDA 15 days ago

Please let me know the following points:

1. How do you rewrite your plugin if the patch is merged?
2. Sorry for the basic question but what does the word "renderigns" in the method name mean?

#2 Updated by Masato NODA 15 days ago

1. How do you rewrite your plugin if the patch is merged?

My plugin is redmine_persist_wfmt.
I will rewrite as follows.

module Pwfmt::MarkdownHelperPatch
  include Pwfmt::Helper

  def wikitoolbar_for(field_id, preview_url = preview_text_path)
    super(field_id, preview_url) + javascript_tag(pwfmt_select_script(field_id, 'markdown'))
  end

  def asset_renderigns_for_wiki_formatter
    base = super
    base[:script_format_adapter] = Proc.new { javascript_include_tag('toolbar', plugin: 'redmine_persist_wfmt') }
    base
  end
end

Redmine::WikiFormatting::Markdown::Helper.prepend(Pwfmt::MarkdownHelperPatch)

If this patch is merged, partial correction of wiki assets is possible.
For example, wiki toolbar can be modified by multiple plugins.
Current heads_for_wiki_formatter returns no value related rendering asset tag of wiki, it's a problem for plugin that extends wiki toolbar .

2. Sorry for the basic question but what does the word "renderigns" in the method name mean?

Sorry, "renderigns" is a miss spell, correctly "renderings".
I reattach a fixed patch.

#3 Updated by Go MAEDA 14 days ago

  • Target version set to Candidate for next major release

#4 Updated by Go MAEDA 8 days ago

  • Category changed from Wiki to Plugin API
  • Target version changed from Candidate for next major release to 4.1.0

Setting the target version to 4.1.0.

Also available in: Atom PDF