ProjectLighthouse/ProjectLighthouse.Servers.Website/Pages/Layouts/BaseLayout.cshtml
2022-06-10 04:30:23 -04:00

210 lines
No EOL
8.7 KiB
Text

@using LBPUnion.ProjectLighthouse.Configuration
@using LBPUnion.ProjectLighthouse.Extensions
@using LBPUnion.ProjectLighthouse.Helpers
@using LBPUnion.ProjectLighthouse.Localization.StringLists
@using LBPUnion.ProjectLighthouse.Types
@model LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts.BaseLayout
@{
if (Model!.User == null)
{
Model.NavigationItemsRight.Add(new PageNavigationItem(BaseLayoutStrings.HeaderLoginRegister, "/login", "sign in"));
}
else
{
if (ServerConfiguration.Instance.Authentication.UseExternalAuth)
{
Model.NavigationItems.Add(new PageNavigationItem(BaseLayoutStrings.HeaderAuthentication, "/authentication", "key"));
}
Model.NavigationItemsRight.Add(new PageNavigationItem(BaseLayoutStrings.HeaderProfile, "/user/" + Model.User.UserId, "user alternate"));
@if (Model.User.IsAdmin)
{
Model.NavigationItemsRight.Add(new PageNavigationItem(BaseLayoutStrings.HeaderAdminPanel, "/admin", "cogs"));
}
Model.NavigationItemsRight.Add(new PageNavigationItem(BaseLayoutStrings.HeaderLogout, "/logout", "user alternate slash")); // should always be last
}
Model.IsMobile = Model.Request.IsMobile();
}
<!DOCTYPE html>
<html lang="en">
<head>
@if (Model.Title == string.Empty)
{
<title>@ServerConfiguration.Instance.Customization.ServerName</title>
}
else
{
<title>@ServerConfiguration.Instance.Customization.ServerName - @Model.Title</title>
}
<link rel="stylesheet" type="text/css" href="~/css/styles.css">
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/fomantic-ui@2.8.8/dist/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="@ServerConfiguration.Instance.Customization.ServerName - @Model.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 attached menu">
<div class="ui container">
@{
string mobileIconStyle = Model.IsMobile ? "margin-right: 0;" : "";
}
@foreach (PageNavigationItem navigationItem in Model!.NavigationItems)
{
<a class="item" href="@navigationItem.Url">
@if (navigationItem.Icon != null)
{
<i class="@navigationItem.Icon icon" style="@mobileIconStyle"></i>
}
@if (!Model.IsMobile)
{
@Model.Translate(navigationItem.Name)
}
</a>
}
<div class="right menu">
@foreach (PageNavigationItem navigationItem in Model!.NavigationItemsRight)
{
<a class="item" href="@navigationItem.Url">
@if (navigationItem.Icon != null)
{
<i class="@navigationItem.Icon icon" style="@mobileIconStyle"></i>
}
@if (!Model.IsMobile)
{
@Model.Translate(navigationItem.Name)
}
</a>
}
</div>
</div>
</div>
<noscript>
<div class="ui bottom attached yellow message small">
<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;">JavaScript not enabled</span>
</div>
<p>
While we intend to have as little JavaScript as possible, we can not
guarantee everything will work without it. We recommend that you whitelist JavaScript for Project Lighthouse.
It's not <i>too</i> bloated, we promise.
</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;">Potential License Violation</span>
<p>This instance is a public-facing instance that has been modified without the changes published. You may be in violation of the <a href="https://github.com/LBPUnion/project-lighthouse/blob/main/LICENSE">GNU Affero General Public License v3.0</a>.</p>
<p>If you believe this is an error, please create an issue with the output of <code>git status</code> ran from the root of the server source code in the description on our <a href="https://github.com/LBPUnion/project-lighthouse/issues">issue tracker</a>.</p>
<p>If not, please publish the source code somewhere accessible to your users.</p>
</div>
</div>
}
</header>
<div class="main">
<div class="ui container">
<br>
@if (Model.ShowTitleInPage)
{
<h1>@Model.Title</h1>
}
@RenderBody()
<div style="height: 50px;"></div> @* makes it look nicer *@
</div>
</div>
<footer>
<div class="ui black attached inverted segment">
<div class="ui container">
<p>Page generated by @VersionHelper.FullVersion.</p>
@if (VersionHelper.IsDirty)
{
<p>This page was generated using a modified version of Project Lighthouse. Please make sure you are properly disclosing the source code to any users who may be using this instance.</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>