From cc28ebf6ac80ca23978ec65b705d45168bcfd741 Mon Sep 17 00:00:00 2001
From: Max <51083570+DRdrProfessor@users.noreply.github.com>
Date: Sun, 7 May 2023 18:37:25 +0200
Subject: [PATCH] Inplementing bootstrapper & updated 'ToolQit'
---
ToolQit | 2 +-
WebSharpRSS/Bootstrapper.cs | 29 +++++++++++++++++++++++++++++
WebSharpRSS/Pages/Index.razor | 19 +------------------
WebSharpRSS/Program.cs | 7 +++++++
WebSharpRSS/Settings.json | 4 ++++
WebSharpRSS/defaults.json | 4 ++++
6 files changed, 46 insertions(+), 19 deletions(-)
create mode 100644 WebSharpRSS/Bootstrapper.cs
create mode 100644 WebSharpRSS/Settings.json
create mode 100644 WebSharpRSS/defaults.json
diff --git a/ToolQit b/ToolQit
index d2d3f1b..49ec417 160000
--- a/ToolQit
+++ b/ToolQit
@@ -1 +1 @@
-Subproject commit d2d3f1b864d8eb424063735d721c1b310c9ab0df
+Subproject commit 49ec417fbaa33042d32a392dd2c432c386a7c5bf
diff --git a/WebSharpRSS/Bootstrapper.cs b/WebSharpRSS/Bootstrapper.cs
new file mode 100644
index 0000000..96fb437
--- /dev/null
+++ b/WebSharpRSS/Bootstrapper.cs
@@ -0,0 +1,29 @@
+using System;
+using System.IO;
+using Serilog;
+using Serilog.Formatting.Json;
+using ToolQit;
+using ToolQit.Containers;
+
+namespace WebSharpRSS
+{
+ public static class Bootstrapper
+ {
+ public static void SetContainerDefaults(this DataContainer dataCon)
+ {
+ dataCon.Set("FaviconResolveUrl", "https://icons.duckduckgo.com/ip3/{0}.ico");
+ dataCon.Set("LogPath", Path.Combine(Environment.CurrentDirectory, "logs", "log_.json"));
+ }
+
+ private static LoggerConfiguration? _configuration;
+ public static void SetupLogging()
+ {
+ if (_configuration != null) return;
+ _configuration = new LoggerConfiguration()
+ .WriteTo.Console()
+ .WriteTo.File(new JsonFormatter(), Caretaker.Settings.GetString("LogPath"), rollingInterval: RollingInterval.Day)
+ .MinimumLevel.Verbose();
+ Log.Logger = _configuration.CreateLogger();
+ }
+ }
+}
\ No newline at end of file
diff --git a/WebSharpRSS/Pages/Index.razor b/WebSharpRSS/Pages/Index.razor
index a8c4e71..2f95661 100644
--- a/WebSharpRSS/Pages/Index.razor
+++ b/WebSharpRSS/Pages/Index.razor
@@ -1,24 +1,7 @@
@page "/"
@inject RssService _rssService
-@*
- @for (int i = 0; i < 10; i++)
- {
-
-
-
- Old Paint
- Old paint found on a stone house door.
- This photo was taken in a small village in Istra Croatia.
-
-
- Share
- Learn More
-
-
- }
-
-*@
+
@code {
diff --git a/WebSharpRSS/Program.cs b/WebSharpRSS/Program.cs
index b8e327b..6250cfe 100644
--- a/WebSharpRSS/Program.cs
+++ b/WebSharpRSS/Program.cs
@@ -3,7 +3,13 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using MudBlazor;
using MudBlazor.Services;
+using Serilog;
using SharpRss;
+using ToolQit;
+using WebSharpRSS;
+
+Caretaker.Settings.SetContainerDefaults();
+Bootstrapper.SetupLogging();
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorPages();
@@ -11,6 +17,7 @@ builder.Services.AddServerSideBlazor();
builder.Services.AddTransient();
builder.Services.AddMudServices(config =>
{
+ Log.Debug("Configuring MudServices");
config.SnackbarConfiguration.PositionClass = Defaults.Classes.Position.BottomRight;
config.SnackbarConfiguration.PreventDuplicates = true;
config.SnackbarConfiguration.ShowCloseIcon = true;
diff --git a/WebSharpRSS/Settings.json b/WebSharpRSS/Settings.json
new file mode 100644
index 0000000..11c0578
--- /dev/null
+++ b/WebSharpRSS/Settings.json
@@ -0,0 +1,4 @@
+{
+ "FaviconResolveUrl": "https://icons.duckduckgo.com/ip3/{0}.ico",
+ "LogPath": "/home/max/GitHub/SharpRSS/WebSharpRSS/logs/log_.json"
+}
\ No newline at end of file
diff --git a/WebSharpRSS/defaults.json b/WebSharpRSS/defaults.json
new file mode 100644
index 0000000..11c0578
--- /dev/null
+++ b/WebSharpRSS/defaults.json
@@ -0,0 +1,4 @@
+{
+ "FaviconResolveUrl": "https://icons.duckduckgo.com/ip3/{0}.ico",
+ "LogPath": "/home/max/GitHub/SharpRSS/WebSharpRSS/logs/log_.json"
+}
\ No newline at end of file