Commit 03bf6b38 authored by Guillaume Grossetie's avatar Guillaume Grossetie

Disable diagram formats that require a companion container

parent 107633e2
......@@ -159,7 +159,7 @@ gem 'wikicloth', '0.8.1'
gem 'asciidoctor', '~> 2.0.10'
gem 'asciidoctor-include-ext', '~> 0.3.1', require: false
gem 'asciidoctor-plantuml', '~> 0.0.12'
gem 'asciidoctor-kroki', '~> 0.2.2'
gem 'asciidoctor-kroki', '~> 0.2.2', require: false
gem 'rouge', '~> 3.25.0'
gem 'truncato', '~> 0.7.11'
gem 'bootstrap_form', '~> 4.2.0'
......
......@@ -168,7 +168,9 @@ module ApplicationSettingImplementation
user_show_add_ssh_key_message: true,
wiki_page_max_content_bytes: 50.megabytes,
container_registry_delete_tags_service_timeout: 250,
container_registry_expiration_policies_worker_capacity: 0
container_registry_expiration_policies_worker_capacity: 0,
kroki_enabled: false,
kroki_url: nil,
}
end
......
......@@ -8,22 +8,11 @@ module Banzai
# HTML that replaces all diagrams supported by Kroki with the corresponding img tags.
#
class KrokiFilter < HTML::Pipeline::Filter
DIAGRAM_SELECTORS = ::AsciidoctorExtensions::Kroki::SUPPORTED_DIAGRAM_NAMES
.map { |diagram_type| %(pre[lang="#{diagram_type}"] > code) }
.join(', ')
DIAGRAM_SELECTORS_WO_PLANTUML = ::AsciidoctorExtensions::Kroki::SUPPORTED_DIAGRAM_NAMES
.select { |diagram_type| diagram_type != 'plantuml' }
def call
diagram_selectors = ::Gitlab::Kroki.formats(settings)
.map { |diagram_type| %(pre[lang="#{diagram_type}"] > code) }
.join(', ')
def call
diagram_selectors = if settings.plantuml_enabled
# if PlantUML is enabled, PlantUML diagrams will be processed by the PlantUML filter.
DIAGRAM_SELECTORS_WO_PLANTUML
else
DIAGRAM_SELECTORS
end
return doc unless settings.kroki_enabled && doc.at(diagram_selectors)
diagram_format = "svg"
......
......@@ -56,13 +56,10 @@ module Gitlab
extensions = proc do
include_processor ::Gitlab::Asciidoc::IncludeProcessor.new(context)
block ::Gitlab::Asciidoc::MermaidBlockProcessor
if Gitlab::CurrentSettings.kroki_enabled
::AsciidoctorExtensions::Kroki::SUPPORTED_DIAGRAM_NAMES.each do |name|
::Gitlab::Kroki.formats(Gitlab::CurrentSettings).each do |name|
block ::AsciidoctorExtensions::KrokiBlockProcessor, name
end
end
end
extra_attrs = path_attrs(context[:requested_path])
asciidoc_opts = { safe: :secure,
......
# frozen_string_literal: true
require 'asciidoctor/extensions/asciidoctor_kroki/extension'
module Gitlab
# Helper methods for Kroki
module Kroki
BLOCKDIAG_FORMATS = %w[
blockdiag
seqdiag
actdiag
nwdiag
packetdiag
rackdiag
].freeze
# Diagrams that require a companion container are disabled for now
DIAGRAMS_FORMATS = ::AsciidoctorExtensions::Kroki::SUPPORTED_DIAGRAM_NAMES
.reject { |diagram_type| diagram_type == 'mermaid' || diagram_type == 'bpmn' || BLOCKDIAG_FORMATS.include?(diagram_type) }
DIAGRAMS_FORMATS_WO_PLANTUML = DIAGRAMS_FORMATS
.reject { |diagram_type| diagram_type == 'plantuml' }
# Get the list of diagram formats that are currently enabled
#
# Returns an Array of diagram formats.
# If Kroki is not enabled, returns an empty Array.
def self.formats(current_settings)
return [] unless current_settings.kroki_enabled
# If PlantUML is enabled, PlantUML diagrams will be processed by the PlantUML server.
# In other words, the PlantUML server has precedence over Kroki since both can process PlantUML diagrams.
if current_settings.plantuml_enabled
DIAGRAMS_FORMATS_WO_PLANTUML
else
DIAGRAMS_FORMATS
end
end
end
end
......@@ -180,11 +180,6 @@ msgid_plural "%d errors"
msgstr[0] ""
msgstr[1] ""
msgid "%d error found:"
msgid_plural "%d errors found:"
msgstr[0] ""
msgstr[1] ""
msgid "%d exporter"
msgid_plural "%d exporters"
msgstr[0] ""
......@@ -20378,6 +20373,9 @@ msgstr ""
msgid "Please note that this application is not provided by GitLab and you should verify its authenticity before allowing access."
msgstr ""
msgid "Please note that using additional formats requires to start companion containers. Make sure that all %{kroki_images} are running."
msgstr ""
msgid "Please only enable search after installing the plugin, enabling indexing and recreating the index"
msgstr ""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment