Skip to content

Commit 64d8dc6

Browse files
committed
Added entries for profile information
1 parent 17fad42 commit 64d8dc6

File tree

10 files changed

+119
-51
lines changed

10 files changed

+119
-51
lines changed

LinkDotNet.Blog.UnitTests/Web/AppConfigurationFactoryTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ public void ShouldMapFromAppConfiguration()
2323
{ "Introduction:Description", "desc" },
2424
{ "BlogPostsPerPage", "5" },
2525
{ "IsAboutMeEnabled", "true" },
26+
{ "AboutMeProfileInformation:Name", "Steven" },
27+
{ "AboutMeProfileInformation:Heading", "Dev" },
28+
{ "AboutMeProfileInformation:ProfilePictureUrl", "Url" },
2629
};
2730
var configuration = new ConfigurationBuilder()
2831
.AddInMemoryCollection(inMemorySettings)
@@ -42,6 +45,9 @@ public void ShouldMapFromAppConfiguration()
4245
appConfiguration.Introduction.Description.Should().Be("desc");
4346
appConfiguration.BlogPostsPerPage.Should().Be(5);
4447
appConfiguration.IsAboutMeEnabled.Should().BeTrue();
48+
appConfiguration.ProfileInformation.Name.Should().Be("Steven");
49+
appConfiguration.ProfileInformation.Heading.Should().Be("Dev");
50+
appConfiguration.ProfileInformation.ProfilePictureUrl.Should().Be("Url");
4551
}
4652

4753
[Fact]
@@ -53,6 +59,7 @@ public void ShouldSetGithubLinkedAccountAccordingToValueSet()
5359
{ "Introduction:ProfilePictureUrl", "anotherurl" },
5460
{ "Introduction:Description", "desc" },
5561
{ "BlogPostsPerPage", "2" },
62+
{ "IsAboutMeEnabled", "false" },
5663
};
5764
var configuration = new ConfigurationBuilder()
5865
.AddInMemoryCollection(inMemorySettings)

LinkDotNet.Blog.Web/AppConfiguration.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ public record AppConfiguration
2222

2323
public int BlogPostsPerPage { get; init; }
2424

25-
public bool IsAboutMeEnabled { get; set; }
25+
public bool IsAboutMeEnabled { get; init; }
26+
27+
public ProfileInformation ProfileInformation { get; set; }
2628
}
2729
}

LinkDotNet.Blog.Web/AppConfigurationFactory.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ public static AppConfiguration Create(IConfiguration config)
1818
BlogPostsPerPage = int.Parse(config["BlogPostsPerPage"]),
1919
IsAboutMeEnabled = bool.Parse(config["IsAboutMeEnabled"]),
2020
};
21+
22+
if (configuration.IsAboutMeEnabled)
23+
{
24+
configuration.ProfileInformation =
25+
config.GetSection("AboutMeProfileInformation").Get<ProfileInformation>();
26+
}
27+
2128
return configuration;
2229
}
2330
}

LinkDotNet.Blog.Web/Pages/AboutMe.razor

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,23 @@
44
@inject IHttpContextAccessor httpContextAccessor
55
/* TODO: Meta Tags About Me - [Name here] */
66

7-
<div class="page">
8-
<div class="container">
9-
<div class="row">
10-
<div class="col-lg-3 col-md-4">
11-
<Profile ProfileImageUrl="@appConfiguration.Introduction.ProfilePictureUrl"
12-
IsAuthenticated="@httpContextAccessor.HttpContext.User.Identity.IsAuthenticated"/>
13-
</div>
14-
<div class="col-lg-9 col-md-8 tab-container">
15-
<div class="row">
16-
<em>Stuff</em>
7+
@if (appConfiguration.IsAboutMeEnabled)
8+
{
9+
<div class="page">
10+
<div class="container">
11+
<div class="row">
12+
<div class="col-lg-3 col-md-4">
13+
<Profile ProfileInformation="@appConfiguration.ProfileInformation"
14+
IsAuthenticated="@httpContextAccessor.HttpContext.User.Identity.IsAuthenticated"
15+
ProfileInformationEntries=""
16+
ProfileInformationCollectionChanged=""/>
17+
</div>
18+
<div class="col-lg-9 col-md-8 tab-container">
19+
<div class="row">
20+
<em>Stuff</em>
21+
</div>
1722
</div>
1823
</div>
1924
</div>
2025
</div>
21-
</div>
26+
}

LinkDotNet.Blog.Web/Shared/AddProfileShortItem.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<li><input type="text" @bind-value="@key" />:<input type="text" @bind-value="@value"/>
1+
<li><input type="text" @bind-value="@key" placeholder="supports markdown"/>:<input type="text" @bind-value="@value" placeholder="supports markdown"/>
22
<button type="button" class="btn btn-default" aria-label="Add Item" @onclick="@AddItemAsync">
33
<i class="far fa-plus-square" aria-hidden="true"></i>
44
</button>
Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
1-
@inherits MarkdownComponentBase
1+
@using LinkDotNet.Domain
2+
@inherits MarkdownComponentBase
23
<div class="profile">
34
<div class="profile-name">
4-
<span>Steven Giesel</span>
5+
<span>@ProfileInformation.Name</span>
56
<br/>
6-
<span>Software Engineer</span>
7+
<span>@ProfileInformation.Heading</span>
78
</div>
89
<div class="profile-image">
9-
<img src="@ProfileImageUrl" alt="Profile Picture" />
10+
<img src="@ProfileInformation.ProfilePictureUrl" alt="Profile Picture" />
1011
</div>
1112
<ul class="profile-keypoints">
12-
@foreach (var (key, value) in cv)
13+
@foreach (var entry in ProfileInformationEntries)
1314
{
14-
<li><bold>@RenderMarkupString(key)</bold>: @RenderMarkupString(value)
15+
<li>
1516
@if (IsAuthenticated)
1617
{
17-
<button type="button" class="btn btn-default" aria-label="Delete Item" @onclick="() => ShowDeleteDialog(key)">
18+
<button type="button" class="btn btn-default" aria-label="Delete Item" @onclick="() =>
19+
ShowDeleteDialog(entry.Key)">
1820
<i class="fas fa-trash-alt" aria-hidden="true"></i>
1921
</button>
2022
}
23+
<bold>@RenderMarkupString(entry.Key)</bold>: @RenderMarkupString(entry.Value)
2124
</li>
2225
}
2326
@if (IsAuthenticated)
@@ -32,37 +35,43 @@ OnYesPressed="DeleteItem"></ConfirmDialog>
3235

3336
@code {
3437
[Parameter]
35-
public string ProfileImageUrl { get; set; }
38+
public ProfileInformation ProfileInformation { get; set; }
3639

3740
[Parameter]
3841
public bool IsAuthenticated { get; set; }
3942

43+
[Parameter]
44+
public EventCallback<IList<ProfileInformationEntry>> ProfileInformationCollectionChanged { get; set; }
45+
46+
[Parameter]
47+
public IList<ProfileInformationEntry> ProfileInformationEntries { get; set; } = new List<ProfileInformationEntry>();
48+
4049
private ConfirmDialog Dialog { get; set; }
4150

4251
private string currentDeleteKey;
4352

44-
private readonly Dictionary<string, string> cv = new()
45-
{
46-
{"<i class=\"fas fa-birthday-cake\"></i> Birthday", "17.05.1991"},
47-
{"E-Mail", "[[email protected]](mailto:[email protected])"},
48-
{"Telephone", "+1234567890"},
49-
{"LinkedIn", "[Steven Giesel](https://www.linkedin.com/in/steven.giesel)"},
50-
{"Github", "<i class=\"fab fa-github \"></i>[linkdotnet](https://github.com/linkdotnet)"},
51-
};
52-
5353
private void ShowDeleteDialog(string key)
5454
{
5555
currentDeleteKey = key;
5656
Dialog.Open();
5757
}
5858

59-
private void DeleteItem()
59+
private async Task DeleteItem()
6060
{
61-
cv.Remove(currentDeleteKey);
61+
var entryToDelete = ProfileInformationEntries.Single(p => p.Key == currentDeleteKey);
62+
ProfileInformationEntries.Remove(entryToDelete);
63+
await ProfileInformationCollectionChanged.InvokeAsync(ProfileInformationEntries);
6264
}
6365

64-
private void AddValue(KeyValuePair<string, string> toAdd)
66+
private async Task AddValue(KeyValuePair<string, string> toAdd)
6567
{
66-
cv.Add(toAdd.Key, toAdd.Value);
68+
var newEntry = new ProfileInformationEntry
69+
{
70+
Key = toAdd.Key,
71+
Value = toAdd.Value,
72+
};
73+
74+
ProfileInformationEntries.Add(newEntry);
75+
await ProfileInformationCollectionChanged.InvokeAsync(ProfileInformationEntries);
6776
}
6877
}

LinkDotNet.Blog.Web/appsettings.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,10 @@
2323
"ClientSecret": ""
2424
},
2525
"BlogPostsPerPage": 10,
26-
"IsAboutMeEnabled": true
26+
"IsAboutMeEnabled": true,
27+
"AboutMeProfileInformation": {
28+
"Name": "Steven Giesel",
29+
"Heading": "Software Engineer",
30+
"ProfilePictureUrl": "assets/profile-picture.webp"
31+
}
2732
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace LinkDotNet.Domain
2+
{
3+
public record ProfileInformation
4+
{
5+
public string Name { get; init; }
6+
7+
public string Heading { get; init; }
8+
9+
public string ProfilePictureUrl { get; init; }
10+
}
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace LinkDotNet.Domain
2+
{
3+
public class ProfileInformationEntry
4+
{
5+
public string Id { get; set; }
6+
7+
public string Key { get; set; }
8+
9+
public string Value { get; set; }
10+
}
11+
}

Readme.md

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,37 @@ The appsettings.json file has a lot of options to customize the content of the b
3535
"ClientSecret": ""
3636
},
3737
"BlogPostsPerPage": 10,
38+
"IsAboutMeEnabled": true,
39+
"AboutMeProfileInformation": {
40+
"Name": "Steven Giesel",
41+
"Heading": "Software Engineer",
42+
"ProfilePictureUrl": "assets/profile-picture.webp"
43+
}
3844
}
3945

4046
```
4147

42-
| Property | Type | Description |
43-
| ------------------ | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
44-
| BlogName | string | Name of your blog. Is used in the navbar and is used as the title of the page. |
45-
| GithubAccountUrl | string | Url to your github account. If not set the navigation link is not shown |
46-
| LinkedInAccountUrl | string | Url to your LinkedIn account. If not set the navigation link is not shown |
47-
| Introduction | | Is used for the introduction part of the blog |
48-
| Description | MarkdownString | Small introduction text for yourself. This is also used for `<meta name="description">` tag. For this the markup will be converted to plain text. |
49-
| BackgroundUrl | string | Url or path to the background image |
50-
| ProfilePictureUrl | string | Url or path to your profile picture |
51-
| ConnectionString | string | Is used for connection to a database. Not used when `InMemoryStorageProvider` is used |
52-
| DatabaseName | string | Name of the database. Only used with `RavenDbStorageProvider` |
53-
| Auth0 | | Configuration for setting up Auth0 |
54-
| Domain | string | See more details here: https://manage.auth0.com/dashboard/ |
55-
| ClientId | string | See more details here: https://manage.auth0.com/dashboard/ |
56-
| ClientSecret | string | See more details here: https://manage.auth0.com/dashboard/ |
57-
| BlogPostsPerPage | int | Gives the amount of blog posts loaded and display per page. For more the user has to use the navigation |
48+
| Property | Type | Description |
49+
| ------------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
50+
| BlogName | string | Name of your blog. Is used in the navbar and is used as the title of the page. |
51+
| GithubAccountUrl | string | Url to your github account. If not set the navigation link is not shown |
52+
| LinkedInAccountUrl | string | Url to your LinkedIn account. If not set the navigation link is not shown |
53+
| Introduction | | Is used for the introduction part of the blog |
54+
| Description | MarkdownString | Small introduction text for yourself. This is also used for `<meta name="description">` tag. For this the markup will be converted to plain text. |
55+
| BackgroundUrl | string | Url or path to the background image |
56+
| ProfilePictureUrl | string | Url or path to your profile picture |
57+
| ConnectionString | string | Is used for connection to a database. Not used when `InMemoryStorageProvider` is used |
58+
| DatabaseName | string | Name of the database. Only used with `RavenDbStorageProvider` |
59+
| Auth0 | | Configuration for setting up Auth0 |
60+
| Domain | string | See more details here: https://manage.auth0.com/dashboard/ |
61+
| ClientId | string | See more details here: https://manage.auth0.com/dashboard/ |
62+
| ClientSecret | string | See more details here: https://manage.auth0.com/dashboard/ |
63+
| BlogPostsPerPage | int | Gives the amount of blog posts loaded and display per page. For more the user has to use the navigation |
64+
| IsAboutMeEnabled | bool | If true, enalbes the "About Me" page |
65+
| AboutMeProfileInformation | node | If `IsAboutMeEnabled` is set to `false` this node can be left empty. |
66+
| Name | string | Name, which is displayed on top of the profile card |
67+
| Heading | string | Displayed under the name. For example job title |
68+
| ProfilePictureUrl | string | Displayed profile picture |
5869

5970
The usage might shift directly into the extension methods, where they are used.
6071

0 commit comments

Comments
 (0)