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

Issue adding icons to styles in 1.1.7 #363

Closed
qtzar opened this issue Nov 1, 2023 · 2 comments
Closed

Issue adding icons to styles in 1.1.7 #363

qtzar opened this issue Nov 1, 2023 · 2 comments

Comments

@qtzar
Copy link
Contributor

qtzar commented Nov 1, 2023

In our workspace we have setup a number of styles similar to the following where the 'icons' folder exists in the same directory as the workspace folder.

    element "SpringBoot" {
        background #6CB33D
        description false
        properties {
            "c4plantuml.sprite" "img:icons/springboot.png"
        }
    }

In 1.1.4 our diagrams would be generated correctly and the icons would show on the elements that had the appropriate tag however in the newer version the icons are no longer appearing when the site is generated from a GitHub repository, but they still work fine from a locally generated site or when you use a local serve.

I believe that the new caching feature caused a small change where the working directory is no longer the directory the workspace.dsl file is and thus the diagram generator is not able to find that icons directory any more.

@jp7677
Copy link
Contributor

jp7677 commented Nov 2, 2023

Interesting. Does this really no longer reproduce by completely removing the cache?

diff --git a/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/DiagramGenerator.kt b/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/DiagramGenerator.kt
index 83e13e5..01ab573 100644
--- a/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/DiagramGenerator.kt
+++ b/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/DiagramGenerator.kt
@@ -43,15 +43,11 @@ fun generateDiagramWithElementLinks(
     diagramCache: ConcurrentHashMap<String, String>
 ): String {
     val diagram = generatePlantUMLDiagramWithElementLinks(workspace, view, url)
+    val reader = SourceStringReader(diagram.withCachedIncludes().definition)
+    val stream = ByteArrayOutputStream()
 
-    val name = "${diagram.key}-${view.key}"
-    return diagramCache.getOrPut(name) {
-        val reader = SourceStringReader(diagram.withCachedIncludes().definition)
-        val stream = ByteArrayOutputStream()
-
-        reader.outputImage(stream, FileFormatOption(FileFormat.SVG, false))
-        stream.toString(Charsets.UTF_8)
-    }
+    reader.outputImage(stream, FileFormatOption(FileFormat.SVG, false))
+    stream.toString(Charsets.UTF_8)
 }
 
 private fun generatePlantUMLDiagrams(workspace: Workspace): Collection<Diagram> {

@jp7677
Copy link
Contributor

jp7677 commented Nov 6, 2023

Hi @qtzar I've looked again briefly at the code, but couldn't see anything obvious. Do you happen to have a public repo with a minimal setup where that issue can be seen?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants