|
|
@ -12,10 +12,18 @@ namespace DiscordChatExporter.Services
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public partial class ExportService : IExportService
|
|
|
|
public partial class ExportService : IExportService
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
private readonly ISettingsService _settingsService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ExportService(ISettingsService settingsService)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_settingsService = settingsService;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Export(string filePath, ChannelChatLog channelChatLog, Theme theme)
|
|
|
|
public void Export(string filePath, ChannelChatLog channelChatLog, Theme theme)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var doc = GetTemplate();
|
|
|
|
var doc = GetTemplate();
|
|
|
|
var style = GetStyle(theme);
|
|
|
|
var style = GetStyle(theme);
|
|
|
|
|
|
|
|
var dateFormat = _settingsService.DateFormat;
|
|
|
|
|
|
|
|
|
|
|
|
// Set theme
|
|
|
|
// Set theme
|
|
|
|
var themeHtml = doc.GetElementbyId("theme");
|
|
|
|
var themeHtml = doc.GetElementbyId("theme");
|
|
|
@ -61,7 +69,7 @@ namespace DiscordChatExporter.Services
|
|
|
|
messageRightHtml.AppendChild(HtmlNode.CreateNode($"<span class=\"msg-user\">{authorName}</span>"));
|
|
|
|
messageRightHtml.AppendChild(HtmlNode.CreateNode($"<span class=\"msg-user\">{authorName}</span>"));
|
|
|
|
|
|
|
|
|
|
|
|
// Date
|
|
|
|
// Date
|
|
|
|
var timeStamp = HtmlDocument.HtmlEncode(messageGroup.TimeStamp.ToString("g"));
|
|
|
|
var timeStamp = HtmlDocument.HtmlEncode(messageGroup.TimeStamp.ToString(dateFormat));
|
|
|
|
messageRightHtml.AppendChild(HtmlNode.CreateNode($"<span class=\"msg-date\">{timeStamp}</span>"));
|
|
|
|
messageRightHtml.AppendChild(HtmlNode.CreateNode($"<span class=\"msg-date\">{timeStamp}</span>"));
|
|
|
|
|
|
|
|
|
|
|
|
// Individual messages
|
|
|
|
// Individual messages
|
|
|
@ -80,7 +88,7 @@ namespace DiscordChatExporter.Services
|
|
|
|
{
|
|
|
|
{
|
|
|
|
contentHtml.AppendChild(
|
|
|
|
contentHtml.AppendChild(
|
|
|
|
HtmlNode.CreateNode(
|
|
|
|
HtmlNode.CreateNode(
|
|
|
|
$"<span class=\"msg-edited\" title=\"{message.EditedTimeStamp:g}\">(edited)</span>"));
|
|
|
|
$"<span class=\"msg-edited\" title=\"{message.EditedTimeStamp.Value.ToString(dateFormat)}\">(edited)</span>"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -150,7 +158,7 @@ namespace DiscordChatExporter.Services
|
|
|
|
|
|
|
|
|
|
|
|
private static string NormalizeFileSize(long fileSize)
|
|
|
|
private static string NormalizeFileSize(long fileSize)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string[] units = { "B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" };
|
|
|
|
string[] units = {"B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"};
|
|
|
|
double size = fileSize;
|
|
|
|
double size = fileSize;
|
|
|
|
var unit = 0;
|
|
|
|
var unit = 0;
|
|
|
|
|
|
|
|
|
|
|
|