forked from yuzutech/kroki
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resolves yuzutech#1521 use native image of Ditaa
- Loading branch information
1 parent
834f6aa
commit 7aaf223
Showing
19 changed files
with
253 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
server/src/main/java/io/kroki/server/service/DitaaCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package io.kroki.server.service; | ||
|
||
import io.kroki.server.action.Commander; | ||
import io.kroki.server.format.FileFormat; | ||
import io.vertx.core.json.JsonObject; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class DitaaCommand { | ||
|
||
private final String binPath; | ||
private final Commander commander; | ||
|
||
public DitaaCommand(JsonObject config) { | ||
this.binPath = config.getString("KROKI_DITAA_BIN_PATH", "ditaa"); | ||
this.commander = new Commander(config); | ||
} | ||
|
||
public byte[] convert(String source, FileFormat format, JsonObject options) throws IOException, InterruptedException { | ||
List<String> commands = new ArrayList<>(); | ||
commands.add(binPath); | ||
if (format.equals(FileFormat.SVG)) { | ||
commands.add("--svg"); | ||
} | ||
String noAntialias = options.getString("no-antialias"); | ||
if (noAntialias != null) { | ||
commands.add("--no-antialias"); | ||
} | ||
String noSeparation = options.getString("no-separation"); | ||
if (noSeparation != null) { | ||
commands.add("--no-separation"); | ||
} | ||
String roundCorners = options.getString("round-corners"); | ||
if (roundCorners != null) { | ||
commands.add("--round-corners"); | ||
} | ||
String scale = options.getString("scale"); | ||
if (scale != null) { | ||
commands.add("--scale " + scale); | ||
} | ||
String noShadows = options.getString("no-shadows"); | ||
if (noShadows != null) { | ||
commands.add("--no-shadows"); | ||
} | ||
String tabs = options.getString("tabs"); | ||
if (tabs != null) { | ||
commands.add("--tabs " + tabs); | ||
} | ||
commands.add("-"); | ||
return commander.execute(source.getBytes(), commands.toArray(new String[0])); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.