From f6ded3fc8cd55b7bbce929aafd222dfa6043ab57 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Feb 2026 10:20:25 +0000 Subject: [PATCH] Add markdown link support; fold bot instructions into markdown; set TextBlock properties directly Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> --- .../Converters/MarkdownToInlinesConverter.cs | 22 ++++++++++ .../LocalizationManager.English.cs | 11 +++-- .../LocalizationManager.French.cs | 11 +++-- .../LocalizationManager.German.cs | 11 +++-- .../LocalizationManager.Spanish.cs | 11 +++-- .../LocalizationManager.Ukrainian.cs | 11 +++-- .../Localization/LocalizationManager.cs | 4 -- .../Components/DashboardViewModel.cs | 10 ----- .../Views/Components/DashboardView.axaml | 44 +++++++++---------- 9 files changed, 68 insertions(+), 67 deletions(-) diff --git a/DiscordChatExporter.Gui/Converters/MarkdownToInlinesConverter.cs b/DiscordChatExporter.Gui/Converters/MarkdownToInlinesConverter.cs index 0837d4af..cbb17ae8 100644 --- a/DiscordChatExporter.Gui/Converters/MarkdownToInlinesConverter.cs +++ b/DiscordChatExporter.Gui/Converters/MarkdownToInlinesConverter.cs @@ -1,9 +1,13 @@ using System; +using System.Diagnostics; using System.Globalization; using System.Linq; using Avalonia.Controls.Documents; using Avalonia.Data.Converters; using Avalonia.Media; +using CommunityToolkit.Mvvm.Input; +using DiscordChatExporter.Gui.Utils.Extensions; +using DiscordChatExporter.Gui.Views.Controls; using Markdig; using Markdig.Syntax; using Markdig.Syntax.Inlines; @@ -78,6 +82,24 @@ public class MarkdownToInlinesConverter : IValueConverter break; } + case LinkInline link when link.Url is not null: + { + var text = string.Concat( + link.OfType().Select(l => l.Content.ToString()) + ); + var url = link.Url; + inlines.Add( + new InlineUIContainer( + new HyperLink + { + Text = text, + Command = new RelayCommand(() => Process.StartShellExecute(url)), + } + ) + ); + break; + } + case ContainerInline container: { foreach (var child in container) diff --git a/DiscordChatExporter.Gui/Localization/LocalizationManager.English.cs b/DiscordChatExporter.Gui/Localization/LocalizationManager.English.cs index 7c8f5cd5..274e09f2 100644 --- a/DiscordChatExporter.Gui/Localization/LocalizationManager.English.cs +++ b/DiscordChatExporter.Gui/Localization/LocalizationManager.English.cs @@ -30,10 +30,10 @@ public partial class LocalizationManager """, // Token instructions (bot) [nameof(TokenBotHeader)] = "To get the token for your bot:", - [nameof(TokenBotIntro)] = - "The token is generated during bot creation. If you lost it, generate a new one:", - [nameof(TokenBotStep1)] = "1. Open Discord", [nameof(TokenBotInstructions)] = """ + The token is generated during bot creation. If you lost it, generate a new one: + + 1. Open Discord [developer portal](https://discord.com/developers/applications) 2. Open your application's settings 3. Navigate to the **Bot** section on the left 4. Under **Token** click **Reset Token** @@ -41,9 +41,8 @@ public partial class LocalizationManager * Integrations using the previous token will stop working until updated * Your bot needs to have the **Message Content Intent** enabled to read messages """, - [nameof(TokenDeveloperPortalLinkText)] = "developer portal", - [nameof(TokenDocumentationLinkText)] = "documentation", - [nameof(TokenHelpText)] = "If you have questions or issues, please refer to the", + [nameof(TokenHelpText)] = + "If you have questions or issues, please refer to the [documentation](https://github.com/Tyrrrz/DiscordChatExporter/tree/master/.docs)", // Settings [nameof(SettingsTitle)] = "Settings", [nameof(ThemeLabel)] = "Theme", diff --git a/DiscordChatExporter.Gui/Localization/LocalizationManager.French.cs b/DiscordChatExporter.Gui/Localization/LocalizationManager.French.cs index 00af097b..5537c788 100644 --- a/DiscordChatExporter.Gui/Localization/LocalizationManager.French.cs +++ b/DiscordChatExporter.Gui/Localization/LocalizationManager.French.cs @@ -32,10 +32,10 @@ public partial class LocalizationManager """, // Token instructions (bot) [nameof(TokenBotHeader)] = "Obtenir le token pour votre bot :", - [nameof(TokenBotIntro)] = - "Le token est généré lors de la création du bot. Si vous l'avez perdu, générez-en un nouveau :", - [nameof(TokenBotStep1)] = "1. Ouvrez Discord", [nameof(TokenBotInstructions)] = """ + Le token est généré lors de la création du bot. Si vous l'avez perdu, générez-en un nouveau : + + 1. Ouvrez Discord [portail développeur](https://discord.com/developers/applications) 2. Ouvrez les paramètres de votre application 3. Naviguez vers la section **Bot** à gauche 4. Sous **Token**, cliquez sur **Reset Token** @@ -43,9 +43,8 @@ public partial class LocalizationManager * Les intégrations utilisant l'ancien token cesseront de fonctionner jusqu'à leur mise à jour * Votre bot doit avoir l'option **Message Content Intent** activée pour lire les messages """, - [nameof(TokenDeveloperPortalLinkText)] = "portail développeur", - [nameof(TokenDocumentationLinkText)] = "documentation", - [nameof(TokenHelpText)] = "Pour les questions ou problèmes, veuillez consulter la", + [nameof(TokenHelpText)] = + "Pour les questions ou problèmes, veuillez consulter la [documentation](https://github.com/Tyrrrz/DiscordChatExporter/tree/master/.docs)", // Settings [nameof(SettingsTitle)] = "Paramètres", [nameof(ThemeLabel)] = "Thème", diff --git a/DiscordChatExporter.Gui/Localization/LocalizationManager.German.cs b/DiscordChatExporter.Gui/Localization/LocalizationManager.German.cs index fde4001e..57f8ffa0 100644 --- a/DiscordChatExporter.Gui/Localization/LocalizationManager.German.cs +++ b/DiscordChatExporter.Gui/Localization/LocalizationManager.German.cs @@ -32,10 +32,10 @@ public partial class LocalizationManager """, // Token instructions (bot) [nameof(TokenBotHeader)] = "Token für Ihren Bot abrufen:", - [nameof(TokenBotIntro)] = - "Der Token wird bei der Bot-Erstellung generiert. Falls er verloren gegangen ist, generieren Sie einen neuen:", - [nameof(TokenBotStep1)] = "1. Öffnen Sie Discord", [nameof(TokenBotInstructions)] = """ + Der Token wird bei der Bot-Erstellung generiert. Falls er verloren gegangen ist, generieren Sie einen neuen: + + 1. Öffnen Sie Discord [Entwicklerportal](https://discord.com/developers/applications) 2. Öffnen Sie die Einstellungen Ihrer Anwendung 3. Navigieren Sie zum Abschnitt **Bot** auf der linken Seite 4. Klicken Sie unter **Token** auf **Reset Token** @@ -43,9 +43,8 @@ public partial class LocalizationManager * Integrationen, die den alten Token verwenden, hören auf zu funktionieren, bis sie aktualisiert werden * Ihr Bot benötigt die aktivierte **Message Content Intent**, um Nachrichten zu lesen """, - [nameof(TokenDeveloperPortalLinkText)] = "Entwicklerportal", - [nameof(TokenDocumentationLinkText)] = "Dokumentation", - [nameof(TokenHelpText)] = "Bei Fragen oder Problemen lesen Sie die", + [nameof(TokenHelpText)] = + "Bei Fragen oder Problemen lesen Sie die [Dokumentation](https://github.com/Tyrrrz/DiscordChatExporter/tree/master/.docs)", // Settings [nameof(SettingsTitle)] = "Einstellungen", [nameof(ThemeLabel)] = "Design", diff --git a/DiscordChatExporter.Gui/Localization/LocalizationManager.Spanish.cs b/DiscordChatExporter.Gui/Localization/LocalizationManager.Spanish.cs index 912d4f51..a953ea84 100644 --- a/DiscordChatExporter.Gui/Localization/LocalizationManager.Spanish.cs +++ b/DiscordChatExporter.Gui/Localization/LocalizationManager.Spanish.cs @@ -30,10 +30,10 @@ public partial class LocalizationManager """, // Token instructions (bot) [nameof(TokenBotHeader)] = "Cómo obtener el token para tu bot:", - [nameof(TokenBotIntro)] = - "El token se genera al crear el bot. Si lo perdiste, genera uno nuevo:", - [nameof(TokenBotStep1)] = "1. Abre Discord", [nameof(TokenBotInstructions)] = """ + El token se genera al crear el bot. Si lo perdiste, genera uno nuevo: + + 1. Abre Discord [portal de desarrolladores](https://discord.com/developers/applications) 2. Abre la configuración de tu aplicación 3. Navega a la sección **Bot** en el lado izquierdo 4. En **Token**, haz clic en **Reset Token** @@ -41,9 +41,8 @@ public partial class LocalizationManager * Las integraciones que usen el token anterior dejarán de funcionar hasta que se actualicen * Tu bot necesita tener habilitado **Message Content Intent** para leer mensajes """, - [nameof(TokenDeveloperPortalLinkText)] = "portal de desarrolladores", - [nameof(TokenDocumentationLinkText)] = "documentación", - [nameof(TokenHelpText)] = "Si tienes preguntas o problemas, consulta la", + [nameof(TokenHelpText)] = + "Si tienes preguntas o problemas, consulta la [documentación](https://github.com/Tyrrrz/DiscordChatExporter/tree/master/.docs)", // Settings [nameof(SettingsTitle)] = "Ajustes", [nameof(ThemeLabel)] = "Tema", diff --git a/DiscordChatExporter.Gui/Localization/LocalizationManager.Ukrainian.cs b/DiscordChatExporter.Gui/Localization/LocalizationManager.Ukrainian.cs index 20bb844d..e6fd8371 100644 --- a/DiscordChatExporter.Gui/Localization/LocalizationManager.Ukrainian.cs +++ b/DiscordChatExporter.Gui/Localization/LocalizationManager.Ukrainian.cs @@ -30,10 +30,10 @@ public partial class LocalizationManager """, // Token instructions (bot) [nameof(TokenBotHeader)] = "Як отримати токен для бота:", - [nameof(TokenBotIntro)] = - "Токен генерується під час створення бота. Якщо ви його втратили, згенеруйте новий:", - [nameof(TokenBotStep1)] = "1. Відкрийте Discord", [nameof(TokenBotInstructions)] = """ + Токен генерується під час створення бота. Якщо ви його втратили, згенеруйте новий: + + 1. Відкрийте Discord [портал розробника](https://discord.com/developers/applications) 2. Відкрийте налаштування вашого застосунку 3. Перейдіть до розділу **Bot** ліворуч 4. В розділі **Token** натисніть **Reset Token** @@ -41,9 +41,8 @@ public partial class LocalizationManager * Інтеграції, що використовують попередній токен, перестануть працювати * Ваш бот повинен мати включений **Message Content Intent** для читання повідомлень """, - [nameof(TokenDeveloperPortalLinkText)] = "портал розробника", - [nameof(TokenDocumentationLinkText)] = "документацію", - [nameof(TokenHelpText)] = "Якщо у вас є запитання або проблеми, зверніться до", + [nameof(TokenHelpText)] = + "Якщо у вас є запитання або проблеми, зверніться до [документації](https://github.com/Tyrrrz/DiscordChatExporter/tree/master/.docs)", // Settings [nameof(SettingsTitle)] = "Налаштування", [nameof(ThemeLabel)] = "Тема", diff --git a/DiscordChatExporter.Gui/Localization/LocalizationManager.cs b/DiscordChatExporter.Gui/Localization/LocalizationManager.cs index e4aeb6bf..5084f889 100644 --- a/DiscordChatExporter.Gui/Localization/LocalizationManager.cs +++ b/DiscordChatExporter.Gui/Localization/LocalizationManager.cs @@ -91,11 +91,7 @@ public partial class LocalizationManager // Token instructions (bot) public string TokenBotHeader => Get(); - public string TokenBotIntro => Get(); - public string TokenBotStep1 => Get(); public string TokenBotInstructions => Get(); - public string TokenDeveloperPortalLinkText => Get(); - public string TokenDocumentationLinkText => Get(); public string TokenHelpText => Get(); // ---- Settings ---- diff --git a/DiscordChatExporter.Gui/ViewModels/Components/DashboardViewModel.cs b/DiscordChatExporter.Gui/ViewModels/Components/DashboardViewModel.cs index 86626952..4ea42d1a 100644 --- a/DiscordChatExporter.Gui/ViewModels/Components/DashboardViewModel.cs +++ b/DiscordChatExporter.Gui/ViewModels/Components/DashboardViewModel.cs @@ -107,9 +107,6 @@ public partial class DashboardViewModel : ViewModelBase private async Task ShowSettingsAsync() => await _dialogManager.ShowDialogAsync(_viewModelManager.CreateSettingsViewModel()); - [RelayCommand] - private void ShowHelp() => Process.StartShellExecute(Program.ProjectDocumentationUrl); - private bool CanPullGuilds() => !IsBusy && !string.IsNullOrWhiteSpace(Token); [RelayCommand(CanExecute = nameof(CanPullGuilds))] @@ -330,13 +327,6 @@ public partial class DashboardViewModel : ViewModelBase } } - [RelayCommand] - private void OpenDiscord() => Process.StartShellExecute("https://discord.com/app"); - - [RelayCommand] - private void OpenDiscordDeveloperPortal() => - Process.StartShellExecute("https://discord.com/developers/applications"); - protected override void Dispose(bool disposing) { if (disposing) diff --git a/DiscordChatExporter.Gui/Views/Components/DashboardView.axaml b/DiscordChatExporter.Gui/Views/Components/DashboardView.axaml index c9f9d679..6582ad8a 100644 --- a/DiscordChatExporter.Gui/Views/Components/DashboardView.axaml +++ b/DiscordChatExporter.Gui/Views/Components/DashboardView.axaml @@ -4,7 +4,6 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:asyncImageLoader="clr-namespace:AsyncImageLoader;assembly=AsyncImageLoader.Avalonia" xmlns:components="clr-namespace:DiscordChatExporter.Gui.ViewModels.Components" - xmlns:controls="clr-namespace:DiscordChatExporter.Gui.Views.Controls" xmlns:converters="clr-namespace:DiscordChatExporter.Gui.Converters" xmlns:materialIcons="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia" xmlns:materialStyles="clr-namespace:Material.Styles.Controls;assembly=Material.Styles" @@ -220,14 +219,6 @@ - - - @@ -246,9 +237,17 @@ Text="{Binding LocalizationManager.TokenPersonalHeader}" /> - + - + @@ -267,19 +266,18 @@ Text="{Binding LocalizationManager.TokenBotHeader}" /> - + - - - - - - - - - - - +