Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVG Embedded #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/views/settings/_plantuml.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,9 @@
<label><%= l(:plantuml_binary) %></label>
<%= text_field_tag 'settings[plantuml_binary_default]', @settings['plantuml_binary_default'], size: 60 %>
</p>
<p>
<label><%= l(:embed_svg) %></label>
<%= check_box_tag 'settings[embed_svg]', 1, @settings['embed_svg'] %>
</p>

</fieldset>
2 changes: 1 addition & 1 deletion assets/javascripts/plantuml.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if (typeof(jsToolBar) != 'undefined') {
fn: {
wiki: function () {
// this.singleTag('{{plantuml(png)\n', '\n}}');
this.encloseLineSelection('{{plantuml(png)\n', '\n}}')
this.encloseLineSelection('{{plantuml(svg)\n', '\n}}')
}
}
}
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ en:
cache_expiration: 'Cache expiration time'
plantuml_binary: 'PlantUML binary'
allow_includes: 'Allow !include (ATTENTION! Security risk)'
embed_svg: 'Embed SVG images as inline <svg>'
9 changes: 7 additions & 2 deletions init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
requires_redmine version: '2.6'..'4.0'

settings(partial: 'settings/plantuml',
default: { 'plantuml_binary' => {}, 'cache_seconds' => '0', 'allow_includes' => false })
default: { 'plantuml_binary' => {}, 'cache_seconds' => '0', 'allow_includes' => false, 'embed_svg' => false })

Redmine::WikiFormatting::Macros.register do
desc <<EOF
Expand All @@ -27,7 +27,12 @@
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]}"
if Setting.plugin_plantuml['embed_svg'] && frmt[:type] == 'svg'
_file = PlantumlHelper.plantuml_file(image, frmt[:ext])
File.read(_file).html_safe
else
image_tag "/plantuml/#{frmt[:type]}/#{image}#{frmt[:ext]}"
end
end
end
end
Expand Down