From ebfcadc862f376f78a0b2552a354901a61d7b55b Mon Sep 17 00:00:00 2001 From: Matthew Strasiotto <39424834+matthewstrasiotto@users.noreply.github.com> Date: Sat, 18 Jun 2022 20:36:29 +1000 Subject: [PATCH] Reduce duplication in adding new views --- SSO-Auth/Api/SSOViewsController.cs | 44 ++++-------------------------- SSO-Auth/SSOPlugin.cs | 10 +++---- 2 files changed, 11 insertions(+), 43 deletions(-) diff --git a/SSO-Auth/Api/SSOViewsController.cs b/SSO-Auth/Api/SSOViewsController.cs index ed2c55c..483cfdc 100644 --- a/SSO-Auth/Api/SSOViewsController.cs +++ b/SSO-Auth/Api/SSOViewsController.cs @@ -90,46 +90,14 @@ public class SSOViewsController : ControllerBase } /// - /// Gets the html view for the linking interface. + /// Gets a html view. /// - /// The html view for the linking interface. + /// The name of the view / asset to fetch. + /// The html view with the specified name. // [Authorize(Policy = "DefaultAuthorization")] - [HttpGet("linking")] - public ActionResult GetLinkingView() + [HttpGet("{viewName}")] + public ActionResult GetView([FromRoute] string viewName) { - return ServeView("SSO-Auth-linking"); - } - - /// - /// Returns the client code for the linking view. - /// - /// The html view for the linking interface. - // [Authorize(Policy = "DefaultAuthorization")] - [HttpGet("linking.js")] - public ActionResult GetLinkingJS() - { - return ServeView("SSO-Auth-linking.js"); - } - - /// - /// Get the shared js module that initializes the ApiClient. - /// - /// Returns the shared js module that initializes the ApiClient. - // [Authorize(Policy = "DefaultAuthorization")] - [HttpGet("ApiClient.js")] - public ActionResult GetApiClientView() - { - return ServeView("SSO-Auth-ApiClient.js"); - } - - /// - /// Returns the css that is usually a part of the default view. - /// - /// A stylesheet. - // [Authorize(Policy = "DefaultAuthorization")] - [HttpGet("emby-restyle.css")] - public ActionResult GetRestyledEmbyElements() - { - return ServeView("SSO-Auth-emby-restyle.css"); + return ServeView(viewName); } } \ No newline at end of file diff --git a/SSO-Auth/SSOPlugin.cs b/SSO-Auth/SSOPlugin.cs index a0e84fc..b6988c4 100644 --- a/SSO-Auth/SSOPlugin.cs +++ b/SSO-Auth/SSOPlugin.cs @@ -85,27 +85,27 @@ public class SSOPlugin : BasePlugin, IPlugin, IHasWebPages { new PluginPageInfo { - Name = Name + ".css", + Name = "style.css", EmbeddedResourcePath = $"{GetType().Namespace}.Config.style.css" }, new PluginPageInfo { - Name = Name + "-linking", + Name = "linking", EmbeddedResourcePath = $"{GetType().Namespace}.Config.linking.html" }, new PluginPageInfo { - Name = Name + "-linking.js", + Name = "linking.js", EmbeddedResourcePath = $"{GetType().Namespace}.Config.linking.js" }, new PluginPageInfo { - Name = Name + "-ApiClient.js", + Name = "ApiClient.js", EmbeddedResourcePath = $"{GetType().Namespace}.Views.apiClient.js" }, new PluginPageInfo { - Name = Name + "-emby-restyle.css", + Name = "emby-restyle.css", EmbeddedResourcePath = $"{GetType().Namespace}.Views.emby-restyle.css" }, };