forked from redmica/redmica_ui_extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init_redmica_ui_extension.rb
39 lines (32 loc) · 1.53 KB
/
init_redmica_ui_extension.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# frozen_string_literal: true
# Common methods for redmica_ui_extension
require File.dirname(__FILE__) + '/lib/redmica_ui_extension/setting_patch'
Setting.include RedmicaUiExtension::SettingPatch
# searchable_selectbox
require File.dirname(__FILE__) + '/lib/searchable_selectbox/hook_listener'
require File.dirname(__FILE__) + '/lib/searchable_selectbox/my_helper_patch'
MyHelper.include SearchableSelectbox::MyHelperPatch
# burndown_chart
require File.dirname(__FILE__) + '/lib/burndown_chart/hook_listener'
require File.dirname(__FILE__) + '/lib/burndown_chart/versions_helper_patch'
VersionsHelper.include BurndownChart::VersionsHelperPatch
# mermaid macro
require File.dirname(__FILE__) + '/lib/mermaid_macro/hook_listener'
Redmine::WikiFormatting::Macros.register do
desc "Convert the text in the block to a diagram using mermaid.js. Mermaid's Syntax: https://mermaid-js.github.io/mermaid/#/n00b-syntaxReference\n" +
"Example:\n\n" +
"{{mermaid\n" +
"erDiagram\n" +
" CUSTOMER ||--o{ ORDER : places\n" +
" ORDER ||--|{ LINE-ITEM : contains\n" +
" CUSTOMER }|..|{ DELIVERY-ADDRESS : uses\n" +
"}}"
macro :mermaid do |_obj, _args, text|
tmp_id = "mermaid-#{SecureRandom.hex(10)}"
content_tag(:div, text, class: 'mermaid before-init-mermaid', id: tmp_id) +
javascript_tag("initMermaidMacro('#{tmp_id}');")
end
end
# preview_attachment
require File.dirname(__FILE__) + '/lib/preview_attachment/hook_listener'
ApplicationHelper.include PreviewAttachment::ApplicationHelperPatch