From 1f4c6ab9badeb6a38a0dfb1d5c6c67aec3599d2f Mon Sep 17 00:00:00 2001 From: Wildling Dev Date: Sun, 14 Nov 2021 11:32:34 -0500 Subject: [PATCH] WIP: override support --- .../Chloroplast.Core/Content/ContentArea.cs | 6 +++-- .../Extensions/PathExtensions.cs | 5 +++- .../Loaders/EcmaXmlExtensions.cs | 7 +++++ .../Rendering/EcmaXmlRenderer.cs | 27 +++++++++++++++++++ 4 files changed, 42 insertions(+), 3 deletions(-) diff --git a/toolsrc/Chloroplast.Core/Content/ContentArea.cs b/toolsrc/Chloroplast.Core/Content/ContentArea.cs index 6519f60..35a2844 100644 --- a/toolsrc/Chloroplast.Core/Content/ContentArea.cs +++ b/toolsrc/Chloroplast.Core/Content/ContentArea.cs @@ -49,7 +49,8 @@ public static IEnumerable LoadContentAreas (IConfigurationRoot conf TargetPath = outDirectory.CombinePath (areaConfig["output_folder"].NormalizePath(toLower: normalizePaths)), RootRelativePath = areaConfig["output_folder"].Replace ("index.html", "").NormalizePath (toLower: normalizePaths), NormalizePaths = normalizePaths, - AreaType = areaConfig["type"] + AreaType = areaConfig["type"], + OverridePath = rootDirectory.CombinePath (areaConfig["override_folder"]) }; // TODO: validate values @@ -93,7 +94,8 @@ public string AreaType if (!string.IsNullOrWhiteSpace (value)) areaType = value; } - } + } + public string OverridePath { get; set; } public GroupContentArea () { diff --git a/toolsrc/Chloroplast.Core/Extensions/PathExtensions.cs b/toolsrc/Chloroplast.Core/Extensions/PathExtensions.cs index 2e6e05d..04213cc 100644 --- a/toolsrc/Chloroplast.Core/Extensions/PathExtensions.cs +++ b/toolsrc/Chloroplast.Core/Extensions/PathExtensions.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Linq; namespace Chloroplast.Core.Extensions { @@ -36,7 +37,9 @@ public static string GetPathFileName(this string value) public static string CombinePath(this string value, params string[] paths) { - string combinedPaths = Path.Combine (paths).NormalizePath (); + if (value == null) value = string.Empty; + + string combinedPaths = Path.Combine (paths.Where(p => !string.IsNullOrWhiteSpace(p)).ToArray()).NormalizePath (); if (combinedPaths.StartsWith (Path.DirectorySeparatorChar)) combinedPaths = combinedPaths.Substring (1); diff --git a/toolsrc/Chloroplast.Core/Loaders/EcmaXmlExtensions.cs b/toolsrc/Chloroplast.Core/Loaders/EcmaXmlExtensions.cs index e24fac6..91b4d5f 100644 --- a/toolsrc/Chloroplast.Core/Loaders/EcmaXmlExtensions.cs +++ b/toolsrc/Chloroplast.Core/Loaders/EcmaXmlExtensions.cs @@ -106,6 +106,13 @@ public class XType [XmlAttribute] public string FullName { get; set; } + public string Namespace { + get + { + return FullName.Replace ("." + Name, string.Empty); + } + } + [XmlElement ("TypeSignature")] public List Signatures { get; set; } = new List (); diff --git a/toolsrc/Chloroplast.Core/Rendering/EcmaXmlRenderer.cs b/toolsrc/Chloroplast.Core/Rendering/EcmaXmlRenderer.cs index cc6e6fa..38d6f47 100644 --- a/toolsrc/Chloroplast.Core/Rendering/EcmaXmlRenderer.cs +++ b/toolsrc/Chloroplast.Core/Rendering/EcmaXmlRenderer.cs @@ -1,5 +1,7 @@ using System; +using System.IO; using System.Threading.Tasks; +using Chloroplast.Core.Content; using Chloroplast.Core.Loaders; using Microsoft.Extensions.Configuration; using EcmaXml = Chloroplast.Core.Loaders.EcmaXml; @@ -19,7 +21,32 @@ public static async Task Render (ContentNode item, string body, if (body.StartsWith ("