From ffe5544f9c0b1f4d92fcad138e096a948f9e33a0 Mon Sep 17 00:00:00 2001 From: Oleksii Holub <1935960+Tyrrrz@users.noreply.github.com> Date: Thu, 7 Apr 2022 20:25:14 +0300 Subject: [PATCH] Dowload fonts in HTML export when using download media --- .../Writers/Html/MessageGroupTemplate.cshtml | 14 +++++++------- .../Writers/Html/PreambleTemplate.cshtml | 17 ++++++++++------- .../ViewModels/Dialogs/ExportSetupViewModel.cs | 2 +- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/DiscordChatExporter.Core/Exporting/Writers/Html/MessageGroupTemplate.cshtml b/DiscordChatExporter.Core/Exporting/Writers/Html/MessageGroupTemplate.cshtml index 84a99e9..ab29e15 100644 --- a/DiscordChatExporter.Core/Exporting/Writers/Html/MessageGroupTemplate.cshtml +++ b/DiscordChatExporter.Core/Exporting/Writers/Html/MessageGroupTemplate.cshtml @@ -8,14 +8,14 @@ @inherits MiniRazor.TemplateBase @{ + ValueTask ResolveUrlAsync(string url) => Model.ExportContext.ResolveMediaUrlAsync(url); + string FormatDate(DateTimeOffset date) => Model.ExportContext.FormatDate(date); string FormatMarkdown(string markdown) => Model.FormatMarkdown(markdown); string FormatEmbedMarkdown(string markdown) => Model.FormatMarkdown(markdown, false); - ValueTask ResolveUrlAsync(string url) => Model.ExportContext.ResolveMediaUrlAsync(url); - var userMember = Model.ExportContext.TryGetMember(Model.MessageGroup.Author.Id); var userColor = Model.ExportContext.TryGetUserColor(Model.MessageGroup.Author.Id); @@ -140,19 +140,19 @@ @if (attachment.IsImage) { - Image attachment + Image attachment } else if (attachment.IsVideo) { } else if (attachment.IsAudio) { } else @@ -418,11 +418,11 @@
@if (sticker.Format is StickerFormat.Png or StickerFormat.PngAnimated) { - Sticker + Sticker } else if (sticker.Format == StickerFormat.Lottie) { -
+
}
} diff --git a/DiscordChatExporter.Core/Exporting/Writers/Html/PreambleTemplate.cshtml b/DiscordChatExporter.Core/Exporting/Writers/Html/PreambleTemplate.cshtml index 04bc718..96fb419 100644 --- a/DiscordChatExporter.Core/Exporting/Writers/Html/PreambleTemplate.cshtml +++ b/DiscordChatExporter.Core/Exporting/Writers/Html/PreambleTemplate.cshtml @@ -11,10 +11,13 @@ ? darkVariant : lightVariant; - string FormatDate(DateTimeOffset date) => Model.ExportContext.FormatDate(date); + string GetFontUrl(int weight) => + $"https://cdn.jsdelivr.net/gh/Tyrrrz/DiscordFonts@master/whitney-{weight}.woff"; ValueTask ResolveUrlAsync(string url) => Model.ExportContext.ResolveMediaUrlAsync(url, CancellationToken); + string FormatDate(DateTimeOffset date) => Model.ExportContext.FormatDate(date); + string FormatMarkdown(string markdown) => Model.FormatMarkdown(markdown); } @@ -30,38 +33,38 @@