diff --git a/PlexRequests.UI/Content/site.js b/PlexRequests.UI/Content/site.js
index e2784b315..e08d5835d 100644
--- a/PlexRequests.UI/Content/site.js
+++ b/PlexRequests.UI/Content/site.js
@@ -62,6 +62,17 @@ function finishLoading(elementId, originalCss, html) {
}
}
+function createBaseUrl(base, url) {
+ if (base) {
+ if (url.charAt(0) === "/") {
+ url = "/" + base + url;
+ } else {
+ url = "/" + base + "/" + url;
+ }
+ }
+ return url;
+}
+
var noResultsHtml = "
" +
"
Sorry, we didn't find any results!
";
var noResultsMusic = "" +
diff --git a/PlexRequests.UI/Helpers/AssetHelper.cs b/PlexRequests.UI/Helpers/BaseUrlHelper.cs
similarity index 76%
rename from PlexRequests.UI/Helpers/AssetHelper.cs
rename to PlexRequests.UI/Helpers/BaseUrlHelper.cs
index 66aa2e48d..ddeb1fb7b 100644
--- a/PlexRequests.UI/Helpers/AssetHelper.cs
+++ b/PlexRequests.UI/Helpers/BaseUrlHelper.cs
@@ -1,7 +1,7 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
-// File: AssetHelper.cs
+// File: BaseUrlHelper.cs
// Created By: Jamie Rees
//
// Permission is hereby granted, free of charge, to any person obtaining
@@ -24,8 +24,10 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ************************************************************************/
#endregion
-using System.Text;
+using System.IO;
+using System.Text;
+using Nancy;
using Nancy.ViewEngines.Razor;
using PlexRequests.Core;
@@ -33,14 +35,13 @@ using PlexRequests.Core.SettingModels;
namespace PlexRequests.UI.Helpers
{
- public static class AssetHelper
+ public static class BaseUrlHelper
{
private static ServiceLocator Locator => ServiceLocator.Instance;
public static IHtmlString LoadAssets(this HtmlHelpers helper)
{
- var settings = Locator.Resolve
>().GetSettings();
var sb = new StringBuilder();
- var assetLocation = settings.BaseUrl;
+ var assetLocation = GetBaseUrl();
var content = GetContentUrl(assetLocation);
@@ -64,9 +65,8 @@ namespace PlexRequests.UI.Helpers
public static IHtmlString LoadSearchAssets(this HtmlHelpers helper)
{
- var settings = Locator.Resolve>().GetSettings();
var sb = new StringBuilder();
- var assetLocation = settings.BaseUrl;
+ var assetLocation = GetBaseUrl();
var content = GetContentUrl(assetLocation);
@@ -77,9 +77,8 @@ namespace PlexRequests.UI.Helpers
public static IHtmlString LoadRequestAssets(this HtmlHelpers helper)
{
- var settings = Locator.Resolve>().GetSettings();
var sb = new StringBuilder();
- var assetLocation = settings.BaseUrl;
+ var assetLocation = GetBaseUrl();
var content = GetContentUrl(assetLocation);
@@ -90,9 +89,8 @@ namespace PlexRequests.UI.Helpers
public static IHtmlString LoadLogsAssets(this HtmlHelpers helper)
{
- var settings = Locator.Resolve>().GetSettings();
var sb = new StringBuilder();
- var assetLocation = settings.BaseUrl;
+ var assetLocation = GetBaseUrl();
var content = GetContentUrl(assetLocation);
@@ -101,10 +99,46 @@ namespace PlexRequests.UI.Helpers
return helper.Raw(sb.ToString());
}
-
- private static string GetContentUrl(string assetLocation)
+
+ public static IHtmlString GetSidebarUrl(this HtmlHelpers helper, NancyContext context, string url, string title)
{
- return string.IsNullOrEmpty(assetLocation) ? string.Empty : $"/{assetLocation}";
+ var returnString = string.Empty;
+ var content = GetLinkUrl(GetBaseUrl());
+ if (!string.IsNullOrEmpty(content))
+ {
+ url = $"/{content}{url}";
+ }
+ if (context.Request.Path == url)
+ {
+ returnString = $"{title}";
+ }
+ else
+ {
+ returnString = $"{title}";
+ }
+
+ return helper.Raw(returnString);
+ }
+
+ public static IHtmlString GetBaseUrl(this HtmlHelpers helper)
+ {
+ return helper.Raw(GetBaseUrl());
+ }
+
+ private static string GetBaseUrl()
+ {
+ var settings = Locator.Resolve>().GetSettings();
+ var assetLocation = settings.BaseUrl;
+ return assetLocation;
+ }
+
+ private static string GetLinkUrl(string assetLocation)
+ {
+ return string.IsNullOrEmpty(assetLocation) ? string.Empty : $"{assetLocation}";
+ }
+ private static string GetContentUrl(string assetLocation)
+ {
+ return string.IsNullOrEmpty(assetLocation) ? string.Empty : $"/{assetLocation}";
}
}
}
\ No newline at end of file
diff --git a/PlexRequests.UI/PlexRequests.UI.csproj b/PlexRequests.UI/PlexRequests.UI.csproj
index ec156d653..93a345ed1 100644
--- a/PlexRequests.UI/PlexRequests.UI.csproj
+++ b/PlexRequests.UI/PlexRequests.UI.csproj
@@ -164,7 +164,7 @@
-
+
diff --git a/PlexRequests.UI/Views/Admin/Authentication.cshtml b/PlexRequests.UI/Views/Admin/Authentication.cshtml
index a703431b8..da2cea63f 100644
--- a/PlexRequests.UI/Views/Admin/Authentication.cshtml
+++ b/PlexRequests.UI/Views/Admin/Authentication.cshtml
@@ -1,7 +1,16 @@
-@Html.Partial("_Sidebar")
-
+@using PlexRequests.UI.Helpers
+@Html.Partial("_Sidebar")
+
+@{
+ var baseUrl = Html.GetBaseUrl();
+ var formAction = "/admin/authentication";
+ if (!string.IsNullOrEmpty(baseUrl.ToHtmlString()))
+ {
+ formAction = "/" + baseUrl.ToHtmlString() + formAction;
+ }
+}
-