Skip to content

Commit

Permalink
Static navigation links! And no more streaming stuff (#20)
Browse files Browse the repository at this point in the history
* Remove some of unnecessary onclick handlers again

* Disable blazor dynamic nav and page streaming
  • Loading branch information
SaphireLattice authored Aug 20, 2024
1 parent bd1722f commit 3589962
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 44 deletions.
2 changes: 1 addition & 1 deletion ReplayBrowser/Pages/Home.razor
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@using ReplayBrowser.Helpers
@using ReplayBrowser.Models
@using ReplayBrowser.Pages.Shared
@attribute [StreamRendering]

@inject ReplayHelper ReplayHelper
@inject AuthenticationStateProvider AuthenticationStateProvider

Expand Down
1 change: 0 additions & 1 deletion ReplayBrowser/Pages/Leaderboard.razor
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
@inject IConfiguration Configuration
@inject LeaderboardService LeaderboardService
@inject Ss14ApiHelper Ss14ApiHelper
@attribute [StreamRendering]

<PageTitle>Leaderboard</PageTitle>
<h4>Leaderboards</h4>
Expand Down
1 change: 0 additions & 1 deletion ReplayBrowser/Pages/Profile.razor
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
@inject ReplayHelper ReplayHelper
@inject Ss14ApiHelper Ss14ApiHelper

@attribute [StreamRendering]

<PageTitle>Player info</PageTitle>

Expand Down
6 changes: 4 additions & 2 deletions ReplayBrowser/Pages/Shared/App.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en" data-bs-theme="dark">
<html lang="en" data-bs-theme="dark" data-enhance-nav="false">

<head>
<meta charset="utf-8"/>
Expand All @@ -14,13 +14,15 @@
<link rel="icon" type="image/png" href="favicon.png"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
<meta name="robots" content="noindex">

<script src="_framework/blazor.web.js" autostart="false"></script>

<HeadOutlet/>
</head>

<body>

<Routes/>
<script src="_framework/blazor.web.js"></script>
</body>

</html>
77 changes: 39 additions & 38 deletions ReplayBrowser/Pages/Shared/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,7 @@
</div>

<div class="page">
<main class="container my-5">
@foreach (var activeNotice in NoticeHelper.GetActiveNotices())
{
// See in cookies if we have already dismissed this notice
var dismissed = HttpContextAccessor.HttpContext != null && HttpContextAccessor.HttpContext.Request.Cookies.ContainsKey($"dismissed-notice-{activeNotice.Id}");
if (dismissed)
continue;
var markupString = new MarkupString(activeNotice.Message);

<div class="alert alert-info" role="alert">
<h4 class="alert-heading">@activeNotice.Title</h4>
<p>@markupString</p>
<button
type="button"
class="btn-close"
data-bs-dismiss="alert"
aria-label="Close"
onclick="document.cookie = `dismissed-notice-${@activeNotice.Id}=true; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/`;">
</button>
</div>
}

<header class="container my-5">
@if (_user.Identity.IsAuthenticated)
{
@if (_account is { Protected: true })
Expand All @@ -74,18 +53,18 @@
<p>Your account is set as protected. Your redaction settings were automatically set to true, in order to prevent harassment or similar. Contact the site operator to remove your protection status.</p>
</div>
}

<p id="logged-in-text">Hello <strong>@_user.Claims.Single(c => c.Type == "name").Value!</strong></p>

<a href="/account/logout" class="btn btn-primary" style="margin-right: 10px">Logout</a>
<a class="btn btn-primary" onclick="window.location.href = '/account/manage';" style="margin-right: 10px">Manage</a>
<a class="btn btn-primary" onclick="window.location.href = '/favourites';" style="margin-right: 10px">Favourites</a>
<a class="btn btn-primary" onclick="window.location.href = '/favorites/profiles';" style="margin-right: 10px">Watched profiles</a>
<a href="/account/manage" class="btn btn-primary" style="margin-right: 10px">Manage</a>
<a href="/favourites" class="btn btn-primary" style="margin-right: 10px">Favourites</a>
<a href="/favorites/profiles" class="btn btn-primary" style="margin-right: 10px">Watched profiles</a>

@if (_account?.IsAdmin ?? false)
{
<a class="btn btn-primary" onclick="window.location.href = '/account/admin';" style="margin-right: 10px">Admin</a>
<a class="btn btn-primary" onclick="window.location.href = '/account/admin/notices';" style="margin-right: 10px">Manage notices</a>
<a href="/account/admin" class="btn btn-primary" style="margin-right: 10px">Admin</a>
<a href="/account/admin/notices" class="btn btn-primary" style="margin-right: 10px">Manage notices</a>
}
}
else
Expand All @@ -94,10 +73,32 @@
}

<br/>
<a class="btn btn-primary" onclick="window.location.href = '/leaderboard'" style="margin-right: 10px; margin-top: 10px">Leaderboard</a>
<a class="btn btn-primary" onclick="window.location.href = '/'" style="margin-right: 10px; margin-top: 10px">Main page</a>
<a class="btn btn-primary" onclick="window.location.href = '/downloads'" style="margin-right: 10px; margin-top: 10px">Current downloads</a>
<a class="btn btn-primary" onclick="window.location.href = '/changelog'" style="margin-right: 10px; margin-top: 10px">Changelog</a>
<a href="/" class="btn btn-primary" style="margin-right: 10px; margin-top: 10px">Main page</a>
<a href="/leaderboard" class="btn btn-primary" style="margin-right: 10px; margin-top: 10px">Leaderboard</a>
<a href="/downloads" class="btn btn-primary" style="margin-right: 10px; margin-top: 10px">Current downloads</a>
<a href="/changelog" class="btn btn-primary" style="margin-right: 10px; margin-top: 10px">Changelog</a>
</header>
<main class="container my-5">
@foreach (var activeNotice in NoticeHelper.GetActiveNotices())
{
// See in cookies if we have already dismissed this notice
var dismissed = HttpContextAccessor.HttpContext != null && HttpContextAccessor.HttpContext.Request.Cookies.ContainsKey($"dismissed-notice-{activeNotice.Id}");
if (dismissed)
continue;
var markupString = new MarkupString(activeNotice.Message);

<div class="alert alert-info" role="alert">
<h4 class="alert-heading">@activeNotice.Title</h4>
<p>@markupString</p>
<button
type="button"
class="btn-close"
data-bs-dismiss="alert"
aria-label="Close"
onclick="document.cookie = `dismissed-notice-${@activeNotice.Id}=true; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/`;">
</button>
</div>
}

<p>Warning: Replays recorded before @ReplayParserService.CutOffDateTime.ToLocalTime().ToString("yyyy-MM-dd") (yyyy-MM-dd) are not supported and are not counted</p>

Expand All @@ -108,9 +109,9 @@

<footer class="footer text-muted text-center">
<div class="container">
<p>Replay Browser is a project by Simyon and YuNii. Source code available on <a href="https://github.com/Simyon264/ReplayBrowser">GitHub</a>.</p>
<p>Replay Browser is a project by Simyon, YuNii and Saphire. Source code available on <a href="https://github.com/Simyon264/ReplayBrowser">GitHub</a>.</p>
</div>

<div class="container">
<p><a href="/contact">Contact</a> | <a href="/privacy">Privacy Policy</a> | <a href="@Configuration["Contact:Server"]" target="_blank">Discord Server</a></p>
</div>
Expand All @@ -119,12 +120,12 @@
<script>
const modalRoot = document.getElementById('modal-root');
const pageRoot = document.querySelector('.page');
const modals = document.querySelectorAll('.modal');
modals.forEach(modal => {
modalRoot.appendChild(modal);
});
const observer = new MutationObserver(function(mutations) {
const modals = document.querySelectorAll('.modal');
modals.forEach(modal => {
Expand All @@ -139,7 +140,7 @@
window.location.href = '/account/login'; // horrible code
return;
}
fetch(`/api/replay/favourite/${replayId}`, {
method: 'POST',
headers: {
Expand All @@ -150,7 +151,7 @@
// the response is just a boolean, true if its now favourited, false if its not
response.json().then(isFavourited => {
let button = $(`#favorite-button-${replayId}`)
// we can just get the first child because the button only has one child
// either <i class="fas fa-star"></i> or <i class="far fa-star"></i>
let icon = button.children().first();
Expand Down
2 changes: 1 addition & 1 deletion ReplayBrowser/Pages/ViewReplay.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@using ReplayBrowser.Data.Models
@using ReplayBrowser.Helpers
@using ReplayBrowser.Pages.Shared
@attribute [StreamRendering]

@inject AuthenticationStateProvider AuthenticationStateProvider
@inject ReplayHelper ReplayHelper

Expand Down

0 comments on commit 3589962

Please sign in to comment.