Skip to content

Commit

Permalink
Merge pull request #219 from MartinZikmund/feature/cleanup-feed-confi…
Browse files Browse the repository at this point in the history
…guration

Adjust feed configuration to use appsettings
  • Loading branch information
MartinZikmund authored Jan 24, 2024
2 parents 6ee1d12 + 902a5f9 commit e16d1f5
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 17 deletions.
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"sdk": {
"version": "8.0.0",
"allowPrerelease": true,
"allowPrerelease": false,
"rollForward": "latestMinor"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ public class AuthorOptions
public string Email { get; set; } = "";

public string PasswordHash { get; set; } = "";

public string FullName => $"{FirstName} {LastName}";
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public class GeneralOptions

public string TitleFormatString { get; set; } = "";

public string DefaultCulture { get; set; } = "";

public Uri Url { get; set; } = null!;

public Uri WasmAppUrl { get; set; } = null!;
Expand Down
37 changes: 21 additions & 16 deletions src/web/MZikmund.Web.Core/Syndication/FeedGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,46 @@
using EwSyndicationLink = Edi.SyndicationFeed.ReaderWriter.SyndicationLink;
using EwSyndicationCategory = Edi.SyndicationFeed.ReaderWriter.SyndicationCategory;
using EwSyndicationPerson = Edi.SyndicationFeed.ReaderWriter.SyndicationPerson;
using Microsoft.Extensions.Options;
using MZikmund.Web.Configuration.ConfigSections;
using MZikmund.Web.Configuration;
using System.Reflection;

namespace MZikmund.Web.Core.Syndication;

public class FeedGenerator : IFeedGenerator
{
public FeedGenerator(IHttpContextAccessor httpContextAccessor)
public FeedGenerator(
IHttpContextAccessor httpContextAccessor,
ISiteConfiguration siteConfiguration)
{
//TODO: Move all values into configuration
var baseUrl = httpContextAccessor.HttpContext.Request.GetBaseUrl();
HostUrl = baseUrl!;
HeadTitle = "Martin Zikmund";
HeadDescription = "Open-source enthusiast and Microsoft MVP. Passionate speaker, avid climber, and Lego aficionado.";
Copyright = ${DateTimeOffset.UtcNow.Year} Martin Zikmund";
Generator = "MZikmund";
GeneratorVersion = "0.1";
HeadTitle = siteConfiguration.General.DefaultTitle;
HeadDescription = siteConfiguration.General.DefaultDescription;
Copyright = ${DateTimeOffset.UtcNow.Year} {siteConfiguration.Author.FullName}";
Generator = siteConfiguration.General.EngineName;
GeneratorVersion = Assembly.GetEntryAssembly()?.GetName()?.Version?.ToString() ?? "0.1";
TrackBackUrl = baseUrl!;
Language = "en-US";
Language = siteConfiguration.General.DefaultCulture;
}

//TODO: Hide properties, use a private feed configuration class instead
public string HostUrl { get; set; }
public string HostUrl { get; }

public string HeadTitle { get; set; }
public string HeadTitle { get; }

public string HeadDescription { get; set; }
public string HeadDescription { get; }

public string Copyright { get; set; }
public string Copyright { get; }

public string Generator { get; set; }
public string Generator { get; }

public string TrackBackUrl { get; set; }
public string TrackBackUrl { get; }

public string GeneratorVersion { get; set; }
public string GeneratorVersion { get; }

public string Language { get; set; }
public string Language { get; }

public async Task<string> GetRssAsync(IEnumerable<FeedEntry> feedEntries, string id)
{
Expand Down
1 change: 1 addition & 0 deletions src/web/MZikmund.Web/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"DefaultTitle": "Martin Zikmund — Open-source Developer, Speaker",
"DefaultDescription": "Open-source enthusiast and Microsoft MVP. Passionate speaker, avid climber, and Lego aficionado.",
"DefaultKeywords": "software, open-source, development, IT, climbing, Lego",
"DefaultCulture": "en-US",
"TitleFormatString": "{0} | Martin Zikmund",
"Url": "https://mzikmund.dev",
"WasmAppUrl": "https://mzikmund.app",
Expand Down

0 comments on commit e16d1f5

Please sign in to comment.