Skip to content

Commit 2220e98

Browse files
committed
feat: Add build information
1 parent 3d797e3 commit 2220e98

File tree

10 files changed

+64
-3
lines changed

10 files changed

+64
-3
lines changed

Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
<PackageVersion Include="Markdig" Version="0.44.0" />
3232
<PackageVersion Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="10.0.0" />
3333
<PackageVersion Include="NCronJob" Version="4.7.0" />
34+
<PackageVersion Include="LinkDotNet.BuildInformation" Version="2.0.0" />
3435
<PackageVersion Include="ReverseMarkdown" Version="4.7.1" />
3536
<PackageVersion Include="System.ServiceModel.Syndication" Version="10.0.0" />
3637
<PackageVersion Include="NetEscapades.AspNetCore.SecurityHeaders" Version="1.3.0" />

MIGRATION.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
# Migration Guide
22
This document describes the changes that need to be made to migrate from one version of the blog to another.
33

4+
## 11.0 to 12.0
5+
`ShowBuildInformation` setting was added on the root level of the `appsettings.json` file. This setting controls whether build information (like build date) is shown in the `Footer` component.
6+
7+
```json
8+
{
9+
...
10+
"ShowBuildInformation": true
11+
}
12+
```
13+
414
## 9.0 to 11.0
515

616
A new config has been added `UseMultiAuthorMode` in `appsettings.json`. The default value of this config is `false`. If set to `true` then author name will be associated with blog posts at the time of creation.

docs/Setup/Configuration.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ The appsettings.json file has a lot of options to customize the content of the b
4848
},
4949
"ShowReadingIndicator": true,
5050
"SimlarBlogPosts": "true",
51+
"ShowBuildInformation": true,
5152
"SupportMe": {
5253
"KofiToken": "ABC123",
5354
"GithubSponsorName": "your-tag-here",
@@ -102,6 +103,7 @@ The appsettings.json file has a lot of options to customize the content of the b
102103
| [Disqus](./../Comments/Disqus.md) | node | Enables the comment section via disqus. If left empty the comment section will not be shown. |
103104
| ShowReadingIndicator | boolean | If set to `true` (default) a circle indicates the progress when a user reads a blog post (without comments). |
104105
| SimilarBlogPosts | boolean | If set to `true` (default) similar blog posts are shown at the end of a blog post. |
106+
| ShowBuildInformation | boolean | If set to `true` (default) the build information (target framework and build timestamp) is shown in the footer. |
105107
| [SupportMe](./../Donations/Readme.md) | node | Donation sections configuration. If left empty no donation sections will not be shown. |
106108
| [ImageStorageProvider](./../Media/Readme.md) | string | Declares the type of the image storage provider (currently only `Azure`). |
107109
| [ImageStorage](./../Media/Readme.md) | node | Configuration for the image storage provider. |

src/LinkDotNet.Blog.Web/ApplicationConfiguration.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,7 @@ public sealed record ApplicationConfiguration
2424

2525
public bool ShowSimilarPosts { get; init; }
2626

27+
public bool ShowBuildInformation { get; init; } = true;
28+
2729
public bool UseMultiAuthorMode { get; init; }
2830
}

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,19 @@
44
@inject IOptions<ProfileInformation> ProfileInformation
55
@inject IOptions<SupportMeConfiguration> SupportConfiguration
66

7-
<footer class="position-absolute bottom-0 w-100 text-center" style="height: 2.5rem;">
8-
<span class="py-2 mb-0 text-body-secondary"@DateTime.Now.Year @CopyrightName</span>
7+
<footer class="position-absolute bottom-0 w-100 text-center text-body-secondary" style="height: 2.5rem;">
8+
<span@DateTime.Now.Year @CopyrightName</span>
9+
@if (AppConfiguration.Value.ShowBuildInformation)
10+
{
11+
<p class="text-gray-300 mb-0">Made with ❤️, @BuildInformation.TargetFrameworkMoniker, and Blazor</p>
12+
<p class="text-gray-300">
13+
Built At: @(BuildInformation.BuildAt.ToString("dd-MM-yyyy HH:mm")) (UTC)
14+
</p>
15+
}
916
@if (SupportConfiguration.Value.ShowInFooter)
1017
{
1118
<div class="pb-2 d-flex justify-content-center">
12-
<DonationSection />
19+
<DonationSection/>
1320
</div>
1421
}
1522
</footer>

src/LinkDotNet.Blog.Web/LinkDotNet.Blog.Web.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<PackageReference Include="Blazored.Toast"/>
77
<PackageReference Include="Blazorise.Bootstrap5"/>
88
<PackageReference Include="Blazorise.Markdown"/>
9+
<PackageReference Include="LinkDotNet.BuildInformation"/>
910
<PackageReference Include="NCronJob"/>
1011
<PackageReference Include="Markdig"/>
1112
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect"/>

src/LinkDotNet.Blog.Web/appsettings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,6 @@
4747
},
4848
"ShowReadingIndicator": true,
4949
"ShowSimilarPosts": true,
50+
"ShowBuildInformation": true,
5051
"UseMultiAuthorMode": false
5152
}

tests/LinkDotNet.Blog.TestUtilities/ApplicationConfigurationBuilder.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class ApplicationConfigurationBuilder
1414
private bool isDisqusEnabled;
1515
private bool showReadingIndicator;
1616
private bool showSimilarPosts;
17+
private bool showBuildInformation = true;
1718
private string? blogBrandUrl;
1819
private bool useMultiAuthorMode;
1920

@@ -76,6 +77,12 @@ public ApplicationConfigurationBuilder WithShowSimilarPosts(bool showSimilarPost
7677
this.showSimilarPosts = showSimilarPosts;
7778
return this;
7879
}
80+
81+
public ApplicationConfigurationBuilder WithShowBuildInformation(bool showBuildInformation)
82+
{
83+
this.showBuildInformation = showBuildInformation;
84+
return this;
85+
}
7986

8087
public ApplicationConfigurationBuilder WithBlogBrandUrl(string? blogBrandUrl)
8188
{
@@ -103,6 +110,7 @@ public ApplicationConfiguration Build()
103110
IsDisqusEnabled = isDisqusEnabled,
104111
ShowReadingIndicator = showReadingIndicator,
105112
ShowSimilarPosts = showSimilarPosts,
113+
ShowBuildInformation = showBuildInformation,
106114
BlogBrandUrl = blogBrandUrl,
107115
UseMultiAuthorMode = useMultiAuthorMode,
108116
};

tests/LinkDotNet.Blog.UnitTests/Web/ApplicationConfigurationTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public void ShouldMapFromAppConfiguration()
3434
{ "Giscus:CategoryId", "generalid" },
3535
{ "Disqus:Shortname", "blog" },
3636
{ "ShowReadingIndicator", "true" },
37+
{ "ShowBuildInformation", "true" },
3738
{ "SupportMe:KofiToken", "ABC" },
3839
{ "SupportMe:PatreonName", "linkdotnet" },
3940
{ "SupportMe:GithubSponsorName", "linkdotnet" },
@@ -65,6 +66,7 @@ public void ShouldMapFromAppConfiguration()
6566
appConfiguration.BlogPostsPerPage.ShouldBe(5);
6667
appConfiguration.IsAboutMeEnabled.ShouldBeTrue();
6768
appConfiguration.ShowReadingIndicator.ShouldBeTrue();
69+
appConfiguration.ShowBuildInformation.ShouldBeTrue();
6870
appConfiguration.UseMultiAuthorMode.ShouldBeTrue();
6971

7072
var giscusConfiguration = new GiscusConfigurationBuilder().Build();

tests/LinkDotNet.Blog.UnitTests/Web/Features/Home/Components/FooterTests.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,31 @@ public void ShouldNotSetNameIfAboutMeIsNotEnabled()
3333

3434
cut.Find("span").TextContent.ShouldContain("©");
3535
}
36+
37+
[Fact]
38+
public void ShouldShowBuildInformationWhenEnabled()
39+
{
40+
var appConfig = Options.Create(new ApplicationConfigurationBuilder()
41+
.WithShowBuildInformation(true)
42+
.Build());
43+
Services.AddScoped(_ => appConfig);
44+
45+
var cut = Render<Footer>();
46+
47+
cut.Markup.ShouldContain("Built At:");
48+
cut.Markup.ShouldContain("Blazor");
49+
}
50+
51+
[Fact]
52+
public void ShouldNotShowBuildInformationWhenDisabled()
53+
{
54+
var appConfig = Options.Create(new ApplicationConfigurationBuilder()
55+
.WithShowBuildInformation(false)
56+
.Build());
57+
Services.AddScoped(_ => appConfig);
58+
59+
var cut = Render<Footer>();
60+
61+
cut.Markup.ShouldNotContain("Built At:");
62+
}
3663
}

0 commit comments

Comments
 (0)