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

Include status in export index #4

Merged
merged 1 commit into from
Jan 7, 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: 5 additions & 1 deletion src/Talo/Commands/Export.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ private async Task HandleAsync(List<string> types, string outDir, IConsole conso
foreach (var metadata in allMetadata)
{
var fileId = await CreateHtmlPage(pipeline, metadata, outputDir, configuration.Prefix);
createdFiles.Add(new CreatedHtmlPage(metadata.SequenceNumber, fileId, metadata.Title));
createdFiles.Add(new CreatedHtmlPage(
SequenceNumber: metadata.SequenceNumber,
LatestStatus: metadata.LatestStatus,
FileId: fileId,
Title: metadata.Title));
}

await CreateIndexPage(outputDir, createdFiles, console);
Expand Down
2 changes: 1 addition & 1 deletion src/Talo/FileSystem/CreatedHtmlPage.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
namespace Talo.FileSystem;

public record CreatedHtmlPage(int SequenceNumber, string FileId, string Title);
public record CreatedHtmlPage(int SequenceNumber, string? LatestStatus, string FileId, string Title);
2 changes: 1 addition & 1 deletion src/Talo/Repositories/RecordMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class RecordMetadata
public string Title { get; private set; } = "";
public int SequenceNumber { get; private set; }
private readonly List<StatusRow> _statusRows = [];
private string? LatestStatus { get; set; }
public string? LatestStatus { get; private set; }

public RecordMetadata(string filePath, IConsole console)
{
Expand Down
19 changes: 14 additions & 5 deletions src/Talo/Templating/HtmlTemplates.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text;
using Markdig.Helpers;
using Talo.FileSystem;

namespace Talo.Templating;
Expand Down Expand Up @@ -29,16 +30,24 @@ public static string Top(string title) =>
public static string IndexTable(List<CreatedHtmlPage> createdFiles)
{
var builder = new StringBuilder();
builder.Append("<ul>");
builder.Append("<table><thead><tr><th>No.</th><th>Status</th><th>Title</th></tr></thead><tbody>");
foreach (var file in createdFiles)
{
var fileName = $"{file.FileId}.html";
builder.Append("<li>");
builder.Append($"<a href='{fileName}'>{file.SequenceNumber}. {file.Title}</a>");
builder.Append("</li>");
builder.Append("<tr>");
builder.Append("<td>");
builder.Append(file.SequenceNumber);
builder.Append("</td>");
builder.Append("<td>");
builder.Append(file.LatestStatus);
builder.Append("</td>");
builder.Append("<td>");
builder.Append($"<a href='{fileName}'>{file.Title}</a>");
builder.Append("</td>");
builder.Append("</tr>");
}

builder.Append("</ul>");
builder.Append("</tbody></table>");
return builder.ToString();
}
}
Loading