add option to toggle about page/make some checks on displayed rules
This commit is contained in:
parent
3916278422
commit
74bb3da459
@ -12,6 +12,7 @@ using System.Security.Claims;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Data.Context;
|
using Data.Context;
|
||||||
using Data.Models;
|
using Data.Models;
|
||||||
|
using SharedLibraryCore.Configuration;
|
||||||
|
|
||||||
namespace SharedLibraryCore
|
namespace SharedLibraryCore
|
||||||
{
|
{
|
||||||
@ -31,22 +32,21 @@ namespace SharedLibraryCore
|
|||||||
private static string SocialLink;
|
private static string SocialLink;
|
||||||
private static string SocialTitle;
|
private static string SocialTitle;
|
||||||
protected List<Page> Pages;
|
protected List<Page> Pages;
|
||||||
|
protected ApplicationConfiguration AppConfig { get; }
|
||||||
|
|
||||||
public BaseController(IManager manager)
|
public BaseController(IManager manager)
|
||||||
{
|
{
|
||||||
Manager = manager;
|
Manager = manager;
|
||||||
|
Localization ??= Utilities.CurrentLocalization.LocalizationIndex;
|
||||||
|
AppConfig = Manager.GetApplicationSettings().Configuration();
|
||||||
|
|
||||||
if (Localization == null)
|
if (AppConfig.EnableSocialLink && SocialLink == null)
|
||||||
{
|
{
|
||||||
Localization = Utilities.CurrentLocalization.LocalizationIndex;
|
SocialLink = AppConfig.SocialLinkAddress;
|
||||||
}
|
SocialTitle = AppConfig.SocialLinkTitle;
|
||||||
|
|
||||||
if (Manager.GetApplicationSettings().Configuration().EnableSocialLink && SocialLink == null)
|
|
||||||
{
|
|
||||||
SocialLink = Manager.GetApplicationSettings().Configuration().SocialLinkAddress;
|
|
||||||
SocialTitle = Manager.GetApplicationSettings().Configuration().SocialLinkTitle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Pages = Manager.GetPageList().Pages
|
Pages = Manager.GetPageList().Pages
|
||||||
.Select(page => new Page
|
.Select(page => new Page
|
||||||
{
|
{
|
||||||
@ -56,7 +56,7 @@ namespace SharedLibraryCore
|
|||||||
|
|
||||||
ViewBag.Version = Manager.Version;
|
ViewBag.Version = Manager.Version;
|
||||||
ViewBag.IsFluid = false;
|
ViewBag.IsFluid = false;
|
||||||
ViewBag.EnableColorCodes = Manager.GetApplicationSettings().Configuration().EnableColorCodes;
|
ViewBag.EnableColorCodes = AppConfig.EnableColorCodes;
|
||||||
ViewBag.Language = Utilities.CurrentLocalization.Culture.TwoLetterISOLanguageName;
|
ViewBag.Language = Utilities.CurrentLocalization.Culture.TwoLetterISOLanguageName;
|
||||||
|
|
||||||
Client ??= new EFClient()
|
Client ??= new EFClient()
|
||||||
@ -126,11 +126,13 @@ namespace SharedLibraryCore
|
|||||||
SignInAsync(new ClaimsPrincipal(claimsIdentity)).Wait();
|
SignInAsync(new ClaimsPrincipal(claimsIdentity)).Wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
var communityName = Manager.GetApplicationSettings().Configuration().CommunityInformation?.Name;
|
var communityName = AppConfig.CommunityInformation?.Name;
|
||||||
var shouldUseCommunityName = !string.IsNullOrWhiteSpace(communityName) && !communityName.Contains("IW4MAdmin");
|
var shouldUseCommunityName = !string.IsNullOrWhiteSpace(communityName)
|
||||||
|
&& !communityName.Contains("IW4MAdmin")
|
||||||
|
&& AppConfig.CommunityInformation.IsEnabled;
|
||||||
|
|
||||||
ViewBag.Authorized = Authorized;
|
ViewBag.Authorized = Authorized;
|
||||||
ViewBag.Url = Manager.GetApplicationSettings().Configuration().WebfrontUrl;
|
ViewBag.Url = AppConfig.WebfrontUrl;
|
||||||
ViewBag.User = Client;
|
ViewBag.User = Client;
|
||||||
ViewBag.Version = Manager.Version;
|
ViewBag.Version = Manager.Version;
|
||||||
ViewBag.SocialLink = SocialLink ?? "";
|
ViewBag.SocialLink = SocialLink ?? "";
|
||||||
@ -139,9 +141,10 @@ namespace SharedLibraryCore
|
|||||||
ViewBag.Localization = Utilities.CurrentLocalization.LocalizationIndex;
|
ViewBag.Localization = Utilities.CurrentLocalization.LocalizationIndex;
|
||||||
ViewBag.CustomBranding = shouldUseCommunityName
|
ViewBag.CustomBranding = shouldUseCommunityName
|
||||||
? communityName
|
? communityName
|
||||||
: Manager.GetApplicationSettings().Configuration().WebfrontCustomBranding ?? "IW4MAdmin";
|
: AppConfig.WebfrontCustomBranding ?? "IW4MAdmin";
|
||||||
ViewBag.EnableColorCodes = Manager.GetApplicationSettings().Configuration().EnableColorCodes;
|
ViewBag.EnableColorCodes = AppConfig.EnableColorCodes;
|
||||||
ViewBag.EnablePrivilegedUserPrivacy = Manager.GetApplicationSettings().Configuration().EnablePrivilegedUserPrivacy;
|
ViewBag.EnablePrivilegedUserPrivacy = AppConfig.EnablePrivilegedUserPrivacy;
|
||||||
|
ViewBag.Configuration = AppConfig;
|
||||||
|
|
||||||
base.OnActionExecuting(context);
|
base.OnActionExecuting(context);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
namespace SharedLibraryCore.Configuration
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace SharedLibraryCore.Configuration
|
||||||
{
|
{
|
||||||
public class CommunityInformationConfiguration
|
public class CommunityInformationConfiguration
|
||||||
{
|
{
|
||||||
@ -28,6 +30,8 @@
|
|||||||
IconUrl = "https://raw.githubusercontent.com/edent/SuperTinyIcons/master/images/svg/youtube.svg"
|
IconUrl = "https://raw.githubusercontent.com/edent/SuperTinyIcons/master/images/svg/youtube.svg"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public bool IsEnabled { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SocialAccountConfiguration
|
public class SocialAccountConfiguration
|
||||||
|
@ -5,6 +5,7 @@ namespace WebfrontCore.Extensions
|
|||||||
public static class WebfrontExtensions
|
public static class WebfrontExtensions
|
||||||
{
|
{
|
||||||
public static bool ShouldUseFallbackBranding(this ApplicationConfiguration appConfig) =>
|
public static bool ShouldUseFallbackBranding(this ApplicationConfiguration appConfig) =>
|
||||||
string.IsNullOrWhiteSpace(appConfig?.CommunityInformation?.Name) || appConfig.CommunityInformation.Name.Contains("IW4MAdmin");
|
string.IsNullOrWhiteSpace(appConfig?.CommunityInformation?.Name) ||
|
||||||
|
appConfig.CommunityInformation.Name.Contains("IW4MAdmin") || !appConfig.CommunityInformation.IsEnabled;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,12 @@
|
|||||||
@model WebfrontCore.ViewModels.CommunityInfo
|
@using SharedLibraryCore.Configuration
|
||||||
|
@model WebfrontCore.ViewModels.CommunityInfo
|
||||||
@{
|
@{
|
||||||
var allRules = Model.ServerRules.Prepend(new KeyValuePair<string, string[]>(ViewBag.Localization["WEBFRONT_ABOUT_GLOBAL_RULES"], Model.GlobalRules));
|
IEnumerable<KeyValuePair<string, string[]>> allRules = new []{new KeyValuePair<string, string[]>(ViewBag.Localization["WEBFRONT_ABOUT_GLOBAL_RULES"], Model.GlobalRules)};
|
||||||
|
var serverRules = Model.ServerRules?.Where(server => server.Value != null && server.Value.Any()).ToList();
|
||||||
|
if (serverRules?.Any() ?? false)
|
||||||
|
{
|
||||||
|
allRules = allRules.Union(serverRules);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@ -22,7 +28,7 @@
|
|||||||
<h4 class="text-primary">@ViewBag.Localization["WEBFRONT_ABOUT_TITLE"]</h4>
|
<h4 class="text-primary">@ViewBag.Localization["WEBFRONT_ABOUT_TITLE"]</h4>
|
||||||
<color-code value="@Model.CommunityInformation.Description" allow="@ViewBag.EnableColorCodes"></color-code>
|
<color-code value="@Model.CommunityInformation.Description" allow="@ViewBag.EnableColorCodes"></color-code>
|
||||||
<div class="mt-3">
|
<div class="mt-3">
|
||||||
@foreach (var social in Model.CommunityInformation.SocialAccounts)
|
@foreach (var social in Model.CommunityInformation.SocialAccounts ?? new SocialAccountConfiguration[0])
|
||||||
{
|
{
|
||||||
<div>
|
<div>
|
||||||
<a href="@social.Url" target="_blank" title="@social.Title">
|
<a href="@social.Url" target="_blank" title="@social.Title">
|
||||||
@ -43,11 +49,14 @@
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
<h2 class="pb-3 ml-auto mr-auto ml-md-0">@ViewBag.Localization["WEBFRONT_ABOUT_COMMUNITY_GUIDELINES"]</h2>
|
@if (allRules.Any(rule => rule.Value.Any()))
|
||||||
|
{
|
||||||
|
<h2 class="pb-3 ml-auto mr-auto ml-md-0">@ViewBag.Localization["WEBFRONT_ABOUT_COMMUNITY_GUIDELINES"]</h2>
|
||||||
|
}
|
||||||
|
|
||||||
@foreach (var (serverName, rules) in allRules)
|
@foreach (var (serverName, rules) in allRules)
|
||||||
{
|
{
|
||||||
if (rules?.Length == 0)
|
if (!rules.Any())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -37,8 +37,11 @@
|
|||||||
<li class="nav-item d-none d-lg-inline-block d-xl-none">@Html.ActionLink("", "Index", "Home", new {area = ""}, new {@class = "nav-link nav-icon oi oi-hard-drive", title=@loc["WEBFRONT_NAV_SERVERS"]})</li>
|
<li class="nav-item d-none d-lg-inline-block d-xl-none">@Html.ActionLink("", "Index", "Home", new {area = ""}, new {@class = "nav-link nav-icon oi oi-hard-drive", title=@loc["WEBFRONT_NAV_SERVERS"]})</li>
|
||||||
<li class="nav-item text-center d-lg-none d-xl-inline-block">@Html.ActionLink(loc["WEBFRONT_NAV_SERVERS"], "Index", "Home", new {area = ""}, new {@class = "nav-link"})</li>
|
<li class="nav-item text-center d-lg-none d-xl-inline-block">@Html.ActionLink(loc["WEBFRONT_NAV_SERVERS"], "Index", "Home", new {area = ""}, new {@class = "nav-link"})</li>
|
||||||
|
|
||||||
<li class="nav-item d-none d-lg-inline-block d-xl-none">@Html.ActionLink("", "Index", "About", new {area = ""}, new {@class = "nav-link nav-icon oi oi-list-rich", title=loc["WEBFRONT_NAV_ABOUT"]})</li>
|
@if (ViewBag.Configuration.CommunityInformation.IsEnabled)
|
||||||
<li class="nav-item text-center text-lg-left d-lg-none d-xl-inline-block">@Html.ActionLink(loc["WEBFRONT_NAV_ABOUT"], "Index", "About", new {area = ""}, new {@class = "nav-link"})</li>
|
{
|
||||||
|
<li class="nav-item d-none d-lg-inline-block d-xl-none">@Html.ActionLink("", "Index", "About", new {area = ""}, new {@class = "nav-link nav-icon oi oi-list-rich", title = loc["WEBFRONT_NAV_ABOUT"]})</li>
|
||||||
|
<li class="nav-item text-center text-lg-left d-lg-none d-xl-inline-block">@Html.ActionLink(loc["WEBFRONT_NAV_ABOUT"], "Index", "About", new {area = ""}, new {@class = "nav-link"})</li>
|
||||||
|
}
|
||||||
|
|
||||||
<li class="nav-item d-none d-lg-inline-block d-xl-none">@Html.ActionLink("", "List", "Penalty", new {area = ""}, new {@class = "nav-link nav-icon oi oi-lock-locked", title=loc["WEBFRONT_NAV_PENALTIES"]})</li>
|
<li class="nav-item d-none d-lg-inline-block d-xl-none">@Html.ActionLink("", "List", "Penalty", new {area = ""}, new {@class = "nav-link nav-icon oi oi-lock-locked", title=loc["WEBFRONT_NAV_PENALTIES"]})</li>
|
||||||
<li class="nav-item text-center d-lg-none d-xl-inline-block">@Html.ActionLink(loc["WEBFRONT_NAV_PENALTIES"], "List", "Penalty", new {area = ""}, new {@class = "nav-link"})</li>
|
<li class="nav-item text-center d-lg-none d-xl-inline-block">@Html.ActionLink(loc["WEBFRONT_NAV_PENALTIES"], "List", "Penalty", new {area = ""}, new {@class = "nav-link"})</li>
|
||||||
|
Loading…
Reference in New Issue
Block a user