Skip to content

Commit 79c68a9

Browse files
digitaldirklinkdotnet
authored andcommitted
Add more places for Donation sections. Refactored existing code, added new support me configuration.
1 parent 71a3698 commit 79c68a9

File tree

13 files changed

+140
-52
lines changed

13 files changed

+140
-52
lines changed

src/LinkDotNet.Blog.Web/ApplicationConfiguration.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,7 @@ public sealed record ApplicationConfiguration
2222

2323
public bool IsDisqusEnabled { get; set; }
2424

25-
public string? KofiToken { get; init; }
26-
27-
public bool IsKofiEnabled => !string.IsNullOrEmpty(KofiToken);
28-
29-
public string? GithubSponsorName { get; init; }
30-
31-
public bool IsGithubSponsorAvailable => !string.IsNullOrEmpty(GithubSponsorName);
32-
3325
public bool ShowReadingIndicator { get; init; }
3426

35-
public string? PatreonName { get; init; }
36-
37-
public bool IsPatreonEnabled => !string.IsNullOrEmpty(PatreonName);
38-
3927
public bool ShowSimilarPosts { get; init; }
4028
}

src/LinkDotNet.Blog.Web/ConfigurationExtension.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using LinkDotNet.Blog.Domain;
33
using LinkDotNet.Blog.Web.Authentication.OpenIdConnect;
44
using LinkDotNet.Blog.Web.Features.ShowBlogPost.Components;
5+
using LinkDotNet.Blog.Web.Features.SupportMe.Components;
56
using Microsoft.Extensions.Configuration;
67
using Microsoft.Extensions.DependencyInjection;
78

@@ -18,7 +19,8 @@ public static IServiceCollection AddConfiguration(this IServiceCollection servic
1819
.AddSocialConfigurations()
1920
.AddProfileInformationConfigurations()
2021
.AddGiscusConfiguration()
21-
.AddDisqusConfiguration();
22+
.AddDisqusConfiguration()
23+
.AddSupportMeConfiguration();
2224

2325
return services;
2426
}
@@ -115,4 +117,16 @@ private static IServiceCollection AddDisqusConfiguration(this IServiceCollection
115117
});
116118
return services;
117119
}
120+
121+
private static IServiceCollection AddSupportMeConfiguration(this IServiceCollection services)
122+
{
123+
ArgumentNullException.ThrowIfNull(services);
124+
125+
services.AddOptions<SupportMeConfiguration>()
126+
.Configure<IConfiguration>((settings, config) =>
127+
{
128+
config.GetSection(SupportMeConfiguration.SupportMeConfigurationSection).Bind(settings);
129+
});
130+
return services;
131+
}
118132
}

src/LinkDotNet.Blog.Web/Features/Home/Components/Footer.razor

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
@using LinkDotNet.Blog.Domain
2+
@using LinkDotNet.Blog.Web.Features.SupportMe.Components
23
@inject IOptions<ApplicationConfiguration> AppConfiguration
34
@inject IOptions<ProfileInformation> ProfileInformation
5+
@inject IOptions<SupportMeConfiguration> SupportConfiguration
46

57
<footer id="footer" class="text-center">
68
<span class="py-2 mb-0 text-body-secondary"@DateTime.Now.Year @CopyrightName</span>
9+
@if (SupportConfiguration.Value.ShowInFooter)
10+
{
11+
<div class="pb-2" style="display:flex;justify-content:center">
12+
<LinkDotNet.Blog.Web.Features.SupportMe.Components.DonationSection />
13+
</div>
14+
}
715
</footer>
816
@code {
917
private string CopyrightName => AppConfiguration.Value.IsAboutMeEnabled
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
@using LinkDotNet.Blog.Domain
1+
@using LinkDotNet.Blog.Domain
2+
@using LinkDotNet.Blog.Web.Features.SupportMe.Components
23
@inject IOptions<Introduction> Introduction
34
@inject IOptions<Social> Social
5+
@inject IOptions<SupportMeConfiguration> SupportConfiguration
46

57
<div style="@IntroductionStyle" class="@IntroductionClass">
68
<div class="introduction-container">
@@ -9,6 +11,10 @@
911
<div class="profile-text d-flex flex-column">
1012
<div>@MarkdownConverter.ToMarkupString(Introduction.Value.Description)</div>
1113
<SocialAccounts Social="@Social.Value"></SocialAccounts>
14+
@if (SupportConfiguration.Value.ShowUnderIntroduction)
15+
{
16+
<LinkDotNet.Blog.Web.Features.SupportMe.Components.DonationSection />
17+
}
1218
</div>
1319
</div>
1420
</div>
@@ -18,6 +24,6 @@
1824
: string.Empty;
1925

2026
private string IntroductionStyle => !string.IsNullOrEmpty(Introduction.Value.BackgroundUrl)
21-
? $"--profile-background: url({Introduction.Value.BackgroundUrl})"
22-
: string.Empty;
27+
? $"--profile-background: url({Introduction.Value.BackgroundUrl})"
28+
: string.Empty;
2329
}

src/LinkDotNet.Blog.Web/Features/Home/Components/NavMenu.razor

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
@inject IOptions<ApplicationConfiguration> Configuration
1+
@using LinkDotNet.Blog.Web.Features.SupportMe.Components
2+
@inject IOptions<ApplicationConfiguration> Configuration
3+
@inject IOptions<SupportMeConfiguration> SupportConfiguration
24
@inject NavigationManager NavigationManager
35
@implements IDisposable
46

@@ -26,24 +28,35 @@
2628
@if (Configuration.Value.IsAboutMeEnabled)
2729
{
2830
<li class="nav-item">
29-
<a class="nav-link" href="AboutMe"><i class="profile"></i> About
30-
me</a></li>
31+
<a class="nav-link" href="AboutMe">
32+
<i class="profile"></i> About me
33+
</a>
34+
</li>
35+
}
36+
37+
@if (SupportConfiguration.Value.ShowSupportMePage)
38+
{
39+
<li class="nav-item">
40+
<a class="nav-link" href="SupportMe">
41+
<i class="price-tags"></i> Support me
42+
</a>
43+
</li>
3144
}
3245

3346
<li class="nav-item dropdown">
34-
<a class="nav-link dropdown-toggle" href="#" id="rssDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false" aria-label="RSS Selector">
35-
<i class="rss2"></i> RSS
36-
</a>
37-
<ul class="dropdown-menu" aria-labelledby="rssDropdown">
38-
<li><a class="dropdown-item" href="/feed.rss" aria-label="RSS with All Posts">All Posts (Summary)</a></li>
39-
<li><a class="dropdown-item" href="/feed.rss?withContent=true" aria-label="RSS with Full Content">Most Recent Posts (Full Content)</a></li>
40-
</ul>
47+
<a class="nav-link dropdown-toggle" href="#" id="rssDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false" aria-label="RSS Selector">
48+
<i class="rss2"></i> RSS
49+
</a>
50+
<ul class="dropdown-menu" aria-labelledby="rssDropdown">
51+
<li><a class="dropdown-item" href="/feed.rss" aria-label="RSS with All Posts">All Posts (Summary)</a></li>
52+
<li><a class="dropdown-item" href="/feed.rss?withContent=true" aria-label="RSS with Full Content">Most Recent Posts (Full Content)</a></li>
53+
</ul>
4154
</li>
4255

4356
<AccessControl CurrentUri="@currentUri"></AccessControl>
4457
<li><ThemeToggler Class="nav-link"></ThemeToggler></li>
4558
<li class="d-flex">
46-
<SearchInput SearchEntered="NavigateToSearchPage"></SearchInput>
59+
<SearchInput SearchEntered="NavigateToSearchPage"></SearchInput>
4760
</li>
4861
</ul>
4962
</div>

src/LinkDotNet.Blog.Web/Features/ShowBlogPost/Components/DonationSection.razor

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/LinkDotNet.Blog.Web/Features/ShowBlogPost/ShowBlogPostPage.razor

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@page "/blogPost/{blogPostId}/{slug?}"
22
@using System.Text
3+
@using LinkDotNet.Blog.Web.Features.SupportMe.Components
34
@using Markdig
45
@using LinkDotNet.Blog.Domain
56
@using LinkDotNet.Blog.Infrastructure.Persistence
@@ -12,6 +13,7 @@
1213
@inject IUserRecordService UserRecordService
1314
@inject IOptions<ApplicationConfiguration> AppConfiguration
1415
@inject IOptions<ProfileInformation> ProfileInformation
16+
@inject IOptions<SupportMeConfiguration> SupportConfiguration
1517

1618
@if (isLoading)
1719
{
@@ -81,8 +83,11 @@ else if (BlogPost is not null)
8183
<Like BlogPost="@BlogPost" OnBlogPostLiked="@UpdateLikes"></Like>
8284
<ShareBlogPost></ShareBlogPost>
8385
</div>
84-
<DonationSection></DonationSection>
85-
@if (AppConfiguration.Value.ShowSimilarPosts)
86+
@if (SupportConfiguration.Value.ShowUnderBlogPost)
87+
{
88+
<LinkDotNet.Blog.Web.Features.SupportMe.Components.DonationSection />
89+
}
90+
@if (AppConfiguration.Value.ShowSimilarPosts)
8691
{
8792
<SimilarBlogPostSection BlogPost="@BlogPost" />
8893
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
@inject IOptions<SupportMeConfiguration> SupportConfiguration
2+
<div class="d-flex flex-column flex-md-row gap-2 justify-content-start align-items-center">
3+
@if (SupportConfiguration.Value.IsKofiEnabled)
4+
{
5+
<div class="mt-2">
6+
<Kofi KofiToken="@SupportConfiguration.Value.KofiToken"></Kofi>
7+
</div>
8+
}
9+
10+
@if (SupportConfiguration.Value.IsGithubSponsorAvailable)
11+
{
12+
<div class="mt-2">
13+
<GithubSponsor Name="@SupportConfiguration.Value.GithubSponsorName"></GithubSponsor>
14+
</div>
15+
}
16+
17+
@if (SupportConfiguration.Value.IsPatreonEnabled)
18+
{
19+
<div class="mt-2">
20+
<Patreon PatreonName="@SupportConfiguration.Value.PatreonName"></Patreon>
21+
</div>
22+
}
23+
</div>

src/LinkDotNet.Blog.Web/Features/ShowBlogPost/Components/GithubSponsor.razor renamed to src/LinkDotNet.Blog.Web/Features/SupportMe/Components/GithubSponsor.razor

File renamed without changes.

src/LinkDotNet.Blog.Web/Features/ShowBlogPost/Components/Kofi.razor renamed to src/LinkDotNet.Blog.Web/Features/SupportMe/Components/Kofi.razor

File renamed without changes.

0 commit comments

Comments
 (0)