mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-02-14 15:53:30 -07:00
Dowload fonts in HTML export when using download media
This commit is contained in:
parent
bf1ad07a9c
commit
ffe5544f9c
|
|
@ -8,14 +8,14 @@
|
||||||
@inherits MiniRazor.TemplateBase<MessageGroupTemplateContext>
|
@inherits MiniRazor.TemplateBase<MessageGroupTemplateContext>
|
||||||
|
|
||||||
@{
|
@{
|
||||||
|
ValueTask<string> ResolveUrlAsync(string url) => Model.ExportContext.ResolveMediaUrlAsync(url);
|
||||||
|
|
||||||
string FormatDate(DateTimeOffset date) => Model.ExportContext.FormatDate(date);
|
string FormatDate(DateTimeOffset date) => Model.ExportContext.FormatDate(date);
|
||||||
|
|
||||||
string FormatMarkdown(string markdown) => Model.FormatMarkdown(markdown);
|
string FormatMarkdown(string markdown) => Model.FormatMarkdown(markdown);
|
||||||
|
|
||||||
string FormatEmbedMarkdown(string markdown) => Model.FormatMarkdown(markdown, false);
|
string FormatEmbedMarkdown(string markdown) => Model.FormatMarkdown(markdown, false);
|
||||||
|
|
||||||
ValueTask<string> ResolveUrlAsync(string url) => Model.ExportContext.ResolveMediaUrlAsync(url);
|
|
||||||
|
|
||||||
var userMember = Model.ExportContext.TryGetMember(Model.MessageGroup.Author.Id);
|
var userMember = Model.ExportContext.TryGetMember(Model.MessageGroup.Author.Id);
|
||||||
|
|
||||||
var userColor = Model.ExportContext.TryGetUserColor(Model.MessageGroup.Author.Id);
|
var userColor = Model.ExportContext.TryGetUserColor(Model.MessageGroup.Author.Id);
|
||||||
|
|
@ -140,19 +140,19 @@
|
||||||
@if (attachment.IsImage)
|
@if (attachment.IsImage)
|
||||||
{
|
{
|
||||||
<a href="@await ResolveUrlAsync(attachment.Url)">
|
<a href="@await ResolveUrlAsync(attachment.Url)">
|
||||||
<img class="chatlog__attachment-media" src="@await ResolveUrlAsync(attachment.Url)" alt="Image attachment" title="@($"Image: {attachment.FileName} ({attachment.FileSize})")" loading="lazy">
|
<img class="chatlog__attachment-media" src="@await ResolveUrlAsync(attachment.Url)" alt="Image attachment" title="Image: @attachment.FileName (@attachment.FileSize)" loading="lazy">
|
||||||
</a>
|
</a>
|
||||||
}
|
}
|
||||||
else if (attachment.IsVideo)
|
else if (attachment.IsVideo)
|
||||||
{
|
{
|
||||||
<video class="chatlog__attachment-media" controls>
|
<video class="chatlog__attachment-media" controls>
|
||||||
<source src="@await ResolveUrlAsync(attachment.Url)" alt="Video attachment" title="@($"Video: {attachment.FileName} ({attachment.FileSize})")">
|
<source src="@await ResolveUrlAsync(attachment.Url)" alt="Video attachment" title="Video: @attachment.FileName (@attachment.FileSize)">
|
||||||
</video>
|
</video>
|
||||||
}
|
}
|
||||||
else if (attachment.IsAudio)
|
else if (attachment.IsAudio)
|
||||||
{
|
{
|
||||||
<audio class="chatlog__attachment-media" controls>
|
<audio class="chatlog__attachment-media" controls>
|
||||||
<source src="@await ResolveUrlAsync(attachment.Url)" alt="Audio attachment" title="@($"Audio: {attachment.FileName} ({attachment.FileSize})")">
|
<source src="@await ResolveUrlAsync(attachment.Url)" alt="Audio attachment" title="Audio: @attachment.FileName (@attachment.FileSize)">
|
||||||
</audio>
|
</audio>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -418,11 +418,11 @@
|
||||||
<div class="chatlog__sticker" title="@sticker.Name">
|
<div class="chatlog__sticker" title="@sticker.Name">
|
||||||
@if (sticker.Format is StickerFormat.Png or StickerFormat.PngAnimated)
|
@if (sticker.Format is StickerFormat.Png or StickerFormat.PngAnimated)
|
||||||
{
|
{
|
||||||
<img class="chatlog__sticker--media" src="@(await ResolveUrlAsync(sticker.SourceUrl))" alt="Sticker">
|
<img class="chatlog__sticker--media" src="@await ResolveUrlAsync(sticker.SourceUrl)" alt="Sticker">
|
||||||
}
|
}
|
||||||
else if (sticker.Format == StickerFormat.Lottie)
|
else if (sticker.Format == StickerFormat.Lottie)
|
||||||
{
|
{
|
||||||
<div class="chatlog__sticker--media" data-source="@(await ResolveUrlAsync(sticker.SourceUrl))"></div>
|
<div class="chatlog__sticker--media" data-source="@await ResolveUrlAsync(sticker.SourceUrl)"></div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,13 @@
|
||||||
? darkVariant
|
? darkVariant
|
||||||
: lightVariant;
|
: 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<string> ResolveUrlAsync(string url) => Model.ExportContext.ResolveMediaUrlAsync(url, CancellationToken);
|
ValueTask<string> ResolveUrlAsync(string url) => Model.ExportContext.ResolveMediaUrlAsync(url, CancellationToken);
|
||||||
|
|
||||||
|
string FormatDate(DateTimeOffset date) => Model.ExportContext.FormatDate(date);
|
||||||
|
|
||||||
string FormatMarkdown(string markdown) => Model.FormatMarkdown(markdown);
|
string FormatMarkdown(string markdown) => Model.FormatMarkdown(markdown);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -30,38 +33,38 @@
|
||||||
<style>
|
<style>
|
||||||
@@font-face {
|
@@font-face {
|
||||||
font-family: Whitney;
|
font-family: Whitney;
|
||||||
src: url(https://cdn.jsdelivr.net/gh/Tyrrrz/DiscordFonts@master/whitney-300.woff);
|
src: url(@await ResolveUrlAsync(GetFontUrl(300)));
|
||||||
font-weight: 300;
|
font-weight: 300;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@font-face {
|
@@font-face {
|
||||||
font-family: Whitney;
|
font-family: Whitney;
|
||||||
src: url(https://cdn.jsdelivr.net/gh/Tyrrrz/DiscordFonts@master/whitney-400.woff);
|
src: url(@await ResolveUrlAsync(GetFontUrl(400)));
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@font-face {
|
@@font-face {
|
||||||
font-family: Whitney;
|
font-family: Whitney;
|
||||||
src: url(https://cdn.jsdelivr.net/gh/Tyrrrz/DiscordFonts@master/whitney-500.woff);
|
src: url(@await ResolveUrlAsync(GetFontUrl(500)));
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@font-face {
|
@@font-face {
|
||||||
font-family: Whitney;
|
font-family: Whitney;
|
||||||
src: url(https://cdn.jsdelivr.net/gh/Tyrrrz/DiscordFonts@master/whitney-600.woff);
|
src: url(@await ResolveUrlAsync(GetFontUrl(600)));
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@font-face {
|
@@font-face {
|
||||||
font-family: Whitney;
|
font-family: Whitney;
|
||||||
src: url(https://cdn.jsdelivr.net/gh/Tyrrrz/DiscordFonts@master/whitney-700.woff);
|
src: url(@await ResolveUrlAsync(GetFontUrl(700)));
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
background-color: @Themed("#36393e", "#ffffff");
|
background-color: @Themed("#36393e", "#ffffff");
|
||||||
color: @Themed("#dcddde", "#23262a");
|
color: @Themed("#dcddde", "#23262a");
|
||||||
font-family: "Whitney", "Helvetica Neue", Helvetica, Arial, sans-serif;
|
font-family: Whitney, "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||||
font-size: 17px;
|
font-size: 17px;
|
||||||
font-weight: @Themed("400", "500");
|
font-weight: @Themed("400", "500");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ public class ExportSetupViewModel : DialogScreen
|
||||||
MessageFilterValue = _settingsService.LastMessageFilterValue;
|
MessageFilterValue = _settingsService.LastMessageFilterValue;
|
||||||
ShouldDownloadMedia = _settingsService.LastShouldDownloadMedia;
|
ShouldDownloadMedia = _settingsService.LastShouldDownloadMedia;
|
||||||
|
|
||||||
// Show the "advanced options" by default if any
|
// Show the "advanced options" section by default if any
|
||||||
// of the advanced options are set to non-default values.
|
// of the advanced options are set to non-default values.
|
||||||
IsAdvancedSectionDisplayed =
|
IsAdvancedSectionDisplayed =
|
||||||
After != default ||
|
After != default ||
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue