From a931f8b7ced9a165a67b137542465ba3638b8f87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ha=CC=8Akan=20Edling?= Date: Sun, 3 Jan 2021 02:21:26 +0100 Subject: [PATCH] Added Id to the structure service. --- src/Statica/Models/StaticStructure.cs | 4 +--- src/Statica/Services/IStaticaService.cs | 10 +++++++++- src/Statica/Services/IStructureService.cs | 7 ++++++- src/Statica/Services/StaticaService.cs | 13 +++++++++++-- src/Statica/Services/StructureService.cs | 21 ++++++++++++++++++--- src/Statica/Statica.csproj | 6 +++--- 6 files changed, 48 insertions(+), 13 deletions(-) diff --git a/src/Statica/Models/StaticStructure.cs b/src/Statica/Models/StaticStructure.cs index 5695574..31af344 100644 --- a/src/Statica/Models/StaticStructure.cs +++ b/src/Statica/Models/StaticStructure.cs @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Håkan Edling + * Copyright (c) 2019-2021 Håkan Edling * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. @@ -8,8 +8,6 @@ * */ -using System.Collections.Generic; - namespace Statica.Models { public class StaticStructure diff --git a/src/Statica/Services/IStaticaService.cs b/src/Statica/Services/IStaticaService.cs index 23a3cf9..bc11891 100644 --- a/src/Statica/Services/IStaticaService.cs +++ b/src/Statica/Services/IStaticaService.cs @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Håkan Edling + * Copyright (c) 2019-2021 Håkan Edling * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. @@ -8,6 +8,8 @@ * */ +using System.Collections.Generic; + namespace Statica.Services { public interface IStaticaService @@ -18,5 +20,11 @@ public interface IStaticaService /// The base slug /// The structure IStructureService GetStructure(string slug); + + /// + /// Gets all of the available structures. + /// + /// A collection of structures + IEnumerable GetStructures(); } } \ No newline at end of file diff --git a/src/Statica/Services/IStructureService.cs b/src/Statica/Services/IStructureService.cs index 469e677..98437a2 100644 --- a/src/Statica/Services/IStructureService.cs +++ b/src/Statica/Services/IStructureService.cs @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Håkan Edling + * Copyright (c) 2019-2021 Håkan Edling * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. @@ -15,6 +15,11 @@ namespace Statica.Services { public interface IStructureService { + /// + /// Gets the unique structure id. + /// + string Id { get; } + /// /// Gets the current sitemap. /// diff --git a/src/Statica/Services/StaticaService.cs b/src/Statica/Services/StaticaService.cs index cc5001e..bdfaf9f 100644 --- a/src/Statica/Services/StaticaService.cs +++ b/src/Statica/Services/StaticaService.cs @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Håkan Edling + * Copyright (c) 2019-2021 Håkan Edling * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. @@ -28,7 +28,7 @@ public StaticaService(params StaticStructure[] structures) foreach (var structure in structures) { _structures[structure.Id] = - new StructureService(structure.BaseSlug, structure.DataPath); + new StructureService(structure.Id, structure.BaseSlug, structure.DataPath); } } @@ -45,5 +45,14 @@ public IStructureService GetStructure(string id) } return null; } + + /// + /// Gets all of the available structures. + /// + /// A collection of structures + public IEnumerable GetStructures() + { + return _structures.Values; + } } } \ No newline at end of file diff --git a/src/Statica/Services/StructureService.cs b/src/Statica/Services/StructureService.cs index 0ba360a..9fb9d84 100644 --- a/src/Statica/Services/StructureService.cs +++ b/src/Statica/Services/StructureService.cs @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Håkan Edling + * Copyright (c) 2019-2021 Håkan Edling * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. @@ -19,7 +19,10 @@ namespace Statica.Services { public class StructureService : IStructureService { - // The bas slug for the structure + // The unique id + private readonly string _id; + + // The base slug for the structure private readonly string _baseSlug; /// The base path for the structure. @@ -31,8 +34,15 @@ public class StructureService : IStructureService /// Mutex for initialization. private object mutex = new object(); - public StructureService(string baseSlug, string dataPath) + /// + /// Default constructor. + /// + /// The unique id + /// The base slug + /// The data path + public StructureService(string id, string baseSlug, string dataPath) { + _id = id; _baseSlug = baseSlug; _dataPath = dataPath; @@ -40,6 +50,11 @@ public StructureService(string baseSlug, string dataPath) _baseSlug += "/"; } + /// + /// Gets the unique structure id. + /// + public string Id => _id; + /// /// Gets the current page structure. /// diff --git a/src/Statica/Statica.csproj b/src/Statica/Statica.csproj index aa59f70..6b7a8ad 100644 --- a/src/Statica/Statica.csproj +++ b/src/Statica/Statica.csproj @@ -2,17 +2,17 @@ netcoreapp3.1 - 0.3.1 + 0.3.2 true true true snupkg Statica - 0.3.1 + 0.3.2 Håkan Edling Piranha Module for generating a partial page structure from local markdown files. - Copyright 2019-2020 (c) Håkan Edling + Copyright 2019-2021 (c) Håkan Edling aspnetcore netstandard MIT statica.png