-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathinit.rb
42 lines (36 loc) · 1.34 KB
/
init.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
40
41
42
Redmine::Plugin.register :plantuml do
name 'PlantUML plugin for Redmine'
author 'Michael Skrynski'
description 'This is a plugin for Redmine which renders PlantUML diagrams.'
version '0.5.1'
url 'https://github.com/dkd/plantuml'
requires_redmine version: '2.6'..'4.1'
settings(partial: 'settings/plantuml',
default: { 'plantuml_binary' => {}, 'cache_seconds' => '0', 'allow_includes' => false })
Redmine::WikiFormatting::Macros.register do
desc <<EOF
Render PlantUML image.
<pre>
{{plantuml(png)
(Bob -> Alice : hello)
}}
</pre>
Available options are:
** (png|svg)
EOF
macro :plantuml do |obj, args, text|
raise 'No PlantUML binary set.' if Setting.plugin_plantuml['plantuml_binary_default'].blank?
raise 'No or bad arguments.' if args.size != 1
frmt = PlantumlHelper.check_format(args.first)
image = PlantumlHelper.plantuml(text, args.first)
image_tag "/plantuml/#{frmt[:type]}/#{image}#{frmt[:ext]}"
end
end
end
Rails.configuration.to_prepare do
# Guards against including the module multiple time (like in tests)
# and registering multiple callbacks
unless Redmine::WikiFormatting::Textile::Helper.included_modules.include? PlantumlHelperPatch
Redmine::WikiFormatting::Textile::Helper.send(:include, PlantumlHelperPatch)
end
end