From dae9e7c94f7f6417b8de38128c498235be474a4f Mon Sep 17 00:00:00 2001 From: Ben Stutzman Date: Tue, 18 May 2021 11:22:48 -0400 Subject: [PATCH 1/4] Add optional URL include instead of file include --- src/C4Sharp/Models/Plantuml/PlantumlDiagram.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/C4Sharp/Models/Plantuml/PlantumlDiagram.cs b/src/C4Sharp/Models/Plantuml/PlantumlDiagram.cs index 3429713..05b42db 100644 --- a/src/C4Sharp/Models/Plantuml/PlantumlDiagram.cs +++ b/src/C4Sharp/Models/Plantuml/PlantumlDiagram.cs @@ -15,9 +15,11 @@ internal static class PlantumlDiagram /// /// /// - public static string ToPumlString(this Diagram diagram) + public static string ToPumlString(this Diagram diagram, bool useUrlInclude = false) { - var path = Path.Join(C4Directory.ResourcesFolderName, $"{diagram.Name}.puml"); + var pumlFileName = $"{diagram.Name}.puml"; + var path = useUrlInclude ? "https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/{pumlFile}" + : Path.Join(C4Directory.ResourcesFolderName, pumlFileName); var stream = new StringBuilder(); stream.AppendLine($"@startuml {diagram.Slug()}"); From cf7fb33654bc2aa88606b4105122cdc35ce100b8 Mon Sep 17 00:00:00 2001 From: Ben Stutzman Date: Tue, 18 May 2021 11:31:09 -0400 Subject: [PATCH 2/4] Fix string interpolation --- src/C4Sharp/Models/Plantuml/PlantumlDiagram.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/C4Sharp/Models/Plantuml/PlantumlDiagram.cs b/src/C4Sharp/Models/Plantuml/PlantumlDiagram.cs index 05b42db..2684beb 100644 --- a/src/C4Sharp/Models/Plantuml/PlantumlDiagram.cs +++ b/src/C4Sharp/Models/Plantuml/PlantumlDiagram.cs @@ -18,7 +18,7 @@ internal static class PlantumlDiagram public static string ToPumlString(this Diagram diagram, bool useUrlInclude = false) { var pumlFileName = $"{diagram.Name}.puml"; - var path = useUrlInclude ? "https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/{pumlFile}" + var path = useUrlInclude ? $"https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/{pumlFileName}" : Path.Join(C4Directory.ResourcesFolderName, pumlFileName); var stream = new StringBuilder(); From 925fabae5fc6c6cd0c920f205526afe822ad6946 Mon Sep 17 00:00:00 2001 From: Ben Stutzman Date: Tue, 18 May 2021 11:42:41 -0400 Subject: [PATCH 3/4] Move URL to constant --- src/C4Sharp/Models/Plantuml/PlantumlDiagram.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/C4Sharp/Models/Plantuml/PlantumlDiagram.cs b/src/C4Sharp/Models/Plantuml/PlantumlDiagram.cs index 2684beb..bd152d8 100644 --- a/src/C4Sharp/Models/Plantuml/PlantumlDiagram.cs +++ b/src/C4Sharp/Models/Plantuml/PlantumlDiagram.cs @@ -10,6 +10,8 @@ namespace C4Sharp.Models.Plantuml /// internal static class PlantumlDiagram { + const string stdlibBaseUrl = "https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master"; + /// /// Create PUML content from Diagram /// @@ -18,8 +20,8 @@ internal static class PlantumlDiagram public static string ToPumlString(this Diagram diagram, bool useUrlInclude = false) { var pumlFileName = $"{diagram.Name}.puml"; - var path = useUrlInclude ? $"https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/{pumlFileName}" - : Path.Join(C4Directory.ResourcesFolderName, pumlFileName); + var path = useUrlInclude ? $"{stdlibBaseUrl}/{pumlFileName}" + : Path.Join(C4Directory.ResourcesFolderName, pumlFileName); var stream = new StringBuilder(); stream.AppendLine($"@startuml {diagram.Slug()}"); From 14761b5d8e60e63f36f9e4606abdc8da6a802e0a Mon Sep 17 00:00:00 2001 From: Ben Stutzman Date: Mon, 24 May 2021 15:44:33 -0400 Subject: [PATCH 4/4] Spell out variable name --- src/C4Sharp/Models/Plantuml/PlantumlDiagram.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/C4Sharp/Models/Plantuml/PlantumlDiagram.cs b/src/C4Sharp/Models/Plantuml/PlantumlDiagram.cs index bd152d8..73722f6 100644 --- a/src/C4Sharp/Models/Plantuml/PlantumlDiagram.cs +++ b/src/C4Sharp/Models/Plantuml/PlantumlDiagram.cs @@ -10,7 +10,7 @@ namespace C4Sharp.Models.Plantuml /// internal static class PlantumlDiagram { - const string stdlibBaseUrl = "https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master"; + const string standardLibraryBaseUrl = "https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master"; /// /// Create PUML content from Diagram @@ -20,7 +20,7 @@ internal static class PlantumlDiagram public static string ToPumlString(this Diagram diagram, bool useUrlInclude = false) { var pumlFileName = $"{diagram.Name}.puml"; - var path = useUrlInclude ? $"{stdlibBaseUrl}/{pumlFileName}" + var path = useUrlInclude ? $"{standardLibraryBaseUrl}/{pumlFileName}" : Path.Join(C4Directory.ResourcesFolderName, pumlFileName); var stream = new StringBuilder();