From 7fb9c79269bbbc8afa96fa6f7bb2bf1f19389fd7 Mon Sep 17 00:00:00 2001 From: feos Date: Tue, 26 Sep 2023 19:45:39 +0300 Subject: [PATCH] add avs, bat, and sh to previewable usefiles we'll be relying on shipping official scripts for different things (mostly pcem), and previewing them makes it transparent for the users what they're downloading. also added prism name fix for wiki by copying the file from forum engine. doesn't feel right tho. --- TASVideos.WikiEngine/NewParser.cs | 2 +- TASVideos.WikiEngine/PrismNames.cs | 15 +++++++++++++++ TASVideos/Pages/UserFiles/Info.cshtml.cs | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 TASVideos.WikiEngine/PrismNames.cs diff --git a/TASVideos.WikiEngine/NewParser.cs b/TASVideos.WikiEngine/NewParser.cs index 2d3909db9..3c1c0c1e1 100644 --- a/TASVideos.WikiEngine/NewParser.cs +++ b/TASVideos.WikiEngine/NewParser.cs @@ -884,7 +884,7 @@ private void ParseStartLine() var e = new Element(_index, "code"); if (lang != "") { - e.Attributes["class"] = "language-" + lang; + e.Attributes["class"] = "language-" + PrismNames.FixLanguage(lang); } e.Children.Add(new Text(_index, EatSrcEmbedText()) { CharEnd = _index }); diff --git a/TASVideos.WikiEngine/PrismNames.cs b/TASVideos.WikiEngine/PrismNames.cs new file mode 100644 index 000000000..97a3eecac --- /dev/null +++ b/TASVideos.WikiEngine/PrismNames.cs @@ -0,0 +1,15 @@ +namespace TASVideos.WikiEngine; + +public static class PrismNames +{ + public static string FixLanguage(string s) + { + return s switch + { + "bat" => "batch", + "sh" => "shell", + "c++" => "cpp", + _ => s + }; + } +} diff --git a/TASVideos/Pages/UserFiles/Info.cshtml.cs b/TASVideos/Pages/UserFiles/Info.cshtml.cs index cb4dd6c1b..b567dd091 100644 --- a/TASVideos/Pages/UserFiles/Info.cshtml.cs +++ b/TASVideos/Pages/UserFiles/Info.cshtml.cs @@ -11,7 +11,7 @@ namespace TASVideos.Pages.UserFiles; [AllowAnonymous] public class InfoModel : BasePageModel { - private static readonly string[] PreviewableExtensions = { "wch", "lua" }; + private static readonly string[] PreviewableExtensions = { "avs", "bat", "lua", "sh", "wch" }; private readonly ApplicationDbContext _db; private readonly IFileService _fileService;