From 3b566585507d499f3870e7014c99f985abe08812 Mon Sep 17 00:00:00 2001 From: Declan Lynch Date: Thu, 10 Aug 2023 15:48:19 -0400 Subject: [PATCH 1/2] Add the ability to set the target for links in the SVG file. --- README.md | 1 + docs/example/workspace.dsl | 1 + .../structurizr/site/generatr/site/DiagramGenerator.kt | 10 +++++++--- .../structurizr/site/generatr/site/SiteGenerator.kt | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5694f3f1..fe95cf97 100644 --- a/README.md +++ b/README.md @@ -262,6 +262,7 @@ architecture model: | `generatr.style.logoPath` | Site favicon location relative to the configured `assets` folder. When configured, the favicon will be set for all generated pages. This requires the `--assets-dir` switch when generating the site and the corresponding file to be available in the `assets` folder. | | `site/logo.png` | | `generatr.search.language` | Indexing/stemming language for the search index. See [Lunr language support](https://github.com/olivernn/lunr-languages) | `en` | `nl` | | `generatr.markdown.flexmark.extensions` | Additional extentions to the markdown generator to add new markdown capabilities. [More Details](https://avisi-cloud.github.io/structurizr-site-generatr/main/extended-markdown-features/) | Tables | `Tables,Admonition` | +| `generatr.link.target` | Specifies the link target for element links in the exported svg | `_top` | `_self` | See the included example for usage of some those properties in the diff --git a/docs/example/workspace.dsl b/docs/example/workspace.dsl index 992e1dc1..beb7856b 100644 --- a/docs/example/workspace.dsl +++ b/docs/example/workspace.dsl @@ -161,6 +161,7 @@ workspace "Big Bank plc" "This is an example workspace to illustrate the key fea "generatr.style.colors.secondary" "#ffffff" "generatr.style.faviconPath" "site/favicon.ico" "generatr.style.logoPath" "site/logo.png" + "generatr.link.target" "_self" // full list of available "generatr.markdown.flexmark.extensions" // "Abbreviation,Admonition,AnchorLink,Aside,Attributes,Autolink,Definition,Emoji,EnumeratedReference,Footnotes,GfmIssues,GfmStrikethroughSubscript,GfmTaskList,GfmUsers,GitLab,Ins,Macros,MediaTags,ResizableImage,Superscript,Tables,TableOfContents,SimulatedTableOfContents,Typographic,WikiLinks,XWikiMacro,YAMLFrontMatter,YouTubeLink" 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 5d1cdeca..5425e8d7 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 @@ -34,11 +34,11 @@ fun generateDiagrams(workspace: Workspace, exportDir: File) { } } -fun generateDiagramWithElementLinks(view: View, url: String, exportDir: File): String { +fun generateDiagramWithElementLinks(workspace: Workspace, view: View, url: String, exportDir: File): String { val pumlDir = pumlDir(exportDir) val svgDir = svgDir(exportDir) - val diagram = generatePlantUMLDiagramWithElementLinks(view, url) + val diagram = generatePlantUMLDiagramWithElementLinks(workspace, view, url) val name = "${diagram.key}-${view.key}" val plantUMLFile = File(pumlDir, "$name.puml") @@ -85,9 +85,13 @@ private fun readSvg(svgDir: File, name: String): String { return svgFile.readText() } -private fun generatePlantUMLDiagramWithElementLinks(view: View, url: String): Diagram { +private fun generatePlantUMLDiagramWithElementLinks(workspace: Workspace, view: View, url: String): Diagram { val plantUMLExporter = C4PlantUmlExporterWithElementLinks(url) + if (workspace.views.configuration.properties.containsKey("generatr.link.target")) { + plantUMLExporter.addSkinParam("svgLinkTarget", workspace.views.configuration.properties.getValue("generatr.link.target")) + } + return plantUMLExporter.export(view) } diff --git a/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/SiteGenerator.kt b/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/SiteGenerator.kt index db558a74..8bbfa91b 100644 --- a/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/SiteGenerator.kt +++ b/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/SiteGenerator.kt @@ -60,7 +60,7 @@ fun generateSite( ) { val generatorContext = GeneratorContext(version, workspace, branches, currentBranch, serving) { key, url -> workspace.views.views.singleOrNull { view -> view.key == key } - ?.let { generateDiagramWithElementLinks(it, url, exportDir) } + ?.let { generateDiagramWithElementLinks(workspace, it, url, exportDir) } } val branchDir = File(exportDir, currentBranch) From a2da645a80533822e892352201030623138a789c Mon Sep 17 00:00:00 2001 From: Declan Lynch Date: Thu, 10 Aug 2023 15:54:43 -0400 Subject: [PATCH 2/2] changed option to generatr.svglink.target so that it is clear that this only affects the SVG file output. --- README.md | 4 ++-- docs/example/workspace.dsl | 2 +- .../avisi/structurizr/site/generatr/site/DiagramGenerator.kt | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index fe95cf97..314df5af 100644 --- a/README.md +++ b/README.md @@ -261,8 +261,8 @@ architecture model: | `generatr.style.faviconPath` | Site logo location relative to the configured `assets` folder. When configured, the logo image will be place on the left side in the header bar. This requires the `--assets-dir` switch when generating the site and the corresponding file to be available in the `assets` folder. | | `site/favicon.ico` | | `generatr.style.logoPath` | Site favicon location relative to the configured `assets` folder. When configured, the favicon will be set for all generated pages. This requires the `--assets-dir` switch when generating the site and the corresponding file to be available in the `assets` folder. | | `site/logo.png` | | `generatr.search.language` | Indexing/stemming language for the search index. See [Lunr language support](https://github.com/olivernn/lunr-languages) | `en` | `nl` | -| `generatr.markdown.flexmark.extensions` | Additional extentions to the markdown generator to add new markdown capabilities. [More Details](https://avisi-cloud.github.io/structurizr-site-generatr/main/extended-markdown-features/) | Tables | `Tables,Admonition` | -| `generatr.link.target` | Specifies the link target for element links in the exported svg | `_top` | `_self` | +| `generatr.markdown.flexmark.extensions` | Additional extensions to the markdown generator to add new markdown capabilities. [More Details](https://avisi-cloud.github.io/structurizr-site-generatr/main/extended-markdown-features/) | Tables | `Tables,Admonition` | +| `generatr.svglink.target` | Specifies the link target for element links in the exported svg | `_top` | `_self` | See the included example for usage of some those properties in the diff --git a/docs/example/workspace.dsl b/docs/example/workspace.dsl index beb7856b..7b3260c9 100644 --- a/docs/example/workspace.dsl +++ b/docs/example/workspace.dsl @@ -161,7 +161,7 @@ workspace "Big Bank plc" "This is an example workspace to illustrate the key fea "generatr.style.colors.secondary" "#ffffff" "generatr.style.faviconPath" "site/favicon.ico" "generatr.style.logoPath" "site/logo.png" - "generatr.link.target" "_self" + "generatr.svglink.target" "_self" // full list of available "generatr.markdown.flexmark.extensions" // "Abbreviation,Admonition,AnchorLink,Aside,Attributes,Autolink,Definition,Emoji,EnumeratedReference,Footnotes,GfmIssues,GfmStrikethroughSubscript,GfmTaskList,GfmUsers,GitLab,Ins,Macros,MediaTags,ResizableImage,Superscript,Tables,TableOfContents,SimulatedTableOfContents,Typographic,WikiLinks,XWikiMacro,YAMLFrontMatter,YouTubeLink" 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 5425e8d7..355fe28c 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 @@ -88,8 +88,8 @@ private fun readSvg(svgDir: File, name: String): String { private fun generatePlantUMLDiagramWithElementLinks(workspace: Workspace, view: View, url: String): Diagram { val plantUMLExporter = C4PlantUmlExporterWithElementLinks(url) - if (workspace.views.configuration.properties.containsKey("generatr.link.target")) { - plantUMLExporter.addSkinParam("svgLinkTarget", workspace.views.configuration.properties.getValue("generatr.link.target")) + if (workspace.views.configuration.properties.containsKey("generatr.svglink.target")) { + plantUMLExporter.addSkinParam("svgLinkTarget", workspace.views.configuration.properties.getValue("generatr.svglink.target")) } return plantUMLExporter.export(view)