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:
8
WebServer.Test/Views/localhost/Index.cshtml
Normal file
8
WebServer.Test/Views/localhost/Index.cshtml
Normal file
@@ -0,0 +1,8 @@
|
||||
@using RazorLight
|
||||
@inherits TemplatePage<object?>
|
||||
@{
|
||||
Layout = "/_Layout.cshtml";
|
||||
ViewBag.Title = "Home";
|
||||
}
|
||||
<h1>Hello!</h1>
|
||||
How you doing?
|
||||
@@ -1 +1,6 @@
|
||||
Hello World!
|
||||
@using RazorLight
|
||||
@inherits TemplatePage<object?>
|
||||
@{
|
||||
Layout = "_Layout.cshtml";
|
||||
}
|
||||
Hello World!
|
||||
@@ -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>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<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">
|
||||
<style>
|
||||
body {
|
||||
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>
|
||||
<link href="/styles/common.css" type="text/css" rel="stylesheet" />
|
||||
@RenderSection("Styles", required: false)
|
||||
</head>
|
||||
<body class="centerize stickyFooter">
|
||||
@RenderBody()
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
@using RazorLight
|
||||
@inherits TemplatePage<WebServer.Models.StatusPageModel>
|
||||
@model WebServer.Models.StatusPageModel
|
||||
@using System;
|
||||
@using RazorLight;
|
||||
@inherits TemplatePage<WebServer.Models.StatusPageModel>;
|
||||
@model WebServer.Models.StatusPageModel;
|
||||
@{
|
||||
Layout = @"_Layout.cshtml";
|
||||
ViewBag.Title = $"{Model.StatusCodeAsUShort} - {Model.Header}";
|
||||
Layout = @"/_Layout.cshtml";
|
||||
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 class="ice centerize">
|
||||
<div style="font-size: 2em;">@Model.Header</div>
|
||||
<span>@Model.Details</span>
|
||||
@if (Model.Exception != null) {
|
||||
|
||||
<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>
|
||||
}
|
||||
BIN
WebServer.Test/Views/localhost/fonts/OpenSans/Light.eot
Normal file
BIN
WebServer.Test/Views/localhost/fonts/OpenSans/Light.eot
Normal file
Binary file not shown.
BIN
WebServer.Test/Views/localhost/fonts/OpenSans/Light.ttf
Normal file
BIN
WebServer.Test/Views/localhost/fonts/OpenSans/Light.ttf
Normal file
Binary file not shown.
BIN
WebServer.Test/Views/localhost/fonts/OpenSans/Light.woff
Normal file
BIN
WebServer.Test/Views/localhost/fonts/OpenSans/Light.woff
Normal file
Binary file not shown.
BIN
WebServer.Test/Views/localhost/images/Chalkboard.webp
Normal file
BIN
WebServer.Test/Views/localhost/images/Chalkboard.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 369 KiB |
50
WebServer.Test/Views/localhost/styles/common.css
Normal file
50
WebServer.Test/Views/localhost/styles/common.css
Normal 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;
|
||||
}
|
||||
10
WebServer.Test/Views/localhost/test123/_Layout.cshtml
Normal file
10
WebServer.Test/Views/localhost/test123/_Layout.cshtml
Normal file
@@ -0,0 +1,10 @@
|
||||
<!-- Layout @@ /test123 -->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Layout2</title>
|
||||
</head>
|
||||
<body>
|
||||
@RenderBody();
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,7 +1,7 @@
|
||||
@using RazorLight
|
||||
@inherits TemplatePage<object?>
|
||||
@{
|
||||
Layout = "/_Layout.cshtml";
|
||||
Layout = "/test123/_Layout.cshtml";
|
||||
ViewBag.Title = "Hello World!";
|
||||
}
|
||||
|
||||
|
||||
24
WebServer/Extensions/ExpandoObject.cs
Normal file
24
WebServer/Extensions/ExpandoObject.cs
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user