add option to generate markdown table
This commit is contained in:
@@ -6,6 +6,7 @@ using ModpackUpdater.Manager;
|
||||
using OfficeOpenXml;
|
||||
using Pilz.UI.Extensions;
|
||||
using System.Text;
|
||||
using Telerik.WinControls;
|
||||
using Telerik.WinControls.UI;
|
||||
|
||||
namespace ModpackUpdater.Apps.Manager.Features;
|
||||
@@ -212,7 +213,46 @@ internal static class SharedFunctions
|
||||
return log.ToString().TrimEnd();
|
||||
}
|
||||
|
||||
public static ExcelPackage? GenerateModlist(InstallInfos installInfos)
|
||||
public static string GenerateModlistAsMarkdown(InstallInfos installInfos)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("|" + ActionsListLangRes.Col_Name);
|
||||
sb.Append("|" + ActionsListLangRes.Col_SrcTag);
|
||||
sb.Append("|" + ActionsListLangRes.Col_Side);
|
||||
sb.Append("|" + ActionsListLangRes.Col_SrcType);
|
||||
sb.Append("|" + ActionsListLangRes.Col_SrcOwner);
|
||||
sb.Append("|" + ActionsListLangRes.Col_SrcName);
|
||||
sb.AppendLine("|");
|
||||
sb.AppendLine("|---|---|---|---|---|---|");
|
||||
|
||||
// Rows
|
||||
foreach (var action in installInfos.Actions.OrderBy(n => n.Name))
|
||||
{
|
||||
if (action.IsExtra || action.IsZip || string.IsNullOrWhiteSpace(action.Id) || !action.Id.StartsWith("mod:"))
|
||||
continue;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(action.Website))
|
||||
sb.Append($"|{action.Name}");
|
||||
else
|
||||
sb.Append($"|[{action.Name}]({action.Website})");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(action.SourceUrl))
|
||||
sb.Append($"|{action.SourceTag}");
|
||||
else
|
||||
sb.Append($"|[{action.SourceTag}]({action.SourceUrl})");
|
||||
|
||||
sb.Append($"|{action.Side.ToString()}");
|
||||
sb.Append($"|{action.SourceType}");
|
||||
sb.Append($"|{action.SourceOwner}");
|
||||
sb.Append($"|{action.SourceName}");
|
||||
|
||||
sb.AppendLine("|");
|
||||
}
|
||||
|
||||
return sb.ToString().TrimEnd();
|
||||
}
|
||||
|
||||
public static ExcelPackage? GenerateModlistAsExcel(InstallInfos installInfos)
|
||||
{
|
||||
var pkg = new ExcelPackage();
|
||||
var ws = pkg.Workbook.Worksheets.Add(string.Format(GeneralLangRes.Text_ModlistForVersion, installInfos.Version));
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
using ModpackUpdater.Apps.Manager.Api.Plugins.Params;
|
||||
using ModpackUpdater.Apps.Manager.LangRes;
|
||||
using OfficeOpenXml;
|
||||
using Pilz.Plugins.Advanced;
|
||||
using Telerik.WinControls;
|
||||
using Telerik.WinControls.UI;
|
||||
|
||||
namespace ModpackUpdater.Apps.Manager.Features.Tools;
|
||||
internal class GenerateModlistFeature : PluginFunction, IPluginFeatureProvider<GenerateModlistFeature>
|
||||
internal class GenerateModlistAsExcelFeature : PluginFunction, IPluginFeatureProvider<GenerateModlistAsExcelFeature>
|
||||
{
|
||||
public static GenerateModlistFeature Instance { get; } = new();
|
||||
public static GenerateModlistAsExcelFeature Instance { get; } = new();
|
||||
|
||||
public GenerateModlistFeature() : base(FeatureTypes.Tools, "origin.genmodlist", FeatureNamesLangRes.GenerateModlistFeature)
|
||||
public GenerateModlistAsExcelFeature() : base(FeatureTypes.Tools, "origin.genmodlist.xlsx", FeatureNamesLangRes.GenerateModlistAsExcelFeature)
|
||||
{
|
||||
Icon = AppGlobals.Symbols.GetSvgImage(AppSymbols.list_view, Pilz.UI.Symbols.SymbolSize.Small);
|
||||
}
|
||||
@@ -20,7 +19,7 @@ internal class GenerateModlistFeature : PluginFunction, IPluginFeatureProvider<G
|
||||
if (@params is not MainApiParameters p || p.Api.CurWorkspace?.InstallInfos is null || p.Api.CurWorkspace?.InstallInfos is null)
|
||||
return null;
|
||||
|
||||
using var pkg = SharedFunctions.GenerateModlist(p.Api.CurWorkspace.InstallInfos);
|
||||
using var pkg = SharedFunctions.GenerateModlistAsExcel(p.Api.CurWorkspace.InstallInfos);
|
||||
if (pkg is null)
|
||||
return null;
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
using ModpackUpdater.Apps.Manager.Api.Plugins.Params;
|
||||
using ModpackUpdater.Apps.Manager.LangRes;
|
||||
using Pilz.Plugins.Advanced;
|
||||
using Telerik.WinControls;
|
||||
|
||||
namespace ModpackUpdater.Apps.Manager.Features.Tools;
|
||||
internal class GenerateModlistAsMarkdownFeature : PluginFunction, IPluginFeatureProvider<GenerateModlistAsExcelFeature>
|
||||
{
|
||||
public static GenerateModlistAsExcelFeature Instance { get; } = new();
|
||||
|
||||
public GenerateModlistAsMarkdownFeature() : base(FeatureTypes.Tools, "origin.genmodlist.md", FeatureNamesLangRes.GenerateModlistAsMarkdownFeature)
|
||||
{
|
||||
Icon = AppGlobals.Symbols.GetSvgImage(AppSymbols.list_view, Pilz.UI.Symbols.SymbolSize.Small);
|
||||
}
|
||||
|
||||
protected override object? ExecuteFunction(PluginFunctionParameter? @params)
|
||||
{
|
||||
if (@params is not MainApiParameters p || p.Api.CurWorkspace?.InstallInfos is null || p.Api.CurWorkspace?.InstallInfos is null)
|
||||
return null;
|
||||
|
||||
Clipboard.SetText(SharedFunctions.GenerateModlistAsMarkdown(p.Api.CurWorkspace.InstallInfos));
|
||||
|
||||
RadMessageBox.Show(p.Api.MainWindow, MsgBoxLangRes.ModlistCopiedToClipboard, MsgBoxLangRes.ModlistCopiedToClipboard_Title, MessageBoxButtons.OK, RadMessageIcon.Info);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -106,11 +106,20 @@ namespace ModpackUpdater.Apps.Manager.LangRes {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Generate modlist ähnelt.
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Generate modlist excel file ähnelt.
|
||||
/// </summary>
|
||||
internal static string GenerateModlistFeature {
|
||||
internal static string GenerateModlistAsExcelFeature {
|
||||
get {
|
||||
return ResourceManager.GetString("GenerateModlistFeature", resourceCulture);
|
||||
return ResourceManager.GetString("GenerateModlistAsExcelFeature", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Generate modlist markdown table ähnelt.
|
||||
/// </summary>
|
||||
internal static string GenerateModlistAsMarkdownFeature {
|
||||
get {
|
||||
return ResourceManager.GetString("GenerateModlistAsMarkdownFeature", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -132,8 +132,11 @@
|
||||
<data name="GenerateChangelogFeature" xml:space="preserve">
|
||||
<value>Generate changelog</value>
|
||||
</data>
|
||||
<data name="GenerateModlistFeature" xml:space="preserve">
|
||||
<value>Generate modlist</value>
|
||||
<data name="GenerateModlistAsExcelFeature" xml:space="preserve">
|
||||
<value>Generate modlist excel file</value>
|
||||
</data>
|
||||
<data name="GenerateModlistAsMarkdownFeature" xml:space="preserve">
|
||||
<value>Generate modlist markdown table</value>
|
||||
</data>
|
||||
<data name="GitLabWorkspace" xml:space="preserve">
|
||||
<value>GitLab workspace</value>
|
||||
|
||||
@@ -78,6 +78,24 @@ namespace ModpackUpdater.Apps.Manager.LangRes {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die The modlist has been generated and copied to the clipboard. ähnelt.
|
||||
/// </summary>
|
||||
internal static string ModlistCopiedToClipboard {
|
||||
get {
|
||||
return ResourceManager.GetString("ModlistCopiedToClipboard", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Modlist generated successfully ähnelt.
|
||||
/// </summary>
|
||||
internal static string ModlistCopiedToClipboard_Title {
|
||||
get {
|
||||
return ResourceManager.GetString("ModlistCopiedToClipboard_Title", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die The modlist has been generated successfully and saved to the selected location. ähnelt.
|
||||
/// </summary>
|
||||
|
||||
@@ -123,6 +123,12 @@
|
||||
<data name="ChangelogCopiedToClipboard_Title" xml:space="preserve">
|
||||
<value>Changelog generated successfully</value>
|
||||
</data>
|
||||
<data name="ModlistCopiedToClipboard" xml:space="preserve">
|
||||
<value>The modlist has been generated and copied to the clipboard.</value>
|
||||
</data>
|
||||
<data name="ModlistCopiedToClipboard_Title" xml:space="preserve">
|
||||
<value>Modlist generated successfully</value>
|
||||
</data>
|
||||
<data name="ModlistGenerated" xml:space="preserve">
|
||||
<value>The modlist has been generated successfully and saved to the selected location.</value>
|
||||
</data>
|
||||
|
||||
Reference in New Issue
Block a user