mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-06-08 02:14:42 -04:00
Cleanup templates and change how model is referenced
This commit is contained in:
parent
ed146bac22
commit
37ee0b8be3
5 changed files with 27 additions and 28 deletions
|
@ -1,5 +1,5 @@
|
||||||
Author;Date;Content;Attachments;
|
Author;Date;Content;Attachments;
|
||||||
{{~ for group in MessageGroups -}}
|
{{~ for group in Model.MessageGroups -}}
|
||||||
{{- for message in group.Messages -}}
|
{{- for message in group.Messages -}}
|
||||||
{{- message.Author.FullName }};
|
{{- message.Author.FullName }};
|
||||||
|
|
||||||
|
|
Can't render this file because it contains an unexpected character in line 10 and column 41.
|
|
@ -2,7 +2,7 @@
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<title>{{ Guild.Name | html.escape }} - {{ Channel.Name | html.escape }}</title>
|
<title>{{ Model.Guild.Name | html.escape }} - {{ Model.Channel.Name | html.escape }}</title>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width" />
|
<meta name="viewport" content="width=device-width" />
|
||||||
<style>
|
<style>
|
||||||
|
@ -14,26 +14,26 @@
|
||||||
{{~ # Info ~}}
|
{{~ # Info ~}}
|
||||||
<div class="info">
|
<div class="info">
|
||||||
<div class="info__guild-icon-container">
|
<div class="info__guild-icon-container">
|
||||||
<img class="info__guild-icon" src="{{ Guild.IconUrl }}" />
|
<img class="info__guild-icon" src="{{ Model.Guild.IconUrl }}" />
|
||||||
</div>
|
</div>
|
||||||
<div class="info__metadata">
|
<div class="info__metadata">
|
||||||
<div class="info__guild-name">{{ Guild.Name | html.escape }}</div>
|
<div class="info__guild-name">{{ Model.Guild.Name | html.escape }}</div>
|
||||||
<div class="info__channel-name">{{ Channel.Name | html.escape }}</div>
|
<div class="info__channel-name">{{ Model.Channel.Name | html.escape }}</div>
|
||||||
|
|
||||||
{{~ if Channel.Topic ~}}
|
{{~ if Model.Channel.Topic ~}}
|
||||||
<div class="info__channel-topic">{{ Channel.Topic | html.escape }}</div>
|
<div class="info__channel-topic">{{ Model.Channel.Topic | html.escape }}</div>
|
||||||
{{~ end ~}}
|
{{~ end ~}}
|
||||||
|
|
||||||
<div class="info__channel-message-count">{{ TotalMessageCount | Format "N0" }} messages</div>
|
<div class="info__channel-message-count">{{ Model.TotalMessageCount | Format "N0" }} messages</div>
|
||||||
|
|
||||||
{{~ if From || To ~}}
|
{{~ if Model.From || Model.To ~}}
|
||||||
<div class="info__channel-date-range">
|
<div class="info__channel-date-range">
|
||||||
{{~ if From && To ~}}
|
{{~ if Model.From && Model.To ~}}
|
||||||
Between {{ From | FormatDate | html.escape }} and {{ To | FormatDate | html.escape }}
|
Between {{ Model.From | FormatDate | html.escape }} and {{ Model.To | FormatDate | html.escape }}
|
||||||
{{~ else if From ~}}
|
{{~ else if Model.From ~}}
|
||||||
After {{ From | FormatDate | html.escape }}
|
After {{ Model.From | FormatDate | html.escape }}
|
||||||
{{~ else if To ~}}
|
{{~ else if Model.To ~}}
|
||||||
Before {{ To | FormatDate | html.escape }}
|
Before {{ Model.To | FormatDate | html.escape }}
|
||||||
{{~ end ~}}
|
{{~ end ~}}
|
||||||
</div>
|
</div>
|
||||||
{{~ end ~}}
|
{{~ end ~}}
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
|
|
||||||
{{~ # Log ~}}
|
{{~ # Log ~}}
|
||||||
<div class="chatlog">
|
<div class="chatlog">
|
||||||
{{~ for group in MessageGroups ~}}
|
{{~ for group in Model.MessageGroups ~}}
|
||||||
<div class="chatlog__message-group">
|
<div class="chatlog__message-group">
|
||||||
{{~ # Avatar ~}}
|
{{~ # Avatar ~}}
|
||||||
<div class="chatlog__author-avatar-container">
|
<div class="chatlog__author-avatar-container">
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
{{~ # Info ~}}
|
{{~ # Info ~}}
|
||||||
==============================================================
|
==============================================================
|
||||||
Guild: {{ Guild.Name }}
|
Guild: {{ Model.Guild.Name }}
|
||||||
Channel: {{ Channel.Name }}
|
Channel: {{ Model.Channel.Name }}
|
||||||
Topic: {{ Channel.Topic }}
|
Topic: {{ Model.Channel.Topic }}
|
||||||
Messages: {{ TotalMessageCount | Format "N0" }}
|
Messages: {{ Model.TotalMessageCount | Format "N0" }}
|
||||||
Range: {{ if From }}{{ From | FormatDate }} {{ end }}{{ if From || To }}->{{ end }}{{ if To }} {{ To | FormatDate }}{{ end }}
|
Range: {{ if Model.From }}{{ Model.From | FormatDate }} {{ end }}{{ if Model.From || Model.To }}->{{ end }}{{ if Model.To }} {{ Model.To | FormatDate }}{{ end }}
|
||||||
==============================================================
|
==============================================================
|
||||||
|
|
||||||
{{~ # Log ~}}
|
{{~ # Log ~}}
|
||||||
{{~ for group in MessageGroups ~}}
|
{{~ for group in Model.MessageGroups ~}}
|
||||||
{{~ # Author name and timestamp ~}}
|
{{~ # Author name and timestamp ~}}
|
||||||
{{~ }}[{{ group.Timestamp | FormatDate }}] {{ group.Author.FullName }}
|
{{~ }}[{{ group.Timestamp | FormatDate }}] {{ group.Author.FullName }}
|
||||||
{{~ # Messages ~}}
|
{{~ # Messages ~}}
|
||||||
|
|
|
@ -307,7 +307,7 @@ namespace DiscordChatExporter.Core.Services
|
||||||
var scriptObject = new ScriptObject();
|
var scriptObject = new ScriptObject();
|
||||||
|
|
||||||
// Import chat log
|
// Import chat log
|
||||||
scriptObject.Import(_log, TemplateMemberFilter, TemplateMemberRenamer);
|
scriptObject.SetValue("Model", _log, true);
|
||||||
|
|
||||||
// Import functions
|
// Import functions
|
||||||
scriptObject.Import(nameof(Format), new Func<IFormattable, string, string>(Format));
|
scriptObject.Import(nameof(Format), new Func<IFormattable, string, string>(Format));
|
||||||
|
|
|
@ -7,9 +7,6 @@ namespace DiscordChatExporter.Core.Services
|
||||||
{
|
{
|
||||||
public partial class ExportService : IExportService
|
public partial class ExportService : IExportService
|
||||||
{
|
{
|
||||||
private static readonly MemberRenamerDelegate TemplateMemberRenamer = m => m.Name;
|
|
||||||
private static readonly MemberFilterDelegate TemplateMemberFilter = m => true;
|
|
||||||
|
|
||||||
private readonly ISettingsService _settingsService;
|
private readonly ISettingsService _settingsService;
|
||||||
|
|
||||||
public ExportService(ISettingsService settingsService)
|
public ExportService(ISettingsService settingsService)
|
||||||
|
@ -30,8 +27,10 @@ namespace DiscordChatExporter.Core.Services
|
||||||
var context = new TemplateContext
|
var context = new TemplateContext
|
||||||
{
|
{
|
||||||
TemplateLoader = loader,
|
TemplateLoader = loader,
|
||||||
MemberRenamer = TemplateMemberRenamer,
|
MemberRenamer = m => m.Name,
|
||||||
MemberFilter = TemplateMemberFilter
|
MemberFilter = m => true,
|
||||||
|
LoopLimit = int.MaxValue,
|
||||||
|
StrictVariables = true
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create template model
|
// Create template model
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue