From 2b5ecbbff98c249fc344626ca4b1c22784d2985e Mon Sep 17 00:00:00 2001 From: dunklecat Date: Mon, 23 Sep 2024 12:13:09 +0200 Subject: [PATCH 1/2] Update xwiki-contrib parent-platform and plantuml versions --- macro-plantuml-macro/pom.xml | 2 +- .../plantuml/internal/PlantUMLMacro.java | 6 ++++- pom.xml | 23 +++++++++++++++++-- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/macro-plantuml-macro/pom.xml b/macro-plantuml-macro/pom.xml index ea6c231..9bb77da 100644 --- a/macro-plantuml-macro/pom.xml +++ b/macro-plantuml-macro/pom.xml @@ -54,7 +54,7 @@ net.sourceforge.plantuml plantuml - 1.2021.7 + 1.2024.7 org.xwiki.rendering diff --git a/macro-plantuml-macro/src/main/java/org/xwiki/contrib/plantuml/internal/PlantUMLMacro.java b/macro-plantuml-macro/src/main/java/org/xwiki/contrib/plantuml/internal/PlantUMLMacro.java index f228012..faccff5 100644 --- a/macro-plantuml-macro/src/main/java/org/xwiki/contrib/plantuml/internal/PlantUMLMacro.java +++ b/macro-plantuml-macro/src/main/java/org/xwiki/contrib/plantuml/internal/PlantUMLMacro.java @@ -23,7 +23,9 @@ import java.io.OutputStream; import java.util.Arrays; import java.util.Collections; +import java.util.HashSet; import java.util.List; +import java.util.Set; import javax.inject.Inject; import javax.inject.Named; @@ -93,7 +95,9 @@ public PlantUMLMacro() { super("PlantUML", DESCRIPTION, new DefaultContentDescriptor(CONTENT_DESCRIPTION), PlantUMLMacroParameters.class); - setDefaultCategory(DEFAULT_CATEGORY_CONTENT); + Set defaultCategories = new HashSet<>(); + defaultCategories.add(DEFAULT_CATEGORY_CONTENT); + super.setDefaultCategories(defaultCategories); } @Override diff --git a/pom.xml b/pom.xml index 03e395a..0133cae 100644 --- a/pom.xml +++ b/pom.xml @@ -21,18 +21,32 @@ --> + + + + xwiki-releases + XWiki Releases + https://maven.xwiki.org/releases/ + + + css4j + CSS4J + https://css4j.github.io/maven + + + 4.0.0 org.xwiki.contrib parent-platform - 12.10-1 + 16.4.2 org.xwiki.contrib.plantuml macro-plantuml 2.1.2-SNAPSHOT pom PlantUML Macro - Parent POM - Parent POM for Jthe PlantUML modules + Parent POM for the PlantUML modules http://extensions.xwiki.org/xwiki/bin/view/Extension/JIRA%20Macro scm:git:git://github.com/xwiki-contrib/macro-plantuml.git @@ -52,6 +66,11 @@ vmassol Vincent Massol + + dunklecat + + occasional mantainer + PLANTUML From 22db1f568fd8f1b35554ffda0e4eac948c22c512 Mon Sep 17 00:00:00 2001 From: dunklecat Date: Mon, 23 Sep 2024 12:48:33 +0200 Subject: [PATCH 2/2] Fix TODOs - Remove maven-javadoc-plugin dep - Remove escapes of '\' and '/' inside PlantUMLBlockAsyncRenderer class - Remove hardcoded URL inside TemporaryImageWriter class --- .gitignore | 2 ++ .../internal/PlantUMLBlockAsyncRenderer.java | 19 +------------------ .../internal/store/TemporaryImageWriter.java | 11 +++-------- pom.xml | 17 +---------------- 4 files changed, 7 insertions(+), 42 deletions(-) diff --git a/.gitignore b/.gitignore index 9b58cd3..a4d07a9 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,5 @@ nbproject .sonar-ide.properties .clover *~ + +.vscode diff --git a/macro-plantuml-macro/src/main/java/org/xwiki/contrib/plantuml/internal/PlantUMLBlockAsyncRenderer.java b/macro-plantuml-macro/src/main/java/org/xwiki/contrib/plantuml/internal/PlantUMLBlockAsyncRenderer.java index 68e6258..cce5bd3 100644 --- a/macro-plantuml-macro/src/main/java/org/xwiki/contrib/plantuml/internal/PlantUMLBlockAsyncRenderer.java +++ b/macro-plantuml-macro/src/main/java/org/xwiki/contrib/plantuml/internal/PlantUMLBlockAsyncRenderer.java @@ -23,7 +23,6 @@ import javax.inject.Inject; -import org.apache.commons.lang3.StringUtils; import org.xwiki.component.annotation.Component; import org.xwiki.contrib.plantuml.PlantUMLMacroParameters; import org.xwiki.model.reference.DocumentReference; @@ -150,23 +149,7 @@ private List createId(String source, MacroTransformationContext context) // Find index of the macro in the XDOM to create a unique id. long index = context.getXDOM().indexOf(context.getCurrentMacroBlock()); - // Make sure we don't have a / or \ in the source so that it works on Tomcat by default even if Tomcat is not - // configured to support \ and / in URLs. - // Make "_" and "-" escape characters and thus: - // - replace "_" by "__" - // - replace "-" by "--" - // - replace "\" by "_" - // - replace "/" by "-" - // This keeps the unicity of the source reference. - // TODO: Remove when the parent pom is upgraded to the version of XWiki where - // https://jira.xwiki.org/browse/XWIKI-17515 has been fixed. - String escapedSource = StringUtils.replaceEach(source, - new String[] { ESCAPE_CHAR_SLASH, ESCAPE_CHAR_BACKSLASH }, - new String[] { ESCAPE_CHAR_SLASH + ESCAPE_CHAR_SLASH, ESCAPE_CHAR_BACKSLASH + ESCAPE_CHAR_BACKSLASH }); - escapedSource = StringUtils.replaceEach(escapedSource, new String[] { "\\", "/" }, - new String[] { ESCAPE_CHAR_SLASH, ESCAPE_CHAR_BACKSLASH }); - - return createId("rendering", "macro", "plantuml", escapedSource, index); + return createId("rendering", "macro", "plantuml", source, index); } private String getCurrentSource(MacroTransformationContext context) diff --git a/macro-plantuml-macro/src/main/java/org/xwiki/contrib/plantuml/internal/store/TemporaryImageWriter.java b/macro-plantuml-macro/src/main/java/org/xwiki/contrib/plantuml/internal/store/TemporaryImageWriter.java index 2a91a51..2d41dea 100644 --- a/macro-plantuml-macro/src/main/java/org/xwiki/contrib/plantuml/internal/store/TemporaryImageWriter.java +++ b/macro-plantuml-macro/src/main/java/org/xwiki/contrib/plantuml/internal/store/TemporaryImageWriter.java @@ -31,6 +31,7 @@ import org.xwiki.bridge.DocumentAccessBridge; import org.xwiki.component.annotation.Component; import org.xwiki.rendering.macro.MacroExecutionException; +import org.xwiki.resource.ResourceReference; import org.xwiki.resource.ResourceReferenceSerializer; import org.xwiki.resource.SerializeResourceReferenceException; import org.xwiki.resource.UnsupportedResourceReferenceException; @@ -64,14 +65,8 @@ public class TemporaryImageWriter implements ImageWriter @Inject private TemporaryResourceStore temporaryResourceStore; - // TODO: Once this extension starts depending on XWiki 14.7+, change this to: - // @Inject - // private ResourceReferenceSerializer resourceReferenceSerializer; - // As it is right now, this is hardcoding the URL scheme and would prevent any other Temporary URL scheme to be - // used. @Inject - @Named("standard/tmp") - private ResourceReferenceSerializer temporaryResourceSerializer; + private ResourceReferenceSerializer resourceReferenceSerializer; @Override public OutputStream getOutputStream(String imageId) throws MacroExecutionException @@ -112,7 +107,7 @@ public ExtendedURL getURL(String imageId) throws MacroExecutionException { TemporaryResourceReference resourceReference = getTemporaryResourceReference(imageId); try { - return this.temporaryResourceSerializer.serialize(resourceReference); + return this.resourceReferenceSerializer.serialize(resourceReference); } catch (SerializeResourceReferenceException | UnsupportedResourceReferenceException e) { throw new MacroExecutionException(String.format("Failed to compute PlantUML image URL for [%s]", resourceReference), e); diff --git a/pom.xml b/pom.xml index 0133cae..f545ba0 100644 --- a/pom.xml +++ b/pom.xml @@ -71,6 +71,7 @@ occasional mantainer + PLANTUML @@ -81,20 +82,4 @@ macro-plantuml-macro macro-plantuml-ui - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - - - 8 - - - - -