From 344c3613b87aa5057d00ca5f8c76593e1854676b Mon Sep 17 00:00:00 2001 From: RaidMax Date: Sat, 28 Dec 2019 20:44:39 -0600 Subject: [PATCH] add help page to layout --- WebfrontCore/Controllers/HomeController.cs | 19 ++++++ WebfrontCore/Startup.cs | 2 +- WebfrontCore/Views/Home/Help.cshtml | 75 ++++++++++++++++++++++ WebfrontCore/Views/Shared/_Layout.cshtml | 39 +++++------ WebfrontCore/WebfrontCore.csproj | 1 + 5 files changed, 116 insertions(+), 20 deletions(-) create mode 100644 WebfrontCore/Views/Home/Help.cshtml diff --git a/WebfrontCore/Controllers/HomeController.cs b/WebfrontCore/Controllers/HomeController.cs index 621a7a06d..35674695d 100644 --- a/WebfrontCore/Controllers/HomeController.cs +++ b/WebfrontCore/Controllers/HomeController.cs @@ -48,5 +48,24 @@ namespace WebfrontCore.Controllers { return View(statusCode); } + + public IActionResult Help() + { + ViewBag.IsFluid = true; + var excludedAssembly = typeof(BaseController).Assembly; + var commands = Manager.GetCommands() + .OrderByDescending(_cmd => _cmd.Permission) + .GroupBy(_cmd => + { + + var pluginType = _cmd.GetType().Assembly.GetTypes().FirstOrDefault(_type => _type.Assembly != excludedAssembly && typeof(IPlugin).IsAssignableFrom(_type)); + return pluginType == null ? + Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_HELP_COMMAND_NATIVE"] : + SharedLibraryCore.Plugins.PluginImporter.ActivePlugins.First(_plugin => _plugin.GetType() == pluginType).Name; + }) + .Select(_grp => (_grp.Key, _grp.AsEnumerable())); + + return View(commands); + } } } diff --git a/WebfrontCore/Startup.cs b/WebfrontCore/Startup.cs index 0d7abb765..04e769815 100644 --- a/WebfrontCore/Startup.cs +++ b/WebfrontCore/Startup.cs @@ -58,7 +58,7 @@ namespace WebfrontCore }); #if DEBUG - //mvcBuilder = mvcBuilder.AddRazorRuntimeCompilation(); + mvcBuilder = mvcBuilder.AddRazorRuntimeCompilation(); services.Configure(_options => { _options.ViewLocationFormats.Add(@"/Views/Plugins/{1}/{0}" + RazorViewEngine.ViewExtension); diff --git a/WebfrontCore/Views/Home/Help.cshtml b/WebfrontCore/Views/Home/Help.cshtml new file mode 100644 index 000000000..9270fcf37 --- /dev/null +++ b/WebfrontCore/Views/Home/Help.cshtml @@ -0,0 +1,75 @@ +@model IEnumerable<(string, IEnumerable)> +@{ + var loc = SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex; +} +@foreach ((var pluginName, var commandList) in Model) +{ +

@pluginName

+ + + + + + + + + + + + + + + @foreach (var command in commandList) + { + + + + + + + + + } + +
@loc["WEBFRONT_HELP_COMMAND_DESC_NAME"]@loc["WEBFRONT_HELP_COMMAND_DESC_ALIAS"]@loc["WEBFRONT_HELP_COMMAND_DESC_DESCRIPTION"]@loc["WEBFRONT_HELP_COMMAND_DESC_REQUIRES_TARGET"]@loc["WEBFRONT_HELP_COMMAND_DESC_SYNTAX"]@loc["WEBFRONT_HELP_COMMAND_DESC_REQUIRED_LEVEL"]
@command.Name@command.Alias@command.Description@command.RequiresTarget!@command.Syntax.Split('!')[1]@command.Permission.ToLocalizedLevelName()
+ + + + + + + + + + + @foreach (var command in commandList) + { + + + + + + + + + + + + + + + + + + + + + + + + + } + +
@loc["WEBFRONT_HELP_COMMAND_DESC_NAME"]@command.Name
@loc["WEBFRONT_HELP_COMMAND_DESC_ALIAS"]@command.Alias
@loc["WEBFRONT_HELP_COMMAND_DESC_DESCRIPTION"]@command.Description
@loc["WEBFRONT_HELP_COMMAND_DESC_REQUIRES_TARGET"]@command.RequiresTarget
@loc["WEBFRONT_HELP_COMMAND_DESC_SYNTAX"]!@command.Syntax.Split('!')[1]
@loc["WEBFRONT_HELP_COMMAND_DESC_REQUIRED_LEVEL"]@command.Permission.ToLocalizedLevelName()
+} +} \ No newline at end of file diff --git a/WebfrontCore/Views/Shared/_Layout.cshtml b/WebfrontCore/Views/Shared/_Layout.cshtml index 0fb28aede..e8f07b5af 100644 --- a/WebfrontCore/Views/Shared/_Layout.cshtml +++ b/WebfrontCore/Views/Shared/_Layout.cshtml @@ -36,40 +36,41 @@ + @foreach (var _page in ViewBag.Pages) { - + } @if (!string.IsNullOrEmpty(ViewBag.SocialLink)) { - + } @if (ViewBag.Authorized) { - + @loc["WEBFRONT_ACTION_RECENT_CLIENTS"] + @loc["WEBFRONT_ACTION_TOKEN"] + @loc["WEBFRONT_NAV_LOGOUT"] + + } else { - + }
diff --git a/WebfrontCore/WebfrontCore.csproj b/WebfrontCore/WebfrontCore.csproj index 065701c71..29e977675 100644 --- a/WebfrontCore/WebfrontCore.csproj +++ b/WebfrontCore/WebfrontCore.csproj @@ -66,6 +66,7 @@ +