From b71e6c9b3c22b3c63d89f5b7914635d02bd5a817 Mon Sep 17 00:00:00 2001 From: Ian Wold <1645320+IanWold@users.noreply.github.com> Date: Mon, 15 Aug 2022 17:04:17 -0500 Subject: [PATCH] Remove examples (#16) --- .../Metalsharp.ExamplePlugin/Drafts.cs | 29 ------------ .../Metalsharp.ExamplePlugin/Layout.cs | 45 ------------------- .../Metalsharp.ExamplePlugin.csproj | 11 ----- .../MetalsharpExtensions.cs | 20 --------- .../Metalsharp.ExampleWebsite.csproj | 27 ----------- .../Metalsharp.ExampleWebsite/Program.cs | 11 ----- .../Metalsharp.ExampleWebsite/Site/Draft.md | 10 ----- .../Metalsharp.ExampleWebsite/Site/Index.md | 10 ----- .../Metalsharp.ExampleWebsite/layout.template | 8 ---- Metalsharp.sln | 18 -------- 10 files changed, 189 deletions(-) delete mode 100644 Metalsharp.Examples/Metalsharp.ExamplePlugin/Drafts.cs delete mode 100644 Metalsharp.Examples/Metalsharp.ExamplePlugin/Layout.cs delete mode 100644 Metalsharp.Examples/Metalsharp.ExamplePlugin/Metalsharp.ExamplePlugin.csproj delete mode 100644 Metalsharp.Examples/Metalsharp.ExamplePlugin/MetalsharpExtensions.cs delete mode 100644 Metalsharp.Examples/Metalsharp.ExampleWebsite/Metalsharp.ExampleWebsite.csproj delete mode 100644 Metalsharp.Examples/Metalsharp.ExampleWebsite/Program.cs delete mode 100644 Metalsharp.Examples/Metalsharp.ExampleWebsite/Site/Draft.md delete mode 100644 Metalsharp.Examples/Metalsharp.ExampleWebsite/Site/Index.md delete mode 100644 Metalsharp.Examples/Metalsharp.ExampleWebsite/layout.template diff --git a/Metalsharp.Examples/Metalsharp.ExamplePlugin/Drafts.cs b/Metalsharp.Examples/Metalsharp.ExamplePlugin/Drafts.cs deleted file mode 100644 index dbe8f94..0000000 --- a/Metalsharp.Examples/Metalsharp.ExamplePlugin/Drafts.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace Metalsharp.ExamplePlugin -{ - /// - /// The Drafts plugin - /// - /// Removes any input or output file with ("draft", true) in its metadata - /// - public class Drafts : IMetalsharpPlugin - { - /// - /// Invokes the plugin - /// - /// - public void Execute(MetalsharpProject project) - { - project.InputFiles.RemoveAll(file => - file.Metadata.TryGetValue("draft", out var _isDraft) - && _isDraft is bool isDraft - && isDraft - ); - - project.OutputFiles.RemoveAll(file => - file.Metadata.TryGetValue("draft", out var _isDraft) - && _isDraft is bool isDraft - && isDraft - ); - } - } -} diff --git a/Metalsharp.Examples/Metalsharp.ExamplePlugin/Layout.cs b/Metalsharp.Examples/Metalsharp.ExamplePlugin/Layout.cs deleted file mode 100644 index 77f6e04..0000000 --- a/Metalsharp.Examples/Metalsharp.ExamplePlugin/Layout.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System.IO; -using System.Linq; -using System.Text.RegularExpressions; - -namespace Metalsharp.ExamplePlugin -{ - /// - /// The Layout plugin - /// - /// Applies an HTML layout to every HTML page in the output, - /// if that page has a layout file specified in its metadata - /// - public class Layout : IMetalsharpPlugin - { - /// - /// Invokes the plugin - /// - /// - public void Execute(MetalsharpProject project) - { - foreach (var file in project.OutputFiles.Where(i => i.Extension == ".html")) - { - if (file.Metadata.TryGetValue("layout", out var _layoutFile) - && _layoutFile is string layoutFile - && File.Exists(layoutFile) - ) - { - var regex = new Regex("\\{\\{(\\s)*content(\\s)*\\}\\}"); - var res = regex.Replace(File.ReadAllText(layoutFile), file.Text); - - foreach (var meta in file.Metadata) - { - regex = new Regex("\\{\\{(\\s)*" + meta.Key + "(\\s)*\\}\\}"); - if (regex.IsMatch(res)) - { - res = regex.Replace(res, meta.Value.ToString()); - } - } - - file.Text = res; - } - } - } - } -} diff --git a/Metalsharp.Examples/Metalsharp.ExamplePlugin/Metalsharp.ExamplePlugin.csproj b/Metalsharp.Examples/Metalsharp.ExamplePlugin/Metalsharp.ExamplePlugin.csproj deleted file mode 100644 index 0de646c..0000000 --- a/Metalsharp.Examples/Metalsharp.ExamplePlugin/Metalsharp.ExamplePlugin.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - net6 - - - - - - - diff --git a/Metalsharp.Examples/Metalsharp.ExamplePlugin/MetalsharpExtensions.cs b/Metalsharp.Examples/Metalsharp.ExamplePlugin/MetalsharpExtensions.cs deleted file mode 100644 index 2a59185..0000000 --- a/Metalsharp.Examples/Metalsharp.ExamplePlugin/MetalsharpExtensions.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace Metalsharp.ExamplePlugin -{ - public static class MetalsharpExtensions - { - /// - /// Invoke the Drafts plugin - /// - /// - public static MetalsharpProject UseDrafts(this MetalsharpProject project) => - project.Use(new Drafts()); - - /// - /// Invoke the Layout plugin - /// - /// - /// The path to the layout file - public static MetalsharpProject UseLayout(this MetalsharpProject project, string filePath) => - project.Use(new Layout()); - } -} diff --git a/Metalsharp.Examples/Metalsharp.ExampleWebsite/Metalsharp.ExampleWebsite.csproj b/Metalsharp.Examples/Metalsharp.ExampleWebsite/Metalsharp.ExampleWebsite.csproj deleted file mode 100644 index 034fc48..0000000 --- a/Metalsharp.Examples/Metalsharp.ExampleWebsite/Metalsharp.ExampleWebsite.csproj +++ /dev/null @@ -1,27 +0,0 @@ - - - - Exe - net6.0 - enable - enable - - - - - - - - - - Always - - - Always - - - Always - - - - diff --git a/Metalsharp.Examples/Metalsharp.ExampleWebsite/Program.cs b/Metalsharp.Examples/Metalsharp.ExampleWebsite/Program.cs deleted file mode 100644 index 457a1ec..0000000 --- a/Metalsharp.Examples/Metalsharp.ExampleWebsite/Program.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Metalsharp; -using Metalsharp.ExamplePlugin; -using Metalsharp.Logging; - -new MetalsharpProject(new MetalsharpConfiguration { Verbosity = LogLevel.Debug }) - .AddInput("Site") - .Use() - .UseDrafts() - .Use() - .Use(new Layout()) - .Build(); diff --git a/Metalsharp.Examples/Metalsharp.ExampleWebsite/Site/Draft.md b/Metalsharp.Examples/Metalsharp.ExampleWebsite/Site/Draft.md deleted file mode 100644 index 4fecde5..0000000 --- a/Metalsharp.Examples/Metalsharp.ExampleWebsite/Site/Draft.md +++ /dev/null @@ -1,10 +0,0 @@ -;;; -{ - "title": "Draft", - "draft": true -} -;;; - -# This is a draft - -If you use the `Drafts` plugin it won't be included in the output directory. \ No newline at end of file diff --git a/Metalsharp.Examples/Metalsharp.ExampleWebsite/Site/Index.md b/Metalsharp.Examples/Metalsharp.ExampleWebsite/Site/Index.md deleted file mode 100644 index bae1e6a..0000000 --- a/Metalsharp.Examples/Metalsharp.ExampleWebsite/Site/Index.md +++ /dev/null @@ -1,10 +0,0 @@ -;;; -{ - "title": "Index", - "layout": "layout.template" -} -;;; - -# Hello! - -World \ No newline at end of file diff --git a/Metalsharp.Examples/Metalsharp.ExampleWebsite/layout.template b/Metalsharp.Examples/Metalsharp.ExampleWebsite/layout.template deleted file mode 100644 index 8970e35..0000000 --- a/Metalsharp.Examples/Metalsharp.ExampleWebsite/layout.template +++ /dev/null @@ -1,8 +0,0 @@ - - -{{title}} - - -{{content}} - - \ No newline at end of file diff --git a/Metalsharp.sln b/Metalsharp.sln index 97cfd0b..bbd5af1 100644 --- a/Metalsharp.sln +++ b/Metalsharp.sln @@ -15,10 +15,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution README.md = README.md EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Metalsharp.Examples", "Metalsharp.Examples", "{945D79AE-689D-40AB-9895-25216E7DCFFD}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Metalsharp.ExamplePlugin", "Metalsharp.Examples\Metalsharp.ExamplePlugin\Metalsharp.ExamplePlugin.csproj", "{0C8CF260-43D9-41A1-AED2-B47404490B76}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Metalsharp.Tests", "Metalsharp.Tests\Metalsharp.Tests.csproj", "{A969B480-A460-4F6F-86E4-8E2D4CE2A5A3}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Metalsharp.Documentation", "Metalsharp.Documentation", "{546D55B0-7888-4947-A29B-3017232C1181}" @@ -29,8 +25,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Metalsharp.Documentation", Metalsharp.Documentation\tutorial-website.md = Metalsharp.Documentation\tutorial-website.md EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Metalsharp.ExampleWebsite", "Metalsharp.Examples\Metalsharp.ExampleWebsite\Metalsharp.ExampleWebsite.csproj", "{EC1FCDD0-3250-471B-8E2F-A99E3BC5E564}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -41,26 +35,14 @@ Global {BC5A2CC9-9F50-4061-8A1A-B7AB8D131251}.Debug|Any CPU.Build.0 = Debug|Any CPU {BC5A2CC9-9F50-4061-8A1A-B7AB8D131251}.Release|Any CPU.ActiveCfg = Release|Any CPU {BC5A2CC9-9F50-4061-8A1A-B7AB8D131251}.Release|Any CPU.Build.0 = Release|Any CPU - {0C8CF260-43D9-41A1-AED2-B47404490B76}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0C8CF260-43D9-41A1-AED2-B47404490B76}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0C8CF260-43D9-41A1-AED2-B47404490B76}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0C8CF260-43D9-41A1-AED2-B47404490B76}.Release|Any CPU.Build.0 = Release|Any CPU {A969B480-A460-4F6F-86E4-8E2D4CE2A5A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A969B480-A460-4F6F-86E4-8E2D4CE2A5A3}.Debug|Any CPU.Build.0 = Debug|Any CPU {A969B480-A460-4F6F-86E4-8E2D4CE2A5A3}.Release|Any CPU.ActiveCfg = Release|Any CPU {A969B480-A460-4F6F-86E4-8E2D4CE2A5A3}.Release|Any CPU.Build.0 = Release|Any CPU - {EC1FCDD0-3250-471B-8E2F-A99E3BC5E564}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {EC1FCDD0-3250-471B-8E2F-A99E3BC5E564}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EC1FCDD0-3250-471B-8E2F-A99E3BC5E564}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EC1FCDD0-3250-471B-8E2F-A99E3BC5E564}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {0C8CF260-43D9-41A1-AED2-B47404490B76} = {945D79AE-689D-40AB-9895-25216E7DCFFD} - {EC1FCDD0-3250-471B-8E2F-A99E3BC5E564} = {945D79AE-689D-40AB-9895-25216E7DCFFD} - EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {F1302004-B5D6-48D4-B9DE-2B069A693245} EndGlobalSection