diff --git a/app/MindWork AI Studio/Dialogs/PandocDialog.razor b/app/MindWork AI Studio/Dialogs/PandocDialog.razor
index 54989d8b..a9b64504 100644
--- a/app/MindWork AI Studio/Dialogs/PandocDialog.razor
+++ b/app/MindWork AI Studio/Dialogs/PandocDialog.razor
@@ -7,14 +7,14 @@
{
- AI Studio relies on the third-party app Pandoc to process and retrieve data from
- local
+ AI Studio relies on the free and open-sourced third-party app Pandoc to process and retrieve data from local
Office files (ex. Word) and later other text formats like LaTeX.
- Unfortunately Pandocs GPL license is not compatible with AI Studios licences.
- Therefore you have to accept Pandocs GPL license before we can download and install Pandoc
- automatically for you (recommended).
+ Unfortunately Pandoc's GPL license is not compatible with AI Studios licences, nonetheless software under GPL is generally free to use and
+ free of charge as well.
+ Therefore you have to accept Pandoc's GPL license before we can download and install Pandoc for free
+ automatically for you (recommended).
However you can download it yourself manually with the instructions below.
@@ -27,7 +27,7 @@
}
else if (!string.IsNullOrEmpty(this.licenseText))
{
- @this.licenseText
+ @this.licenseText
}
@@ -38,10 +38,10 @@
Pandoc is distributed under the
GNU General Public License v2 (GPL).
By clicking "Accept GPL and Install", you agree to the terms of the GPL license
and Pandoc
- will be installed automatically for you.
+ will be installed automatically for you. Software under GPL is
free of charge and free to use.
- Accept GPL and Install
+ Accept GPL and install for free
@@ -51,7 +51,7 @@
-
+
Accept the terms of the GPL license and download the latest installer with the download button below.
Eventually you need to allow the download of the installer in the download window.
@@ -66,7 +66,7 @@
Pandoc is distributed under the GNU General Public License v2 (GPL).
- By clicking "Accept GPL and download installer", you agree to the terms of the GPL license.
+ By clicking "Accept GPL and download installer", you agree to the terms of the GPL license. Software under GPL is free of charge and free to use.
Accept GPL and download installer
@@ -74,10 +74,10 @@
-
+
Accept the terms of the GPL license and download the latest archive with the download button below.
-
+
Extract the archive to a folder of your choice.
C:\Users\%USERNAME%\pandoc
@@ -85,7 +85,7 @@
/usr/local/bin/pandoc
-
+
Open the folder and copy the full path to the pandoc.exe file into your
clipboard.
@@ -107,7 +107,7 @@
Pandoc is distributed under the GNU General Public License v2 (GPL).
- By clicking "Accept GPL and archive", you agree to the terms of the GPL license.
+ By clicking "Accept GPL and archive", you agree to the terms of the GPL license. Software under GPL is free of charge and free to use.
Accept GPL and download archive
@@ -117,7 +117,7 @@
- Reject GPL licence
+ Reject GPL licence
}
else
@@ -151,7 +151,4 @@
}
-
-
-
\ No newline at end of file
diff --git a/app/MindWork AI Studio/Dialogs/PandocDialog.razor.cs b/app/MindWork AI Studio/Dialogs/PandocDialog.razor.cs
index 19a2fcaa..d1ca7392 100644
--- a/app/MindWork AI Studio/Dialogs/PandocDialog.razor.cs
+++ b/app/MindWork AI Studio/Dialogs/PandocDialog.razor.cs
@@ -14,6 +14,9 @@ public partial class PandocDialog : ComponentBase
[Inject]
protected IJSRuntime JsRuntime { get; init; } = null!;
+ [Inject]
+ private IDialogService DialogService { get; init; } = null!;
+
[CascadingParameter]
private IMudDialogInstance MudDialog { get; set; } = null!;
@@ -42,12 +45,17 @@ public partial class PandocDialog : ComponentBase
private async Task CheckPandocAvailabilityAsync()
{
- this.isPandocAvailable = await Pandoc.CheckAvailabilityAsync(false);
+ this.isPandocAvailable = await Pandoc.CheckAvailabilityAsync(this.RustService);
this.showSkeleton = false;
await this.InvokeAsync(this.StateHasChanged);
}
- private async Task InstallPandocAsync() => await Pandoc.InstallAsync(this.RustService);
+ private async Task InstallPandocAsync()
+ {
+ await Pandoc.InstallAsync(this.RustService);
+ this.MudDialog.Close(DialogResult.Ok(true));
+ await this.DialogService.ShowAsync("pandoc dialog");
+ }
private void ProceedToInstallation() => this.showInstallPage = true;
@@ -56,7 +64,6 @@ public partial class PandocDialog : ComponentBase
var uri = await Pandoc.GenerateInstallerUriAsync();
var filename = this.FilenameFromUri(uri);
await this.JsRuntime.InvokeVoidAsync("triggerDownload", uri, filename);
-
}
private async Task GetArchive()
@@ -66,15 +73,33 @@ public partial class PandocDialog : ComponentBase
await this.JsRuntime.InvokeVoidAsync("triggerDownload", uri, filename);
}
+ private async Task RejectLicense()
+ {
+ var message = "Pandoc is open-source and free of charge, but if you reject Pandoc's license, it can not be installed and some of AIStudios data retrieval features will be disabled (e.g. using Office files like Word)." +
+ "This decision can be revoked at any time. Are you sure you want to reject the license?";
+
+ var dialogParameters = new DialogParameters
+ {
+ { "Message", message },
+ };
+
+ var dialogReference = await this.DialogService.ShowAsync("Reject Pandoc's licence", dialogParameters, DialogOptions.FULLSCREEN);
+ var dialogResult = await dialogReference.Result;
+ if (dialogResult is null || dialogResult.Canceled)
+ dialogReference.Close();
+ else
+ this.Cancel();
+ }
+
private string FilenameFromUri(string uri)
{
var index = uri.LastIndexOf('/');
return uri[(index + 1)..];
}
- private async Task OnExpandedChanged(bool newVal)
+ private async Task OnExpandedChanged(bool isExpanded)
{
- if (newVal)
+ if (isExpanded)
{
this.isLoading = true;
try
diff --git a/app/MindWork AI Studio/Tools/Pandoc.cs b/app/MindWork AI Studio/Tools/Pandoc.cs
index f48e5ea9..b989d2b9 100644
--- a/app/MindWork AI Studio/Tools/Pandoc.cs
+++ b/app/MindWork AI Studio/Tools/Pandoc.cs
@@ -20,8 +20,27 @@ public static partial class Pandoc
/// Checks if pandoc is available on the system and can be started as a process
///
/// True, if pandoc is available and the minimum required version is met, else False.
- public static async Task CheckAvailabilityAsync(bool showMessages = true)
+ public static async Task CheckAvailabilityAsync(RustService rustService, bool showMessages = true)
{
+ var installDir = await GetPandocDataFolder(rustService);
+ var subdirectories = Directory.GetDirectories(installDir);
+
+ if (subdirectories.Length > 1)
+ {
+ await InstallAsync(rustService);
+ return true;
+ }
+
+ var hasPandoc = false;
+ foreach (var subdirectory in subdirectories)
+ {
+ if (subdirectory.Contains("pandoc"))
+ hasPandoc = true;
+ }
+
+ if (hasPandoc)
+ return true;
+
try
{
var startInfo = new ProcessStartInfo
@@ -88,9 +107,8 @@ public static partial class Pandoc
public static async Task InstallAsync(RustService rustService)
{
- var dataDir = await rustService.GetDataDirectory();
- await MessageBus.INSTANCE.SendError(new (Icons.Material.Filled.Help, $"{dataDir}"));
- var installDir = Path.Join(dataDir, "pandoc");
+ var installDir = await GetPandocDataFolder(rustService);
+ ClearFolder(installDir);
try
{
@@ -126,35 +144,31 @@ public static partial class Pandoc
LOG.LogError("Pandoc was not installed, the download archive is unknown:\n {Uri}", uri);
return;
}
-
-
- var currentPath = Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Machine);
- var pandocDir = Path.Join(currentPath, "pandoc-3.6.4");
- if (currentPath != null && !currentPath.Contains(pandocDir))
- {
- Environment.SetEnvironmentVariable(
- "PATH",
- $"{currentPath};{pandocDir}",
- EnvironmentVariableTarget.Machine);
- Console.WriteLine("Pandoc-Verzeichnis zum PATH hinzugefügt.");
- }
- else
- {
- Console.WriteLine("Pandoc-Verzeichnis ist bereits im PATH.");
- }
await MessageBus.INSTANCE.SendSuccess(new(Icons.Material.Filled.CheckCircle,
- $"Pandoc {MINIMUM_REQUIRED_VERSION.ToString()} was installed successfully."));
+ $"Pandoc {await FetchLatestVersionAsync()} was installed successfully."));
}
catch (Exception ex)
{
Console.WriteLine($"Fehler: {ex.Message}");
}
}
-
- private static async Task ExtractZipAsync(string zipPath, string targetDir)
+
+ private static void ClearFolder(string path)
{
+ if (!Directory.Exists(path)) return;
+ try
+ {
+ foreach (var dir in Directory.GetDirectories(path))
+ {
+ Directory.Delete(dir, true);
+ }
+ }
+ catch (Exception ex)
+ {
+ LOG.LogError(ex, "Error clearing pandoc folder.");
+ }
}
public static async Task FetchLatestVersionAsync() {
@@ -222,6 +236,8 @@ public static partial class Pandoc
///
private static string GetPandocExecutableName() => RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "pandoc.exe" : "pandoc";
+ private static async Task GetPandocDataFolder(RustService rustService) => Path.Join(await rustService.GetDataDirectory(), "pandoc");
+
[GeneratedRegex(@"pandoc(?:\.exe)?\s*([0-9]+\.[0-9]+)")]
private static partial Regex PandocRegex();