Skip to content

Commit

Permalink
Add release date support
Browse files Browse the repository at this point in the history
  • Loading branch information
kMutagene committed Feb 15, 2024
1 parent 5d068b8 commit 72df6a9
Show file tree
Hide file tree
Showing 10 changed files with 174 additions and 14 deletions.
5 changes: 3 additions & 2 deletions src/PackageRegistryService/DataInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ public static void SeedData(ValidationPackageDb context)
.Select(i =>
new ValidationPackage
{
Name = i.FileName,
Name = i.Metadata.Name,
Description = i.Metadata.Description,
MajorVersion = i.Metadata.MajorVersion,
MinorVersion = i.Metadata.MinorVersion,
PatchVersion = i.Metadata.PatchVersion,
PackageContent = File.ReadAllBytes($"StagingArea/{i.FileName}/{i.FileName}@{i.Metadata.MajorVersion}.{i.Metadata.MinorVersion}.{i.Metadata.PatchVersion}.fsx"),
PackageContent = File.ReadAllBytes($"StagingArea/{i.Metadata.Name}/{i.FileName}"),
ReleaseDate = new(i.LastUpdated.Year, i.LastUpdated.Month, i.LastUpdated.Day),
Tags = i.Metadata.Tags,
ReleaseNotes = i.Metadata.ReleaseNotes,
Authors = i.Metadata.Authors
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace PackageRegistryService.Migrations
{
/// <inheritdoc />
public partial class AddReleaseDate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<DateOnly>(
name: "ReleaseDate",
table: "ValidationPackages",
type: "date",
nullable: false,
defaultValue: new DateOnly(1, 1, 1));
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ReleaseDate",
table: "ValidationPackages");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
Expand Down Expand Up @@ -43,6 +44,9 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.IsRequired()
.HasColumnType("bytea");
b.Property<DateOnly>("ReleaseDate")
.HasColumnType("date");
b.Property<string>("ReleaseNotes")
.HasColumnType("text");
Expand Down
4 changes: 4 additions & 0 deletions src/PackageRegistryService/Models/ValidationPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ public class ValidationPackage
/// <example>aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1kUXc0dzlXZ1hjUQ==</example>
public required byte[] PackageContent { get; set; }
/// <summary>
///
/// </summary>
public required DateOnly ReleaseDate { get; set; }
/// <summary>
///
/// </summary>
public string[]? Tags { get; set; }
Expand Down
7 changes: 4 additions & 3 deletions src/PackageRegistryService/Pages/Components/Layout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ public static string Render(string activeNavbarItem, string title, string conten
return $@"<!DOCTYPE html>
<html>
<head>
<meta charset=""utf-8"" />
<meta name=""viewport"" content=""width=device-width, initial-scale=1"" />
<link rel=""stylesheet"" href=""/css/pico.min.css"">
<meta charset=""utf-8"">
<meta name=""viewport"" content=""width=device-width, initial-scale=1"">
<meta name=""color-scheme"" content=""light dark"" />
<link rel=""stylesheet"" href=""css/pico.cyan.min.css"" />
<title>{title}</title>
</head>
<body>
Expand Down
14 changes: 9 additions & 5 deletions src/PackageRegistryService/Pages/Components/PackageSummary.cs
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
namespace PackageRegistryService.Pages.Components
{
public record PackageSummary(string Name, string Description, string [] Tags, string LatestVersion)
public record PackageSummary(string Name, string Description, string [] Tags, string LatestVersion, DateOnly ReleaseDate)
{
public static string Render(PackageSummary summary)
{
return $@"<tr>
<th scope=""row""><a href=""/package/{summary.Name}"">{summary.Name}</a></th>
<td>{summary.Description}</td>
<td>{summary.LatestVersion}</td>
<td>{string.Join("", summary.Tags.Select(t => $"<b>{t} </b>"))}</td>
<td><a href=""/package/{summary.Name}/{summary.LatestVersion}"">{summary.LatestVersion}</a></td>
<td>{summary.ReleaseDate}</td>
<td>{string.Join("; ", summary.Tags.Select(t => $@"<a href=""/packages?tag={t}"">{t}</a>"))}</td>
</tr>";
}

public static string RenderList(IEnumerable<PackageSummary> summaries)
{
var content = @$"<h1>All available validation packages</h1><br>#
var content = @$"<h1>All available validation packages</h1><br>
<div class=""overflow-auto"">
<table class=""striped"">
<thead>
<tr>
<th scope=""col"">Name</th>
<th scope=""col"">Description</th>
<th scope=""col"">Latest version</th>
<th scope=""col"">Release date</th>
<th scope=""col"">Tags</th>
</tr>
</thead>
{string.Join(System.Environment.NewLine, summaries.Select(PackageSummary.Render))}
</table>";
</table>
</div>";
return content;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/PackageRegistryService/Pages/Packages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public static async Task<ContentHttpResult> Render(ValidationPackageDb database)
Name: group.Key,
Tags: latestPackage.Tags,
Description: latestPackage.Description,
ReleaseDate: latestPackage.ReleaseDate,
LatestVersion: latestPackage.GetSemanticVersionString()
);
}
Expand Down
4 changes: 4 additions & 0 deletions src/PackageRegistryService/wwwroot/css/pico.cyan.min.css

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions src/PackageRegistryService/wwwroot/css/pico.min.css

This file was deleted.

0 comments on commit 72df6a9

Please sign in to comment.