mirror of https://github.com/ErsatzTV/ErsatzTV.git
Browse Source
* rename artifacts; remove github changelog * update dependencies * remove unused markdown view * fix app name in macos scripts * fix unit testspull/2842/head
29 changed files with 108 additions and 328 deletions
@ -1,7 +0,0 @@
@@ -1,7 +0,0 @@
|
||||
namespace ErsatzTV.Core.Interfaces.GitHub; |
||||
|
||||
public interface IGitHubApiClient |
||||
{ |
||||
Task<Either<BaseError, string>> GetLatestReleaseNotes(CancellationToken cancellationToken); |
||||
Task<Either<BaseError, string>> GetReleaseNotes(string tag, CancellationToken cancellationToken); |
||||
} |
||||
@ -1,34 +0,0 @@
@@ -1,34 +0,0 @@
|
||||
using ErsatzTV.Core; |
||||
using ErsatzTV.Core.Interfaces.GitHub; |
||||
using Refit; |
||||
|
||||
namespace ErsatzTV.Infrastructure.GitHub; |
||||
|
||||
public class GitHubApiClient : IGitHubApiClient |
||||
{ |
||||
public async Task<Either<BaseError, string>> GetLatestReleaseNotes(CancellationToken cancellationToken) |
||||
{ |
||||
try |
||||
{ |
||||
IGitHubApi service = RestService.For<IGitHubApi>("https://api.github.com"); |
||||
return await service.GetReleases(cancellationToken).Map(releases => releases.Head().Body); |
||||
} |
||||
catch (Exception ex) |
||||
{ |
||||
return BaseError.New(ex.ToString()); |
||||
} |
||||
} |
||||
|
||||
public async Task<Either<BaseError, string>> GetReleaseNotes(string tag, CancellationToken cancellationToken) |
||||
{ |
||||
try |
||||
{ |
||||
IGitHubApi service = RestService.For<IGitHubApi>("https://api.github.com"); |
||||
return await service.GetTag(tag, cancellationToken).Map(t => t.Body); |
||||
} |
||||
catch (Exception ex) |
||||
{ |
||||
return BaseError.New(ex.ToString()); |
||||
} |
||||
} |
||||
} |
||||
@ -1,14 +0,0 @@
@@ -1,14 +0,0 @@
|
||||
using ErsatzTV.Infrastructure.GitHub.Models; |
||||
using Refit; |
||||
|
||||
namespace ErsatzTV.Infrastructure.GitHub; |
||||
|
||||
[Headers("Accept: application/vnd.github.v3+json", "User-Agent: ErsatzTV/ErsatzTV")] |
||||
public interface IGitHubApi |
||||
{ |
||||
[Get("/repos/ErsatzTV/ErsatzTV/releases")] |
||||
Task<List<GitHubTag>> GetReleases(CancellationToken cancellationToken); |
||||
|
||||
[Get("/repos/ErsatzTV/ErsatzTV/releases/tags/{tag}")] |
||||
Task<GitHubTag> GetTag(string tag, CancellationToken cancellationToken); |
||||
} |
||||
@ -1,6 +0,0 @@
@@ -1,6 +0,0 @@
|
||||
namespace ErsatzTV.Infrastructure.GitHub.Models; |
||||
|
||||
public class GitHubTag |
||||
{ |
||||
public string Body { get; set; } |
||||
} |
||||
@ -1,69 +0,0 @@
@@ -1,69 +0,0 @@
|
||||
using Ganss.Xss; |
||||
using Markdig; |
||||
using Microsoft.AspNetCore.Components; |
||||
using Microsoft.JSInterop; |
||||
|
||||
namespace ErsatzTV.Shared; |
||||
|
||||
public partial class MarkdownView |
||||
{ |
||||
private MarkupString? _markupContent; |
||||
|
||||
[Inject] |
||||
public IHtmlSanitizer HtmlSanitizer { get; set; } |
||||
|
||||
[Inject] |
||||
public IJSRuntime JsRuntime { get; set; } |
||||
|
||||
[Parameter] |
||||
public string Content { get; set; } |
||||
|
||||
public MarkupString? HtmlContent |
||||
{ |
||||
get |
||||
{ |
||||
if (string.IsNullOrWhiteSpace(Content)) |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
return _markupContent ?? (_markupContent = ConvertStringToMarkupString(Content)).Value; |
||||
} |
||||
} |
||||
|
||||
private MarkupString ConvertStringToMarkupString(string value) |
||||
{ |
||||
if (!string.IsNullOrWhiteSpace(value)) |
||||
{ |
||||
// Convert markdown string to HTML
|
||||
string html = Markdown.ToHtml( |
||||
value, |
||||
new MarkdownPipelineBuilder() |
||||
.UseAdvancedExtensions() |
||||
.UseSoftlineBreakAsHardlineBreak() |
||||
.Build()); |
||||
|
||||
// Sanitize HTML before rendering
|
||||
string sanitizedHtml = HtmlSanitizer.Sanitize(html); |
||||
|
||||
// Return sanitized HTML as a MarkupString that Blazor can render
|
||||
return new MarkupString(sanitizedHtml); |
||||
} |
||||
|
||||
return new MarkupString(); |
||||
} |
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender) |
||||
{ |
||||
try |
||||
{ |
||||
await JsRuntime.InvokeVoidAsync("styleMarkdown"); |
||||
} |
||||
catch (Exception) |
||||
{ |
||||
// ignored
|
||||
} |
||||
|
||||
await base.OnAfterRenderAsync(true); |
||||
} |
||||
} |
||||
Loading…
Reference in new issue