Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: dev containers dependabot and accessibility fixes #69

Merged
merged 5 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@ updates:
directory: "/"
schedule:
interval: "weekly"

# Maintain dependencies for Dev Containers
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: "weekly"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ _ReSharper*/
# TeamCity is a build add-in
_TeamCity*

# Generic coverage output directory
coverage/

# DotCover is a Code Coverage Tool
Expand Down
2 changes: 1 addition & 1 deletion src/Client/Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<Title>Microsoft Graveyard</Title>
<Description>🪦 The virtual graveyard for all products killed by Microsoft</Description>
<Authors>VictorFrye</Authors>
<RepositoryUrl>https://github.com/victorfrye/microsoft-graveyard</RepositoryUrl>
<RepositoryUrl>https://github.com/victorfrye/microsoftgraveyard</RepositoryUrl>

<AssemblyName>VictorFrye.MicrosoftGraveyard.Client</AssemblyName>
<RootNamespace>VictorFrye.MicrosoftGraveyard.Client</RootNamespace>
Expand Down
11 changes: 7 additions & 4 deletions src/Client/Components/Content/Graveyard.razor
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@inject TimeProvider TimeProvider

<ul class="d-flex flex-wrap justify-content-center p-0">
@foreach (var corpse in Corpses)
{
Expand All @@ -8,25 +10,26 @@
@code {
[Parameter]
public IList<Corpse> Corpses { get; init; } = [];
private static DateOnly _today = DateOnly.FromDateTime(TimeProvider.System.GetLocalNow().DateTime);

private RenderFragment<Corpse> GraveTemplate = (corpse) =>
@<li class='col-8 col-md-5 col-xl-3 d-flex my-3 mx-md-4 rounded text-light'>
<div class="d-flex flex-column p-1">
@if (corpse.IsDead())
@if (corpse.IsDead(_today))
{
<img src="/images/headstone.svg" class="img-grave m-2" />
<img src="/images/headstone.svg" class="img-grave m-2" alt="headstone" />
<p class="text-life-dates text-center">@corpse.GetLifeDates()</p>
}
else
{
<img src="/images/coffin.svg" class="img-grave m-2" />
<img src="/images/coffin.svg" class="img-grave m-2" alt="coffin" />
<p class="text-life-dates text-center">@corpse.GetExpectedDeathDate()</p>
}
</div>

<div class="d-block p-1">
<h2><a href=@corpse.Link target="_blank">@corpse.GetFullName()</a></h2>
<p>@corpse.GetObituary()</p>
<p>@corpse.GetObituary(_today)</p>
</div>
</li>;
}
4 changes: 2 additions & 2 deletions src/Client/Components/Content/SocialButtons.razor
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<ul class="d-flex flex-row flex-nowrap gap-3 p-0 pb-3">
<div class="d-flex flex-row flex-nowrap gap-3 p-0 pb-3">
@foreach (var social in Socials)
{
@ButtonTemplate(social)
}
</ul>
</div>

@code {
[Parameter]
Expand Down
17 changes: 8 additions & 9 deletions src/Client/Models/Corpse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,34 @@ public class Corpse(string name, string? qualifier, DateOnly? birthDate, DateOnl
public string Description { get; init; } = description;
public string Link { get; init; } = link;

private readonly DateOnly _now = DateOnly.FromDateTime(DateTime.Now);

public bool IsDead() => DeathDate <= _now;
public bool IsDead(DateOnly today) => DeathDate <= today;

public string GetExpectedDeathDate() => $"{DeathDate:MMMM yyyy}";

public string GetLifeDates() => BirthDate is null ? $"{DeathDate:yyyy}" : $"{BirthDate.Value:yyyy} - {DeathDate:yyyy}";

public string GetFullName() => Qualifier is null ? Name : $"{Name} ({Qualifier})";

public string GetObituary()
public string GetObituary(DateOnly today)
{
var obituary = new StringBuilder();
var isDead = IsDead(today);

if (IsDead())
if (isDead)
{
var (age, period) = GetAge(DeathDate, _now);
var (age, period) = GetAge(DeathDate, today);
var message = age == 0 ? "today" : $"{age} {period} ago";
obituary.Append($"Killed by Microsoft {message}, ");
}
else
{
var (age, period) = GetAge(_now, DeathDate);
var (age, period) = GetAge(today, DeathDate);
obituary.Append($"To be killed by Microsoft in {age} {period}, ");
}

obituary.Append($"{Name} {(IsDead() ? "was" : "is")} {Description}.");
obituary.Append($"{Name} {(isDead ? "was" : "is")} {Description}.");

if (IsDead() && BirthDate is not null)
if (isDead && BirthDate is not null)
{
var (age, period) = GetAge(BirthDate.Value, DeathDate);
obituary.Append($" It was {age} {period} old.");
Expand Down
4 changes: 3 additions & 1 deletion src/Client/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");

builder.Services.AddHttpClient();
builder.Services
.AddHttpClient()
.AddSingleton(TimeProvider.System);

await builder.Build().RunAsync();
4 changes: 4 additions & 0 deletions src/Client/wwwroot/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
User-agent: *
Allow: /

Sitemap: https://microsoftgraveyard.com/sitemap.xml
6 changes: 6 additions & 0 deletions src/Client/wwwroot/sitemap.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://microsoftgraveyard.com/</loc>
</url>
</urlset>
26 changes: 13 additions & 13 deletions tests/Unit/Models/CorpseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ namespace VictorFrye.MicrosoftGraveyard.Tests.Unit.Models;

public class CorpseTests
{
private static readonly DateOnly Now = DateOnly.FromDateTime(DateTime.Now);
private static readonly DateOnly GivenDate = new(2024, 1, 22);

[Fact]
public void ShouldReturnIsAlive()
{
// Arrange
var dateToBeKilled = Now.AddYears(1);
var dateToBeKilled = GivenDate.AddYears(1);

// Act
var actual = NewMockCorpse(deathDate: dateToBeKilled).IsDead();
var actual = NewMockCorpse(deathDate: dateToBeKilled).IsDead(GivenDate);

// Assert
Assert.False(actual);
Expand All @@ -25,10 +25,10 @@ public void ShouldReturnIsAlive()
public void ShouldReturnIsDead()
{
// Arrange
var dateToBeKilled = Now.AddYears(-1);
var dateToBeKilled = GivenDate.AddYears(-1);

// Act
var actual = NewMockCorpse(deathDate: dateToBeKilled).IsDead();
var actual = NewMockCorpse(deathDate: dateToBeKilled).IsDead(GivenDate);

// Assert
Assert.True(actual);
Expand Down Expand Up @@ -106,7 +106,7 @@ public void ShouldReturnObituaryWhenKilledTodayAndBirthKnown()
var expected = "Killed by Microsoft today, Skype was a video calling service. It was 1 year old.";

// Act
var actual = NewMockCorpse(name: "Skype", birthDate: Now.AddYears(-1), deathDate: Now, description: "a video calling service").GetObituary();
var actual = NewMockCorpse(name: "Skype", birthDate: GivenDate.AddYears(-1), deathDate: GivenDate, description: "a video calling service").GetObituary(GivenDate);

// Assert
Assert.Equal(expected, actual);
Expand All @@ -119,7 +119,7 @@ public void ShouldReturnObituaryWhenKilledYesterdayAndBirthUnknown()
var expected = "Killed by Microsoft 1 day ago, Skype was a video calling service.";

// Act
var actual = NewMockCorpse(name: "Skype", birthDate: null, deathDate: Now.AddDays(-1), description: "a video calling service").GetObituary();
var actual = NewMockCorpse(name: "Skype", birthDate: null, deathDate: GivenDate.AddDays(-1), description: "a video calling service").GetObituary(GivenDate);

// Assert
Assert.Equal(expected, actual);
Expand All @@ -132,7 +132,7 @@ public void ShouldReturnObituaryWhenKilledTwoDaysAgoAndBirthFourMonthsAgo()
var expected = "Killed by Microsoft 2 days ago, Skype was a video calling service. It was 4 months old.";

// Act
var actual = NewMockCorpse(name: "Skype", birthDate: Now.AddMonths(-4), deathDate: Now.AddDays(-2), description: "a video calling service").GetObituary();
var actual = NewMockCorpse(name: "Skype", birthDate: GivenDate.AddMonths(-4), deathDate: GivenDate.AddDays(-2), description: "a video calling service").GetObituary(GivenDate);

// Assert
Assert.Equal(expected, actual);
Expand All @@ -145,7 +145,7 @@ public void ShouldReturnObituaryWhenKilledLastMonthAndTwoDaysAgoAndBornLastDecad
var expected = "Killed by Microsoft 1 month ago, Skype was a video calling service. It was 9 years old.";

// Act
var actual = NewMockCorpse(name: "Skype", birthDate: Now.AddYears(-10), deathDate: Now.AddMonths(-1).AddDays(-2), description: "a video calling service").GetObituary();
var actual = NewMockCorpse(name: "Skype", birthDate: GivenDate.AddYears(-10), deathDate: GivenDate.AddMonths(-1).AddDays(-2), description: "a video calling service").GetObituary(GivenDate);

// Assert
Assert.Equal(expected, actual);
Expand All @@ -158,7 +158,7 @@ public void ShouldReturnObituaryWhenToBeKilledNextYear()
var expected = "To be killed by Microsoft in 1 year, Skype is a video calling service.";

// Act
var actual = NewMockCorpse(name: "Skype", birthDate: Now, deathDate: Now.AddYears(1), description: "a video calling service").GetObituary();
var actual = NewMockCorpse(name: "Skype", birthDate: GivenDate, deathDate: GivenDate.AddYears(1), description: "a video calling service").GetObituary(GivenDate);

// Assert
Assert.Equal(expected, actual);
Expand All @@ -171,7 +171,7 @@ public void ShouldReturnObituaryWhenToBeKilledNextMonth()
var expected = "To be killed by Microsoft in 1 month, Skype is a video calling service.";

// Act
var actual = NewMockCorpse(name: "Skype", birthDate: Now, deathDate: Now.AddMonths(1), description: "a video calling service").GetObituary();
var actual = NewMockCorpse(name: "Skype", birthDate: GivenDate, deathDate: GivenDate.AddMonths(1), description: "a video calling service").GetObituary(GivenDate);

// Assert
Assert.Equal(expected, actual);
Expand All @@ -184,7 +184,7 @@ public void ShouldReturnObituaryWhenToBeKilledInTwoMonthsMinusADay()
var expected = "To be killed by Microsoft in 2 months, Skype is a video calling service.";

// Act
var actual = NewMockCorpse(name: "Skype", birthDate: Now, deathDate: Now.AddMonths(2), description: "a video calling service").GetObituary();
var actual = NewMockCorpse(name: "Skype", birthDate: GivenDate, deathDate: GivenDate.AddMonths(2), description: "a video calling service").GetObituary(GivenDate);

// Assert
Assert.Equal(expected, actual);
Expand All @@ -202,7 +202,7 @@ private static Corpse NewMockCorpse(
name,
qualifier,
birthDate,
deathDate ?? Now,
deathDate ?? GivenDate,
description,
link);
}
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.TimeProvider.Testing" Version="8.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />

<PackageReference Include="bunit" Version="1.26.64" />
Expand Down