From 8e8d6aac5ba8e2c40ebb708864a952fccd3ce11b Mon Sep 17 00:00:00 2001 From: Erin Schnabel Date: Wed, 3 Apr 2024 15:01:39 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20funky=20characters=20in=20?= =?UTF-8?q?image=20names?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ebullient/convert/tools/dnd5e/Tools5eSources.java | 5 +++++ .../convert/tools/dnd5e/qute/Tools5eQuteBase.java | 4 ++-- .../dev/ebullient/convert/Tools5eDataConvertTest.java | 10 +++++----- src/test/resources/sources-homebrew.json | 10 ++++++++-- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/main/java/dev/ebullient/convert/tools/dnd5e/Tools5eSources.java b/src/main/java/dev/ebullient/convert/tools/dnd5e/Tools5eSources.java index 2c9233131..65651e241 100644 --- a/src/main/java/dev/ebullient/convert/tools/dnd5e/Tools5eSources.java +++ b/src/main/java/dev/ebullient/convert/tools/dnd5e/Tools5eSources.java @@ -251,6 +251,11 @@ public ImageRef buildImageRef(Tools5eIndex index, JsonMediaHref mediaHref, Strin int pos = fullPath.lastIndexOf('/'); String fileName = fullPath.substring(pos + 1); + int query = fileName.lastIndexOf('?'); + if (query >= 0) { + fileName = fileName.substring(0, query); + } + if (type == Tools5eIndexType.deity || type == Tools5eIndexType.note || type == Tools5eIndexType.variantrule) { fileName = primarySource() + "-" + fileName; } diff --git a/src/main/java/dev/ebullient/convert/tools/dnd5e/qute/Tools5eQuteBase.java b/src/main/java/dev/ebullient/convert/tools/dnd5e/qute/Tools5eQuteBase.java index c4120d502..486b0cc12 100644 --- a/src/main/java/dev/ebullient/convert/tools/dnd5e/qute/Tools5eQuteBase.java +++ b/src/main/java/dev/ebullient/convert/tools/dnd5e/qute/Tools5eQuteBase.java @@ -66,7 +66,7 @@ private static String sourceIfNotDefault(String source, Tools5eIndexType type) { if (type != null && source.equalsIgnoreCase(type.defaultSourceString())) { return ""; } - return "-" + source.toLowerCase(); + return "-" + Tui.slugify(source); } } @@ -90,7 +90,7 @@ public static String getDeityResourceName(String name, String source, String pan switch (pantheon.toLowerCase()) { case "exandria" -> { if (!source.equalsIgnoreCase("egw")) { - suffix = "-" + source.toLowerCase(); + suffix = "-" + Tui.slugify(source); } } } diff --git a/src/test/java/dev/ebullient/convert/Tools5eDataConvertTest.java b/src/test/java/dev/ebullient/convert/Tools5eDataConvertTest.java index 81e7fce2b..dea835ac6 100644 --- a/src/test/java/dev/ebullient/convert/Tools5eDataConvertTest.java +++ b/src/test/java/dev/ebullient/convert/Tools5eDataConvertTest.java @@ -148,11 +148,11 @@ void testLiveData_5eHomebrew(QuarkusMainLauncher launcher) { "-o", target.toString(), TestUtils.PATH_5E_TOOLS_DATA.toString())); - // if (TestUtils.PATH_5E_TOOLS_IMAGES.toFile().exists()) { - // args.add(TestUtils.TEST_RESOURCES.resolve("images-from-local.json").toString()); - // } else { - args.add(TestUtils.TEST_RESOURCES.resolve("images-remote.json").toString()); - // } + if (TestUtils.PATH_5E_TOOLS_IMAGES.toFile().exists()) { + args.add(TestUtils.TEST_RESOURCES.resolve("images-from-local.json").toString()); + } else { + args.add(TestUtils.TEST_RESOURCES.resolve("images-remote.json").toString()); + } LaunchResult result = launcher.launch(args.toArray(new String[0])); assertThat(result.exitCode()) diff --git a/src/test/resources/sources-homebrew.json b/src/test/resources/sources-homebrew.json index 8f2bc4912..485981e4e 100644 --- a/src/test/resources/sources-homebrew.json +++ b/src/test/resources/sources-homebrew.json @@ -32,7 +32,8 @@ "sources/5e-homebrew/creature/MCDM Productions; Flee, Mortals! preview.json", "sources/5e-homebrew/creature/MCDM Productions; Flee, Mortals!.json", "sources/5e-homebrew/creature/Nerzugal Role-Playing; Nerzugal's Extended Bestiary.json", - "sources/5e-homebrew/deity/Frog God Games; The Lost Lands.json" + "sources/5e-homebrew/deity/Frog God Games; The Lost Lands.json", + "sources/5e-homebrew/collection/Loot Tavern; Heliana's Guide To Monster Hunting.json" ] }, "from": [ @@ -53,7 +54,12 @@ "race|.*|dmg" ], "template": { + "background": "examples/templates/tools5e/images-background2md.txt", + "item": "examples/templates/tools5e/images-item2md.txt", "monster": "src/test/resources/other/monster-all.txt", - "item": "examples/templates/tools5e/images-item2md.txt" + "object": "examples/templates/tools5e/images-object2md.txt", + "race": "examples/templates/tools5e/images-race2md.txt", + "spell": "examples/templates/tools5e/images-spell2md.txt", + "vehicle": "examples/templates/tools5e/images-vehicle2md.txt" } }