mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 02:26:55 -07:00
BaseUrl is finally finished! #72
This commit is contained in:
parent
47dc543b09
commit
67c968e886
17 changed files with 201 additions and 64 deletions
|
@ -32,12 +32,20 @@ using Nancy.ViewEngines.Razor;
|
|||
|
||||
using PlexRequests.Core;
|
||||
using PlexRequests.Core.SettingModels;
|
||||
using PlexRequests.Helpers;
|
||||
|
||||
namespace PlexRequests.UI.Helpers
|
||||
{
|
||||
public static class BaseUrlHelper
|
||||
{
|
||||
private static ServiceLocator Locator => ServiceLocator.Instance;
|
||||
static BaseUrlHelper()
|
||||
{
|
||||
Locator = ServiceLocator.Instance;
|
||||
Cache = Locator.Resolve<ICacheProvider>();
|
||||
}
|
||||
private static ICacheProvider Cache { get; }
|
||||
private static ServiceLocator Locator { get; }
|
||||
|
||||
public static IHtmlString LoadAssets(this HtmlHelpers helper)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
|
@ -117,6 +125,26 @@ namespace PlexRequests.UI.Helpers
|
|||
returnString = $"<a class=\"list-group-item\" href=\"{url}\">{title}</a>";
|
||||
}
|
||||
|
||||
return helper.Raw(returnString);
|
||||
}
|
||||
|
||||
public static IHtmlString GetNavbarUrl(this HtmlHelpers helper, NancyContext context, string url, string title, string fontIcon)
|
||||
{
|
||||
var returnString = string.Empty;
|
||||
var content = GetLinkUrl(GetBaseUrl());
|
||||
if (!string.IsNullOrEmpty(content))
|
||||
{
|
||||
url = $"/{content}{url}";
|
||||
}
|
||||
if (context.Request.Path == url)
|
||||
{
|
||||
returnString = $"<li class=\"active\"><a href=\"{url}\"><i class=\"fa fa-{fontIcon}\"></i> {title}</a></li>";
|
||||
}
|
||||
else
|
||||
{
|
||||
returnString = $"<li><a href=\"{url}\"><i class=\"fa fa-{fontIcon}\"></i> {title}</a></li>";
|
||||
}
|
||||
|
||||
return helper.Raw(returnString);
|
||||
}
|
||||
|
||||
|
@ -125,11 +153,15 @@ namespace PlexRequests.UI.Helpers
|
|||
return helper.Raw(GetBaseUrl());
|
||||
}
|
||||
|
||||
private static string GetBaseUrl()
|
||||
{
|
||||
var settings = Locator.Resolve<ISettingsService<PlexRequestSettings>>().GetSettings();
|
||||
var assetLocation = settings.BaseUrl;
|
||||
return assetLocation;
|
||||
private static string GetBaseUrl()
|
||||
{
|
||||
var returnValue = Cache.GetOrSet(CacheKeys.GetBaseUrl, () =>
|
||||
{
|
||||
var settings = Locator.Resolve<ISettingsService<PlexRequestSettings>>().GetSettings();
|
||||
var assetLocation = settings.BaseUrl;
|
||||
return assetLocation;
|
||||
});
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
private static string GetLinkUrl(string assetLocation)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue