Skip to content
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
24 changes: 21 additions & 3 deletions src/ModelPublisher.Core/Models/ReleaseManifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,28 @@ public string ResolveFilePath(string relativePath)
return Path.GetFullPath(Path.Combine(ManifestDirectory, relativePath));
}

/// <summary>
/// Returns the description with the platform's disclaimer appended, formatted for the platform
/// (markdown if supported, plain text otherwise).
/// </summary>
public string GetDescription(IPlatformPublisher publisher)
=> publisher.SupportsMarkdown
? Description
: MarkdownHelper.ToPlainText(Description);
{
var markdown = AppendDisclaimer(Description, publisher.Disclaimer);
return publisher.SupportsMarkdown ? markdown : MarkdownHelper.ToPlainText(markdown);
}

/// <summary>
/// Returns the description with the platform's disclaimer appended, always as markdown.
/// Use this when the caller handles its own format conversion (e.g. TipTap HTML injection).
/// </summary>
public string GetDescriptionMarkdown(IPlatformPublisher publisher)
=> AppendDisclaimer(Description, publisher.Disclaimer);

private static string AppendDisclaimer(string description, string disclaimer)
{
if (string.IsNullOrWhiteSpace(disclaimer)) return description;
return $"{description}\n\n---\n\n{disclaimer}";
}
}

public class ManifestFiles
Expand Down
2 changes: 2 additions & 0 deletions src/ModelPublisher.Core/Platforms/Cults3DPublisher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class Cults3DPublisher : IPlatformPublisher
public bool IsFreeOnly => true;
public bool SupportsMarkdown => true;

public string Disclaimer => "";

public async Task<PublishResult> PublishFreeAsync(ReleaseManifest manifest, IPage page, CancellationToken ct = default)
{
try
Expand Down
6 changes: 6 additions & 0 deletions src/ModelPublisher.Core/Platforms/IPlatformPublisher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ public interface IPlatformPublisher

bool SupportsMarkdown => false;

/// <summary>
/// Platform-specific disclaimer appended to the bottom of every description (markdown format).
/// Return empty string to omit.
/// </summary>
string Disclaimer => "";

Task<PublishResult> PublishFreeAsync(ReleaseManifest manifest, IPage page, CancellationToken ct = default);

Task<PublishResult> PublishPremiumAsync(ReleaseManifest manifest, IPage page, CancellationToken ct = default);
Expand Down
2 changes: 2 additions & 0 deletions src/ModelPublisher.Core/Platforms/MakerOnlinePublisher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class MakerOnlinePublisher : IPlatformPublisher
public bool IsFreeOnly => true;
public bool SupportsMarkdown => true;

public string Disclaimer => "";

public async Task<PublishResult> PublishFreeAsync(ReleaseManifest manifest, IPage page, CancellationToken ct = default)
{
try
Expand Down
2 changes: 2 additions & 0 deletions src/ModelPublisher.Core/Platforms/MakerWorldPublisher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class MakerWorldPublisher : IPlatformPublisher
public bool IsFreeOnly => true;
public bool SupportsMarkdown => true;

public string Disclaimer => "";

public async Task<PublishResult> PublishFreeAsync(ReleaseManifest manifest, IPage page, CancellationToken ct = default)
{
try
Expand Down
2 changes: 2 additions & 0 deletions src/ModelPublisher.Core/Platforms/PatreonPublisher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public class PatreonPublisher : IPlatformPublisher
public bool IsFreeOnly => true; // Patreon posts aren't free, but we do not have both free and premium tiers
public bool SupportsMarkdown => false;

public string Disclaimer => "";

public async Task<PublishResult> PublishFreeAsync(ReleaseManifest manifest, IPage page, CancellationToken ct = default)
{
try
Expand Down
4 changes: 3 additions & 1 deletion src/ModelPublisher.Core/Platforms/PrintablesPublisher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class PrintablesPublisher : IPlatformPublisher
public bool IsFreeOnly => false;
public bool SupportsMarkdown => false;

public string Disclaimer => "";

public async Task<PublishResult> PublishFreeAsync(ReleaseManifest manifest, IPage page,
CancellationToken ct = default)
{
Expand Down Expand Up @@ -93,7 +95,7 @@ await page
.CheckAsync();

// Step 8: Description — inject HTML directly into TipTap's ProseMirror div
var descHtml = MarkdownHelper.ToTipTapHtml(manifest.Description);
var descHtml = MarkdownHelper.ToTipTapHtml(manifest.GetDescriptionMarkdown(this));
var descEditor = page.Locator("section")
.Filter(new() { HasText = "Description" })
.GetByRole(AriaRole.Textbox);
Expand Down
2 changes: 2 additions & 0 deletions src/ModelPublisher.Core/Platforms/ThangsPublisher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class ThangsPublisher : IPlatformPublisher

public bool IsFreeOnly => false;
public bool SupportsMarkdown => true;

public string Disclaimer => "";

public async Task<PublishResult> PublishFreeAsync(ReleaseManifest manifest, IPage page, CancellationToken ct = default)
{
Expand Down