Remove wiki functionality
This commit is contained in:
parent
131479277b
commit
052d8f1c8e
7 changed files with 0 additions and 281 deletions
|
|
@ -38,7 +38,6 @@
|
|||
<PackageReference Include="CoreRCON" Version="5.0.5" />
|
||||
<PackageReference Include="craftersmine.SteamGridDB.Net" Version="1.1.6" />
|
||||
<PackageReference Include="Crc32.NET" Version="1.2.0" />
|
||||
<PackageReference Include="CXuesong.MW.WikiClientLibrary" Version="0.8.0" />
|
||||
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.14" />
|
||||
<PackageReference Include="Hangfire.Core" Version="1.8.14" />
|
||||
<PackageReference Include="Hangfire.InMemory" Version="0.10.3" />
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ namespace LANCommander.Server.Models
|
|||
public LANCommanderMediaSettings Media { get; set; } = new LANCommanderMediaSettings();
|
||||
public LANCommanderIPXRelaySettings IPXRelay { get; set; } = new LANCommanderIPXRelaySettings();
|
||||
public LANCommanderServerSettings Servers { get; set; } = new LANCommanderServerSettings();
|
||||
public LANCommanderWikiSettings Wiki { get; set; } = new LANCommanderWikiSettings();
|
||||
public LANCommanderUpdateSettings Update { get; set; } = new LANCommanderUpdateSettings();
|
||||
public LANCommanderLauncherSettings Launcher { get; set; } = new LANCommanderLauncherSettings();
|
||||
public LANCommanderLogSettings Logs { get; set; } = new LANCommanderLogSettings();
|
||||
|
|
@ -98,13 +97,6 @@ namespace LANCommander.Server.Models
|
|||
public string StoragePath { get; set; } = "Servers";
|
||||
}
|
||||
|
||||
public class LANCommanderWikiSettings
|
||||
{
|
||||
public bool Enabled { get; set; } = false;
|
||||
public string Username { get; set; } = "";
|
||||
public string Password { get; set; } = "";
|
||||
}
|
||||
|
||||
public class LANCommanderUpdateSettings
|
||||
{
|
||||
public string StoragePath { get; set; } = "Updates";
|
||||
|
|
|
|||
|
|
@ -188,7 +188,6 @@ namespace LANCommander.Server
|
|||
builder.Services.AddScoped<MediaService>();
|
||||
builder.Services.AddScoped<RedistributableService>();
|
||||
builder.Services.AddScoped<IMediaGrabberService, SteamGridDBMediaGrabber>();
|
||||
builder.Services.AddScoped<WikiService>();
|
||||
builder.Services.AddScoped<UpdateService>();
|
||||
builder.Services.AddScoped<IssueService>();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,94 +0,0 @@
|
|||
using LANCommander.Server.Data.Models;
|
||||
using LANCommander.PCGamingWiki;
|
||||
using Razor.Templating.Core;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using WikiClientLibrary.Client;
|
||||
using WikiClientLibrary.Pages;
|
||||
using WikiClientLibrary.Sites;
|
||||
|
||||
namespace LANCommander.Server.Services
|
||||
{
|
||||
public class WikiService : IDisposable
|
||||
{
|
||||
private GameService GameService;
|
||||
private RedistributableService RedistributableService;
|
||||
private WikiClient WikiClient;
|
||||
private WikiSite WikiSite;
|
||||
|
||||
public WikiService(GameService gameService, RedistributableService redistributableService)
|
||||
{
|
||||
GameService = gameService;
|
||||
RedistributableService = redistributableService;
|
||||
WikiClient = new WikiClient();
|
||||
}
|
||||
|
||||
public async Task AuthenticateAsync(string username, string password)
|
||||
{
|
||||
WikiSite = new WikiSite(WikiClient, "https://lancommander.app/api.php");
|
||||
|
||||
await WikiSite.Initialization;
|
||||
|
||||
await WikiSite.LoginAsync(username, password);
|
||||
}
|
||||
|
||||
public async Task<WikiPage> GetPage(Game game)
|
||||
{
|
||||
var page = new WikiPage(WikiSite, game.Title);
|
||||
|
||||
await page.RefreshAsync(PageQueryOptions.FetchContent);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
public async Task<WikiPage> GetPage(Redistributable redistributable)
|
||||
{
|
||||
var page = new WikiPage(WikiSite, redistributable.Name);
|
||||
|
||||
await page.RefreshAsync(PageQueryOptions.FetchContent);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
public async Task PublishPage(WikiPage page, string summary, bool minor = false)
|
||||
{
|
||||
await page.UpdateContentAsync(summary, minor);
|
||||
}
|
||||
|
||||
public string GetUrl(WikiPage page)
|
||||
{
|
||||
if (page == null)
|
||||
return "";
|
||||
|
||||
return $"https://lancommander.app/index.php/{page.PageStub.Title}";
|
||||
}
|
||||
|
||||
public async Task<string> GenerateRedistributablePage(Guid id)
|
||||
{
|
||||
var redistributable = await RedistributableService.Get(id);
|
||||
|
||||
var result = await RazorTemplateEngine.RenderAsync("~/Templates/Wiki/Redistributable.cshtml", redistributable);
|
||||
|
||||
return result.Trim();
|
||||
}
|
||||
|
||||
public async Task<string> GenerateGamePage(Guid id)
|
||||
{
|
||||
var game = await GameService.Get(id);
|
||||
|
||||
var result = await RazorTemplateEngine.RenderAsync("~/Templates/Wiki/Game.cshtml", game);
|
||||
|
||||
return result.Trim();
|
||||
}
|
||||
|
||||
public async void Dispose()
|
||||
{
|
||||
try
|
||||
{
|
||||
await WikiSite.LogoutAsync();
|
||||
WikiClient.Dispose();
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,153 +0,0 @@
|
|||
@using LANCommander.Server.Models
|
||||
@using System.ComponentModel.DataAnnotations
|
||||
@using WikiClientLibrary.Pages
|
||||
@inject GameService GameService
|
||||
@inject RedistributableService RedistributableService
|
||||
@inject WikiService WikiService
|
||||
@inject IMessageService MessageService
|
||||
@inject IJSRuntime JS
|
||||
@inject ILogger<WikiEditor> Logger
|
||||
|
||||
<Spin Spinning="@Loading">
|
||||
<Space Direction="DirectionVHType.Vertical" Size="@("large")" Style="width: 100%">
|
||||
<SpaceItem>
|
||||
<StandaloneDiffEditor @ref="DiffEditor" Id="wiki-diff" ConstructionOptions="DiffEditorConstructionOptions" OnDidInit="LoadDiff" />
|
||||
</SpaceItem>
|
||||
|
||||
<SpaceItem>
|
||||
<Form Model="Changes">
|
||||
<FormItem Label="Minor">
|
||||
<Checkbox @bind-Value="context.Minor" />
|
||||
</FormItem>
|
||||
<FormItem Label="Summary">
|
||||
<TextArea @bind-Value="context.Summary" />
|
||||
</FormItem>
|
||||
</Form>
|
||||
</SpaceItem>
|
||||
|
||||
<SpaceItem>
|
||||
<GridRow Justify="end">
|
||||
<GridCol>
|
||||
<Space Direction="@DirectionVHType.Horizontal">
|
||||
<SpaceItem>
|
||||
<a href="@WikiService.GetUrl(Page)" target="_blank" class="ant-btn ant-btn-default">View</a>
|
||||
</SpaceItem>
|
||||
<SpaceItem>
|
||||
<Button OnClick="Publish" Type="@ButtonType.Primary" Disabled="@(OriginalContents == ModifiedContents)">Publish</Button>
|
||||
</SpaceItem>
|
||||
</Space>
|
||||
</GridCol>
|
||||
</GridRow>
|
||||
</SpaceItem>
|
||||
</Space>
|
||||
</Spin>
|
||||
|
||||
@code {
|
||||
[Parameter] public Guid GameId { get; set; }
|
||||
[Parameter] public Guid RedistributableId { get; set; }
|
||||
|
||||
LANCommanderSettings Settings = SettingService.GetSettings();
|
||||
|
||||
bool Loading = true;
|
||||
bool Authenticated = false;
|
||||
|
||||
bool Minor = false;
|
||||
string Summary = "";
|
||||
|
||||
string OriginalContents = "";
|
||||
string ModifiedContents = "";
|
||||
|
||||
StandaloneDiffEditor DiffEditor;
|
||||
Game Game;
|
||||
Redistributable Redistributable;
|
||||
WikiPage Page;
|
||||
WikiPageChanges Changes = new WikiPageChanges();
|
||||
|
||||
StandaloneDiffEditorConstructionOptions DiffEditorConstructionOptions(StandaloneDiffEditor editor)
|
||||
{
|
||||
return new StandaloneDiffEditorConstructionOptions
|
||||
{
|
||||
OriginalEditable = true,
|
||||
AutomaticLayout = true,
|
||||
Theme = "vs-dark",
|
||||
};
|
||||
}
|
||||
|
||||
class WikiPageChanges
|
||||
{
|
||||
public bool Minor { get; set; } = false;
|
||||
[Required]
|
||||
public string Summary { get; set; } = "";
|
||||
}
|
||||
|
||||
async Task LoadDiff()
|
||||
{
|
||||
try
|
||||
{
|
||||
await WikiService.AuthenticateAsync(Settings.Wiki.Username, Settings.Wiki.Password);
|
||||
|
||||
if (GameId != Guid.Empty)
|
||||
{
|
||||
Game = await GameService.Get(GameId);
|
||||
Page = await WikiService.GetPage(Game);
|
||||
|
||||
ModifiedContents = await WikiService.GenerateGamePage(Game.Id);
|
||||
}
|
||||
else if (RedistributableId != Guid.Empty)
|
||||
{
|
||||
Redistributable = await RedistributableService.Get(RedistributableId);
|
||||
Page = await WikiService.GetPage(Redistributable);
|
||||
|
||||
ModifiedContents = await WikiService.GenerateRedistributablePage(Redistributable.Id);
|
||||
}
|
||||
|
||||
OriginalContents = Page.Content;
|
||||
|
||||
if (!Page.Exists)
|
||||
Changes.Summary = $"Created new page for {Game.Title}";
|
||||
|
||||
Authenticated = true;
|
||||
|
||||
TextModel originalModel = await BlazorMonaco.Editor.Global.CreateModel(JS, OriginalContents, "plaintext", "sample-diff-editor-originalModel");
|
||||
TextModel modifiedModel = await BlazorMonaco.Editor.Global.CreateModel(JS, ModifiedContents, "plaintext", "sample-diff-editor-modifiedModel");
|
||||
|
||||
await DiffEditor.SetModel(new DiffEditorModel
|
||||
{
|
||||
Original = originalModel,
|
||||
Modified = modifiedModel
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageService.Error("Wiki initialization failed!");
|
||||
Logger.LogError(ex, "Wiki initialization failed!");
|
||||
}
|
||||
finally
|
||||
{
|
||||
Loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
async Task Publish()
|
||||
{
|
||||
try
|
||||
{
|
||||
Loading = true;
|
||||
|
||||
Page.Content = ModifiedContents;
|
||||
|
||||
await WikiService.PublishPage(Page, Changes.Summary, Changes.Minor);
|
||||
|
||||
MessageService.Success("Changes published!");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageService.Error("Could not publish changes!");
|
||||
Logger.LogError(ex, "Could not publish changes!");
|
||||
}
|
||||
finally
|
||||
{
|
||||
Loading = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -59,11 +59,6 @@
|
|||
{
|
||||
<MenuItem RouterLink="@($"/Games/{Game.Id}/Saves")">Saves</MenuItem>
|
||||
}
|
||||
|
||||
if (Settings.Wiki.Enabled)
|
||||
{
|
||||
<MenuItem RouterLink="@($"/Games/{Game.Id}/Wiki")">Wiki</MenuItem>
|
||||
}
|
||||
}
|
||||
</Menu>
|
||||
</Sider>
|
||||
|
|
@ -323,13 +318,6 @@
|
|||
</ActionColumn>
|
||||
</Table>
|
||||
</div>
|
||||
|
||||
@if (Settings.Wiki.Enabled)
|
||||
{
|
||||
<div data-panel="Wiki">
|
||||
<WikiEditor GameId="Game.Id" />
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -18,11 +18,6 @@
|
|||
{
|
||||
<MenuItem RouterLink="@($"/Redistributables/{Redistributable.Id}/Scripts")">Scripts</MenuItem>
|
||||
<MenuItem RouterLink="@($"/Redistributables/{Redistributable.Id}/Archives")">Archives</MenuItem>
|
||||
|
||||
if (Settings.Wiki.Enabled)
|
||||
{
|
||||
<MenuItem RouterLink="@($"/Redistributables/{Redistributable.Id}/Wiki")">Wiki</MenuItem>
|
||||
}
|
||||
}
|
||||
</Menu>
|
||||
</Sider>
|
||||
|
|
@ -79,13 +74,6 @@
|
|||
<div data-panel="Archives">
|
||||
<ArchiveEditor RedistributableId="Redistributable.Id" />
|
||||
</div>
|
||||
|
||||
@if (Settings.Wiki.Enabled)
|
||||
{
|
||||
<div data-panel="Wiki">
|
||||
<WikiEditor RedistributableId="Redistributable.Id" />
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</Content>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue