ProjectLighthouse/ProjectLighthouse.Servers.Website/Pages/Layouts/BaseLayout.cshtml
Josh b8324d0c10
Migrate to GitInfo for embedding git information (#911)
* Migrate to GitInfo for embedding git information

* Adjust gitignore to reflect new git system

* Fix changes from broken merge

* Remove vestigial code in VersionHelper

---------

Co-authored-by: sudokoko <koko@drones.gay>
2023-10-29 23:50:16 +00:00

272 lines
No EOL
11 KiB
Text

@using LBPUnion.ProjectLighthouse.Configuration
@using LBPUnion.ProjectLighthouse.Extensions
@using LBPUnion.ProjectLighthouse.Helpers
@using LBPUnion.ProjectLighthouse.Localization.StringLists
@using LBPUnion.ProjectLighthouse.Servers.Website.Types
@using Microsoft.EntityFrameworkCore
@model LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts.BaseLayout
@{
if (Model.User == null)
{
Model.NavigationItemsRight.Add(ServerConfiguration.Instance.Authentication.RegistrationEnabled
? new PageNavigationItem(BaseLayoutStrings.HeaderLoginRegister, "/login", "sign in")
: new PageNavigationItem(BaseLayoutStrings.HeaderLogin, "/login", "sign in"));
}
else
{
Model.NavigationItems.Add(new PageNavigationItem(BaseLayoutStrings.HeaderAuthentication, "/authentication", "key"));
@if (await Model.Database.Notifications.AnyAsync(n => n.UserId == Model.User.UserId && !n.IsDismissed) ||
await Model.Database.WebsiteAnnouncements.AnyAsync())
{
Model.NavigationItemsRight.Add(new PageNavigationItem(GeneralStrings.Notifications, "/notifications", "bell"));
}
else
{
Model.NavigationItemsRight.Add(new PageNavigationItem(GeneralStrings.Notifications, "/notifications", "bell outline"));
}
@if (Model.User.IsAdmin)
{
Model.NavigationItemsRight.Add(new PageNavigationItem(BaseLayoutStrings.HeaderAdminPanel, "/admin", "wrench", "yellow"));
}
else if (Model.User.IsModerator)
{
Model.NavigationItemsRight.Add(new PageNavigationItem(BaseLayoutStrings.HeaderModPanel, "/moderation", "user shield", "green"));
}
}
Model.IsMobile = Model.Request.IsMobile();
string title = Model.Title == string.Empty
? ServerConfiguration.Instance.Customization.ServerName
: $"{Model.Title} - {ServerConfiguration.Instance.Customization.ServerName}";
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>@title</title>
<link rel="stylesheet" type="text/css" href="~/css/styles.css">
<link rel="stylesheet" type="text/css" href="~/css/semantic.min.css">
@* Favicon *@
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#008cff">
<meta name="msapplication-TileColor" content="#008cff">
@* Embed Stuff *@
<meta name="theme-color" data-react-helmet="true" content="#008cff">
<meta content="@title" property="og:title">
@if (!string.IsNullOrEmpty(Model.Description))
{
<meta content="@Model.Description" property="og:description">
}
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@* Google Analytics *@
@if (ServerConfiguration.Instance.GoogleAnalytics.AnalyticsEnabled)
{
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=@ServerConfiguration.Instance.GoogleAnalytics.Id"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '@ServerConfiguration.Instance.GoogleAnalytics.Id');
</script>
}
</head>
<body>
<div class="pageContainer">
<header class="lighthouse-header">
<div class="ui inverted attached menu">
<div class="ui container">
@{
string mobileIconStyle = Model.IsMobile ? "margin-right: 0;" : "";
}
<a class="item home-logo" href="/">
<img src="~/logo-mono.png" alt="Home" class="logo-mono"/>
<img src="~/@(ServerConfiguration.Instance.WebsiteConfiguration.PrideEventEnabled && DateTime.Now.Month == 6 ? "logo-pride.png" : "logo-color.png")"
alt="Home"
class="logo-color"/>
</a>
@foreach (PageNavigationItem navigationItem in Model.NavigationItems)
{
<a class="item" href="@navigationItem.Url">
@if (navigationItem.Icon != null)
{
<i class="@navigationItem.CustomColor @navigationItem.Icon icon" style="@mobileIconStyle"></i>
}
@if (!Model.IsMobile)
{
<span class="ui inline @navigationItem.CustomColor text">
@Model.Translate(navigationItem.Name)
</span>
}
</a>
}
<div class="right menu">
@foreach (PageNavigationItem navigationItem in Model.NavigationItemsRight)
{
<a class="item" href="@navigationItem.Url">
@if (navigationItem.Icon != null)
{
<i class="@navigationItem.CustomColor @navigationItem.Icon icon" style="@mobileIconStyle"></i>
}
@if (!Model.IsMobile)
{
<span class="ui inline @navigationItem.CustomColor text">@Model.Translate(navigationItem.Name)</span>
}
</a>
}
@if (Model.User != null)
{
<a class="item" href="/user/@Model.User.UserId">
<img src="/gameAssets/@Model.User.WebsiteAvatarHash"
onerror="this.onerror='';this.src='/gameAssets/@ServerConfiguration.Instance.WebsiteConfiguration.MissingIconHash'"
alt=""
class="lighthouse-avatar"/>
@if (!Model.IsMobile)
{
<b class="lighthouse-name">@Model.User.Username</b>
}
</a>
}
</div>
</div>
</div>
<noscript>
<div class="ui bottom attached red message">
<div class="ui container">
<div style="display: flex; align-items: center; font-size: 1.2rem;">
<i class="warning icon"></i>
<span style="font-size: 1.2rem;">@Model.Translate(BaseLayoutStrings.JavaScriptWarnTitle)</span>
</div>
<p>@Model.Translate(BaseLayoutStrings.JavaScriptWarn)</p>
</div>
</div>
</noscript>
@if (!ServerStatics.IsDebug() && VersionHelper.IsDirty)
{
<div class="ui bottom attached red message large">
<div class="ui container">
<i class="warning icon"></i>
<span style="font-size: 1.2rem;">@Model.Translate(BaseLayoutStrings.LicenseWarnTitle)</span>
<p>
@Html.Raw(Model.Translate(BaseLayoutStrings.LicenseWarn1,
"<a href=\"https://github.com/LBPUnion/project-lighthouse/blob/main/LICENSE\">GNU Affero General Public License v3.0</a>"))
</p>
<p>
@Html.Raw(Model.Translate(BaseLayoutStrings.LicenseWarn2,
"<code>git status</code>", "<a href=\"https://github.com/LBPUnion/project-lighthouse/issues\">", "</a>"))
</p>
<p>
@Html.Raw(Model.Translate(BaseLayoutStrings.LicenseWarn3))
</p>
</div>
</div>
}
</header>
<div class="main">
<div class="ui container">
@{
// on mobile, only show page contents
string segment = Model.IsMobile ? "" : "ui attached segment";
}
<div class="@segment">
<div style="height: 17px"></div>
@if (Model.ShowTitleInPage)
{
<h1 class="lighthouse-title">@Model.Title</h1>
}
@RenderBody()
<div style="height: 17px"></div>
</div>
</div>
</div>
<footer>
<div class="ui black attached inverted segment">
<div class="ui container">
@{
string? remoteUrl = VersionHelper.RepositoryUrl;
}
<span>
@Model.Translate(BaseLayoutStrings.GeneratedBy, VersionHelper.FullVersion)
</span>
<span style="float: right;">
<a href="https://github.com/LBPUnion/ProjectLighthouse/blob/main/LICENSE" target="_blank">
AGPL-3.0 License
</a>
&centerdot;
@if (!string.IsNullOrWhiteSpace(remoteUrl))
{
<a href="https://@remoteUrl" target="_blank">
Source Code
</a>
}
else
{
<span class="ui text red">Cannot Detect Source Code</span>
}
</span>
@if (VersionHelper.IsDirty)
{
<p>@Model.Translate(BaseLayoutStrings.GeneratedModified)</p>
}
</div>
</div>
@if (ServerStatics.IsDebug())
{
<div class="ui red attached inverted segment">
<div class="ui container">
<button type="button" class="ui inverted button collapsible">
<b>Show/Hide Debug Info</b>
</button>
<div style="display:none" id="lighthouse-debug-info">
<br>
<p>Model.IsMobile: @Model.IsMobile</p>
<p>Model.Title: @Model.Title</p>
<p>Model.Description: @Model.Description</p>
<p>Model.User.UserId: @(Model.User?.UserId.ToString() ?? "(not logged in)")</p>
</div>
</div>
</div>
<script>
const collapsible = document.getElementsByClassName("collapsible");
for (let i = 0; i < collapsible.length; i++)
{
collapsible[i].addEventListener("click", function()
{
this.classList.toggle("active");
const content = this.nextElementSibling;
if (content.style.display === "block")
{
content.style.display = "none";
}
else
{
content.style.display = "block";
}
});
}
</script>
}
</footer>
</div>
</body>
</html>