Skip to content

Commit

Permalink
Add alt text to news page entries (#1108)
Browse files Browse the repository at this point in the history
- Allow providing alt text for header and body images
- Have the API send a relative path and let the frontend construct the
URL using the CDN url. Eliminates the need to configure the CDN url in
both the frontend and backend.
- Use query params for news paging instead of URL segments
  • Loading branch information
SapiensAnatis authored Oct 9, 2024
1 parent 1422698 commit fe92cca
Show file tree
Hide file tree
Showing 24 changed files with 2,924 additions and 131 deletions.
12 changes: 0 additions & 12 deletions DragaliaAPI/DragaliaAPI.Database/DragaliaAPI.Database.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.DataProtection.EntityFrameworkCore" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design">
<PrivateAssets>all</PrivateAssets>
Expand All @@ -14,14 +10,6 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" />
<PackageReference Include="Serilog" />
</ItemGroup>
Expand Down
19 changes: 13 additions & 6 deletions DragaliaAPI/DragaliaAPI.Database/Entities/DbNewsItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,22 @@ public class DbNewsItem
/// <summary>
/// Gets or sets a relative path to the summary header image.
/// </summary>
/// <remarks>
/// Will be combined with the configured CDN base address to deliver a fully qualified URL in the response.
/// </remarks>
public string? HeaderImagePath { get; set; }

/// <summary>
/// Gets or sets the alt text for the summary header image.
/// </summary>
public string? HeaderImageAltText { get; set; }

/// <summary>
/// Gets or sets a relative path to the body image.
/// </summary>
/// <remarks>
/// Will be combined with the configured CDN base address to deliver a fully qualified URL in the response.
/// </remarks>
public string? BodyImagePath { get; set; }

/// <summary>
/// Gets or sets the alt text for the body image.
/// </summary>
public string? BodyImageAltText { get; set; }
}

public class DbNewsItemConfiguration : IEntityTypeConfiguration<DbNewsItem>
Expand All @@ -60,7 +64,9 @@ public void Configure(EntityTypeBuilder<DbNewsItem> builder)
builder.Property(x => x.Headline).HasMaxLength(256);
builder.Property(x => x.Description).HasMaxLength(4096);
builder.Property(x => x.HeaderImagePath).HasMaxLength(512);
builder.Property(x => x.HeaderImageAltText).HasMaxLength(1024);
builder.Property(x => x.BodyImagePath).HasMaxLength(512);
builder.Property(x => x.BodyImageAltText).HasMaxLength(1024);

builder.HasData(
new DbNewsItem()
Expand All @@ -71,6 +77,7 @@ public void Configure(EntityTypeBuilder<DbNewsItem> builder)
Description =
"The below infographic shows the endeavour rewards available for the progressing the Mercurial Gauntlet.",
BodyImagePath = "/dawnshard/news/mg-endeavours.webp",
BodyImageAltText = "Mercurial Gauntlet rewards infographic",
Date = new DateTimeOffset(2024, 06, 02, 16, 07, 00, TimeSpan.FromHours(1)),
}
);
Expand Down
Loading

0 comments on commit fe92cca

Please sign in to comment.