IW4M-Admin/WebfrontCore/Views/About/Index.cshtml
2023-05-28 11:38:57 -05:00

93 lines
3.6 KiB
Plaintext

@using SharedLibraryCore.Configuration
@using System.Text.RegularExpressions
@model WebfrontCore.ViewModels.CommunityInfo
@{
IEnumerable<KeyValuePair<(string, long), string[]>> allRules = new[] { new KeyValuePair<(string, long), string[]>((ViewBag.Localization["WEBFRONT_ABOUT_GLOBAL_RULES"], 0), 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="content text-wrap mt-20">
@if (Model.CommunityInformation.EnableBanner)
{
<img class="img-fluid mb-20" style="max-height: 250px" src="images/community/banner.png" alt="@Model.CommunityInformation.Name"/>
}
@if (!string.IsNullOrWhiteSpace(Model.CommunityInformation.Name))
{
<h2 class="content-title">
<color-code value="@Model.CommunityInformation.Name"></color-code>
</h2>
}
<div class="card m-0 rounded">
@if (!string.IsNullOrWhiteSpace(Model.CommunityInformation.Description))
{
<h5 class="text-primary mt-0">@ViewBag.Localization["WEBFRONT_ABOUT_TITLE"]</h5>
<div class="text-md-justify">
<color-code value="@Model.CommunityInformation.Description"></color-code>
</div>
<div class="mt-10">
@foreach (var social in Model.CommunityInformation.SocialAccounts ?? Array.Empty<SocialAccountConfiguration>())
{
<div>
<a href="@social.Url" target="_blank" title="@social.Title" class="d-flex no-decoration">
@if (!string.IsNullOrWhiteSpace(social.IconId))
{
<i class="oi @social.IconId mr-5" style="width: 1.6rem;"></i>
}
else if (!string.IsNullOrWhiteSpace(social.IconUrl))
{
var url = Uri.TryCreate(social.IconUrl, UriKind.Absolute, out var parsedUrl)
? parsedUrl.AbsoluteUri
: $"images/community/{social.IconUrl}";
<img class="img-fluid mr-5" style="width: 1.6rem; fill: white" src="@url" alt="@social.Title"/>
}
<div class="ml-1">@social.Title</div>
</a>
</div>
}
</div>
}
</div>
@if (allRules.Any(rule => rule.Value.Any()))
{
<h2 class="content-title mt-20">@ViewBag.Localization["WEBFRONT_ABOUT_COMMUNITY_GUIDELINES"]</h2>
}
<div class="card m-0 rounded">
@foreach (var ((serverName, id), rules) in allRules)
{
if (!rules.Any())
{
continue;
}
var start = 1;
<h5 class="text-primary mt-0 mb-0">
<color-code value="@serverName"></color-code>
</h5>
@foreach (var rule in rules)
{
<div class="rule">
@if (!rule.StartsWith("#") && !Regex.IsMatch(rule.StripColors(), @"^(Rule ?#?)?\d+(.|\))"))
{
<span>@start.</span>
}
<span class="text-muted">
<color-code value="@rule"></color-code>
</span>
</div>
start++;
}
<div class="mb-20"></div>
}
</div>
</div>