Update Test Site

+ Localized everything - No external resources required on the front-end
 + `test123` tested Layouts with relative paths.. issue is, its always relative from root
This commit is contained in:
Kaveman
2024-08-18 03:27:36 -07:00
parent 27fe310191
commit a92acf0597
12 changed files with 127 additions and 37 deletions

View File

@@ -0,0 +1,8 @@
@using RazorLight
@inherits TemplatePage<object?>
@{
Layout = "/_Layout.cshtml";
ViewBag.Title = "Home";
}
<h1>Hello!</h1>
How you doing?

View File

@@ -1 +1,6 @@
Hello World! @using RazorLight
@inherits TemplatePage<object?>
@{
Layout = "_Layout.cshtml";
}
Hello World!

View File

@@ -1,29 +1,19 @@
<!DOCTYPE html> @using RazorLight;
@using WebServer.Extensions;
@{
ViewBag.Title = (ExpandoObjectExt.TryGetProperty(ViewBag, "Title", out object title)
? $"{title} - " : string.Empty
) + "MySite";
}
<!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>@ViewBag.Title</title> <title>@ViewBag.Title</title>
<link href="https://kavemans.dev/src/styles/framework.css" type="text/css" rel="stylesheet" />
<link href="https://kavemans.dev/src/styles/common.css" type="text/css" rel="stylesheet" />
<link href="https://kavemans.dev/src/styles/main.css" type="text/css" rel="stylesheet" />
@RenderSection("Styles", required: false)
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<style> <link href="/styles/common.css" type="text/css" rel="stylesheet" />
body { @RenderSection("Styles", required: false)
background-image: url('https://kavemans.dev/src/images/Chalkboard.webp');
background-size: cover;
background-position: center center;
}
.ice {
background-color: rgba(0, 0, 0, 0.5);
position: fixed;
top: 0;
left: 0;
height: 100%;
width: 100%;
}
</style>
</head> </head>
<body class="centerize stickyFooter"> <body class="centerize stickyFooter">
@RenderBody() @RenderBody()

View File

@@ -1,16 +1,19 @@
@using RazorLight @using System;
@inherits TemplatePage<WebServer.Models.StatusPageModel> @using RazorLight;
@model WebServer.Models.StatusPageModel @inherits TemplatePage<WebServer.Models.StatusPageModel>;
@model WebServer.Models.StatusPageModel;
@{ @{
Layout = @"_Layout.cshtml"; Layout = @"/_Layout.cshtml";
ViewBag.Title = $"{Model.StatusCodeAsUShort} - {Model.Header}"; ViewBag.Title = Model.Header;
// Uncomment to show a test exception
//try { throw new Exception("Test Exception thrown in _StatusPage.cshtml"); } catch (Exception ex) { Model.Exception ??= ex; }
}
<div style="font-size: 2em;">@Model.Header</div>
<span>@Model.Details</span>
@if (Model.Exception != null) {
<div style="padding: 5px; border-radius: 5px; background: rgba(0, 0, 0, 0.5); box-shadow: inset rgb(255 255 255 / 20%) 0 0 0 2px; width: auto; max-width: 95%; text-align: left;">
<pre style="margin: 0;">@Model.Exception</pre>
</div>
} }
<div class="ice centerize">
<div style="font-size: 2em;">@Model.Header</div>
<span>@Model.Details</span>
@if (Model.Exception != null) {
<div style="padding: 5px; border-radius: 5px; background: rgba(0, 0, 0, 0.5); box-shadow: inset rgb(255 255 255 / 20%) 0 0 0 2px; width: auto; max-width: 95%; text-align: left;">
<pre style="margin: 0;">@Model.Exception</pre>
</div>
}
</div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 KiB

View File

@@ -0,0 +1,50 @@
@charset "UTF-8";
@font-face {
font-family: 'Open Sans Light';
src: url('/fonts/OpenSans/Light.eot');
src: local('Open Sans Light'),
url('/fonts/OpenSans/Light.woff') format('woff'),
url('/fonts/OpenSans/Light.ttf') format('truetype');
}
html, body {
min-height: 100vh;
width: 100%;
margin: 0;
padding: 0;
font-family: "Open Sans Light", sans-serif;
color: #fff;
background-color: #131a26;
}
body {
padding: 0;
margin: 0;
position: relative;
min-height: 100vh;
background-image: url('/images/Chalkboard.webp');
background-size: cover;
background-position: center center;
z-index: -1;
}
body::before {
content: "";
pointer-events: none;
height: 100vh;
width: 100vw;
background-color: rgba(0, 0, 0, 0.5);
position: absolute;
top: 0;
left: 0;
z-index: inherit;
}
.centerize {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
}

View File

@@ -0,0 +1,10 @@
<!-- Layout @@ /test123 -->
<!DOCTYPE html>
<html>
<head>
<title>Layout2</title>
</head>
<body>
@RenderBody();
</body>
</html>

View File

@@ -1,7 +1,7 @@
@using RazorLight @using RazorLight
@inherits TemplatePage<object?> @inherits TemplatePage<object?>
@{ @{
Layout = "/_Layout.cshtml"; Layout = "/test123/_Layout.cshtml";
ViewBag.Title = "Hello World!"; ViewBag.Title = "Hello World!";
} }

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Text;
namespace WebServer.Extensions {
public static class ExpandoObjectExt {
public static object GetPropertyOrDefault(this ExpandoObject expando, string propertyName, object defaultValue) {
if (expando is IDictionary<string, object> dict) {
if (!dict.TryGetValue(propertyName, out var result))
dict.Add(propertyName, result = defaultValue);
return result;
}
return defaultValue;
}
public static bool TryGetProperty(this ExpandoObject expando, string propertyName, out object value) {
value = null;
return expando is IDictionary<string, object> dict
&& dict.TryGetValue(propertyName, out value);
}
}
}