From d388c7757010156bd79d4c2fb3cc812c91a4683d Mon Sep 17 00:00:00 2001 From: vnugent Date: Sat, 17 Aug 2024 22:00:42 -0400 Subject: package and configuration update for upstream updates --- back-end/src/Endpoints/BmAccountEndpoint.cs | 8 +++----- back-end/src/Endpoints/BookmarkEndpoint.cs | 21 ++++++------------- back-end/src/Endpoints/SiteLookupEndpoint.cs | 10 +++++----- back-end/src/SimpleBookmark.csproj | 8 ++++---- back-end/src/SimpleBookmarkEntry.cs | 30 +++++----------------------- 5 files changed, 23 insertions(+), 54 deletions(-) (limited to 'back-end/src') diff --git a/back-end/src/Endpoints/BmAccountEndpoint.cs b/back-end/src/Endpoints/BmAccountEndpoint.cs index 24ddb90..81b2ff3 100644 --- a/back-end/src/Endpoints/BmAccountEndpoint.cs +++ b/back-end/src/Endpoints/BmAccountEndpoint.cs @@ -36,11 +36,12 @@ using VNLib.Plugins.Extensions.Loading; using VNLib.Plugins.Extensions.Validation; using VNLib.Plugins.Extensions.Loading.Users; using VNLib.Plugins.Extensions.Loading.Events; - -using SimpleBookmark.Model; +using VNLib.Plugins.Extensions.Loading.Routing; namespace SimpleBookmark.Endpoints { + [EndpointPath("{{path}}")] + [EndpointLogName("Accounts")] [ConfigurationName("registration")] internal sealed class BmAccountEndpoint : UnprotectedWebEndpoint { @@ -58,9 +59,6 @@ namespace SimpleBookmark.Endpoints public BmAccountEndpoint(PluginBase plugin, IConfigScope config) { - string path = config.GetRequiredProperty("path", p => p.GetString()!); - InitPathAndLog(path, plugin.Log); - //get setup mode and enabled startup arguments SetupMode = plugin.HostArgs.HasArgument("--setup"); Enabled = !plugin.HostArgs.HasArgument("--disable-registation"); diff --git a/back-end/src/Endpoints/BookmarkEndpoint.cs b/back-end/src/Endpoints/BookmarkEndpoint.cs index ae2932d..d76cb35 100644 --- a/back-end/src/Endpoints/BookmarkEndpoint.cs +++ b/back-end/src/Endpoints/BookmarkEndpoint.cs @@ -39,6 +39,7 @@ using VNLib.Plugins.Essentials.Accounts; using VNLib.Plugins.Essentials.Endpoints; using VNLib.Plugins.Essentials.Extensions; using VNLib.Plugins.Extensions.Loading; +using VNLib.Plugins.Extensions.Loading.Routing; using VNLib.Plugins.Extensions.Data.Extensions; using VNLib.Plugins.Extensions.Validation; @@ -47,25 +48,15 @@ using SimpleBookmark.Model; namespace SimpleBookmark.Endpoints { + [EndpointPath("{{path}}")] + [EndpointLogName("Bookmarks")] [ConfigurationName("bm_endpoint")] - internal sealed class BookmarkEndpoint : ProtectedWebEndpoint + internal sealed class BookmarkEndpoint(PluginBase plugin, IConfigScope config) : ProtectedWebEndpoint { private static readonly IValidator BmValidator = BookmarkEntry.GetValidator(); - private readonly BookmarkStore Bookmarks; - private readonly BookmarkStoreConfig BmConfig; - - public BookmarkEndpoint(PluginBase plugin, IConfigScope config) - { - string? path = config.GetRequiredProperty("path", p => p.GetString()!); - InitPathAndLog(path, plugin.Log); - - //Init bookmark store - Bookmarks = plugin.GetOrCreateSingleton(); - - //Load config - BmConfig = config.GetRequiredProperty("config", p => p.Deserialize()!); - } + private readonly BookmarkStore Bookmarks = plugin.GetOrCreateSingleton(); + private readonly BookmarkStoreConfig BmConfig = config.GetRequiredProperty("config"); /// protected override async ValueTask GetAsync(HttpEntity entity) diff --git a/back-end/src/Endpoints/SiteLookupEndpoint.cs b/back-end/src/Endpoints/SiteLookupEndpoint.cs index effe6aa..f184ea9 100644 --- a/back-end/src/Endpoints/SiteLookupEndpoint.cs +++ b/back-end/src/Endpoints/SiteLookupEndpoint.cs @@ -28,11 +28,14 @@ using VNLib.Plugins.Essentials.Endpoints; using VNLib.Plugins.Essentials.Extensions; using VNLib.Plugins.Extensions.Loading; using VNLib.Plugins.Extensions.Validation; +using VNLib.Plugins.Extensions.Loading.Routing; using SimpleBookmark.PlatformFeatures.Curl; namespace SimpleBookmark.Endpoints { + [EndpointPath("{{path}}")] + [EndpointLogName("Site Lookup")] [ConfigurationName("curl")] internal sealed class SiteLookupEndpoint : ProtectedWebEndpoint { @@ -44,11 +47,8 @@ namespace SimpleBookmark.Endpoints public SiteLookupEndpoint(PluginBase plugin, IConfigScope config) { - string path = config.GetRequiredProperty("path", p => p.GetString()!); - InitPathAndLog(path, plugin.Log); - - string exePath = config.GetValueOrDefault("exe_path", p => p.GetString(), DefaultCurlExecName); - bool httspOnly = config.GetValueOrDefault("https_only", p => p.GetBoolean(), false); + string exePath = config.GetValueOrDefault("exe_path", DefaultCurlExecName); + bool httspOnly = config.GetValueOrDefault("https_only", false); //Optional extra arguments string[] extrArgs = config.GetValueOrDefault( diff --git a/back-end/src/SimpleBookmark.csproj b/back-end/src/SimpleBookmark.csproj index 382d141..ea8ade9 100644 --- a/back-end/src/SimpleBookmark.csproj +++ b/back-end/src/SimpleBookmark.csproj @@ -33,10 +33,10 @@ - - - - + + + + diff --git a/back-end/src/SimpleBookmarkEntry.cs b/back-end/src/SimpleBookmarkEntry.cs index 13b94a5..a3d9eb9 100644 --- a/back-end/src/SimpleBookmarkEntry.cs +++ b/back-end/src/SimpleBookmarkEntry.cs @@ -22,9 +22,6 @@ */ using System; -using System.Linq; -using System.Text; -using System.Text.Json; using VNLib.Plugins; using VNLib.Utils.Logging; @@ -76,7 +73,7 @@ namespace SimpleBookmark @" ****************************************************************************** Simple-Bookmark - A linkding inspired, self hosted, bookmark manager - By Vaughn Nugent - vnpublic @proton.me + By Vaughn Nugent - vnpublic@proton.me https://www.vaughnnugent.com/resources/software License: GNU Affero General Public License v3.0 This application comes with ABSOLUTELY NO WARRANTY. @@ -84,27 +81,10 @@ namespace SimpleBookmark Documentation: https://www.vaughnnugent.com/resources/software/articles?tags=docs,_simple-bookmark GitHub: https://github.com/VnUgE/simple-bookmark {warning} - Your server is now running at the following locations:{0} -******************************************************************************"; - - string[] interfaces = HostConfig.GetProperty("virtual_hosts") - .EnumerateArray() - .Select(e => - { - JsonElement el = e.GetProperty("interface"); - string ipAddress = el.GetProperty("address").GetString()!; - int port = el.GetProperty("port").GetInt32(); - return $"{ipAddress}:{port}"; - }) - .ToArray(); - - StringBuilder sb = new(); - foreach (string intf in interfaces) - { - sb.Append("\n\t"); - sb.AppendLine(intf); - } +\******************************************************************************"; + + //See if setup mode is enabled bool setupMode = HostArgs.HasArgument("--setup") && !HostArgs.HasArgument("--disable-registation"); @@ -112,7 +92,7 @@ namespace SimpleBookmark ? "\nWARNING: This server is in setup mode. Account registation is open to all users.\n" : string.Empty; - Log.Information(template, warnMessage, sb); + Log.Information(template, warnMessage); } } } -- cgit