5 Commits

Author SHA1 Message Date
Tommy Parnell
b776c14feb oof 2022-08-21 22:28:10 -04:00
Tommy Parnell
26780cf00f revert svg opt 2022-08-21 22:25:42 -04:00
Tommy Parnell
d85c0c8c99 shrink html 2022-08-21 22:10:26 -04:00
Tommy Parnell
75e329b3df save some cshtml changes 2022-08-20 10:09:37 -04:00
Tommy Parnell
c252cd2d4b checkbox hamburger (#14)
Convert hamburger menu to checkbox
2022-08-20 09:40:08 -04:00
11 changed files with 146 additions and 63 deletions

View File

@@ -4,6 +4,6 @@
.gitignore
.vs
.vscode
*/bin
*/obj
**/bin
**/obj
**/.toolstarget

View File

@@ -1,17 +1,26 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
# https://hub.docker.com/_/microsoft-dotnet
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
WORKDIR /source
# copy csproj and restore as distinct layers
COPY ./src/TerribleDev.Blog.Web/*.csproj .
RUN dotnet restore -r linux-musl-x64 /p:PublishReadyToRunComposite=true
# copy everything else and build app
COPY ./src/TerribleDev.Blog.Web/ .
RUN dotnet publish -c release -o /app -r linux-musl-x64 --self-contained true --no-restore /p:PublishTrimmed=true /p:PublishReadyToRunComposite=true /p:PublishSingleFile=true
RUN date +%s > /app/buildtime.txt
# final stage/image
FROM mcr.microsoft.com/dotnet/runtime-deps:6.0-alpine-amd64
WORKDIR /app
COPY --from=build /app ./
# Copy csproj and restore as distinct layers
COPY *.sln .
COPY . .
RUN dotnet restore
# See: https://github.com/dotnet/announcements/issues/20
# Uncomment to enable globalization APIs (or delete)
# ENV \
# DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false \
# LC_ALL=en_US.UTF-8 \
# LANG=en_US.UTF-8
# RUN apk add --no-cache icu-libs
# Copy everything else and build
COPY . .
RUN dotnet publish -c Release -o out
# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:6.0
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "TerribleDev.Blog.Web.dll"]
ENTRYPOINT ["./TerribleDev.Blog.Web"]

12
Dockerfile.old Normal file
View File

@@ -0,0 +1,12 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
WORKDIR /app
# Copy everything else and build
COPY /src/TerribleDev.Blog.Web .
RUN dotnet publish -c release -o /out -r linux-musl-x64 --self-contained true /p:PublishTrimmed=true /p:PublishReadyToRunComposite=true /p:PublishSingleFile=true
RUN date +%s > /out/buildtime.txt
# Build runtime image
FROM mcr.microsoft.com/dotnet/runtime-deps:6.0-alpine-amd64
WORKDIR /app
COPY --from=build /app/out .
ENTRYPOINT ["./TerribleDev.Blog.Web"]

39
fly.toml Normal file
View File

@@ -0,0 +1,39 @@
# fly.toml file generated for tparnellblog on 2022-08-20T09:53:58-04:00
app = "tparnellblog"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []
[env]
[experimental]
allowed_public_ports = []
auto_rollback = true
private_network = true
[[services]]
http_checks = []
internal_port = 80
processes = ["app"]
protocol = "tcp"
script_checks = []
[services.concurrency]
hard_limit = 200
soft_limit = 100
type = "connections"
[[services.ports]]
force_https = true
handlers = ["http"]
port = 80
[[services.ports]]
handlers = ["tls", "http"]
port = 443
[[services.tcp_checks]]
grace_period = "1s"
interval = "15s"
restart_limit = 0
timeout = "2s"

View File

@@ -9,7 +9,7 @@ RUN dotnet restore -r linux-musl-x64 /p:PublishReadyToRunComposite=true
# copy everything else and build app
COPY . .
RUN dotnet publish -c release -o /app -r linux-musl-x64 --self-contained true --no-restore /p:PublishTrimmed=true /p:PublishReadyToRunComposite=true /p:PublishSingleFile=true
RUN date +%s > /app/buildtime.txt
# final stage/image
FROM mcr.microsoft.com/dotnet/runtime-deps:6.0-alpine-amd64
WORKDIR /app

View File

@@ -27,6 +27,7 @@ namespace TerribleDev.Blog.Web.Factories
if(!codeContent.IsSuccessStatusCode)
{
Console.Error.WriteLine("Error posting code to prisma");
Console.Error.WriteLine("status code: " + codeContent.StatusCode);
}
return (code, await codeContent.Content.ReadAsStringAsync());
}));

View File

@@ -1,5 +1,7 @@
using System;
using System.Collections.Concurrent;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using Microsoft.AspNetCore.Mvc;
@@ -9,7 +11,26 @@ namespace TerribleDev.Blog.Web.Filters
{
public class StaticETag: ActionFilterAttribute
{
public static string staticEtag = "\"" + MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(DateTimeOffset.Now.ToUnixTimeMilliseconds().ToString())).ToHexString().Substring(0,8) + "\"";
static StaticETag()
{
string etagString;
if(File.Exists("buildtime.txt"))
{
Console.WriteLine("buildtime.txt found");
etagString = File.ReadAllText("buildtime.txt");
}
else
{
Console.WriteLine("buildtime.txt not found");
Console.WriteLine("Directory list");
Console.WriteLine(Directory.GetFiles(".", "*", SearchOption.AllDirectories).Aggregate((a, b) => a + "\n" + b));
var unixTime = DateTimeOffset.Now.ToUnixTimeMilliseconds().ToString();
Console.WriteLine("Using Unix Time for Etag: " + unixTime);
etagString = unixTime;
}
StaticETag.staticEtag = "\"" + MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(etagString)).ToHexString().Substring(0,8) + "\"";
}
public static string staticEtag;
public static ConcurrentDictionary<string, string> cache = new ConcurrentDictionary<string, string>();
public override void OnActionExecuted(ActionExecutedContext context)
{

View File

@@ -89,6 +89,7 @@ namespace TerribleDev.Blog.Web
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
Console.WriteLine("ETag Detected As: " + StaticETag.staticEtag);
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();

View File

@@ -5,7 +5,6 @@
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
<ItemGroup>
<Content Remove="compilerconfig.json" />
<Content Remove="bundleconfig.json" />

View File

@@ -0,0 +1,14 @@
@media (prefers-color-scheme: dark) {
:root {
--hln: #f0f0f0;
--bdy-txt-clr: #ffffff;
--blk-qt-lb: #d1dced;
--code-blk-bg-clr: #4a4a4a;
--pmry-bknd: #323131;
--lnk-clr: #3faff9;
/* --lnk-vistd: #d8dbde; */
--bc: #bdcad2;
--hr: #626468;
}
}

View File

@@ -1,31 +1,18 @@
:root {
--headline: #4a4a4a;
--body-text-color: #5d686f;
--block-quote-left-border: #d1dced;
--code-block-background-color: #f5f5f5;
--primary-background: #FFFFFF;
--link-color: #00558d;
--link-visited: var(--link-color);
/* --link-visited: #6c6c6c; */
--border-color: #738691;
--horizontal-rule: #dfe2e7;
--nav-bar-background: var(--headline);
--nav-bar-text-color: var(--primary-background);
--hln: #4a4a4a;
--bdy-txt-clr: #5d686f;
--blk-qt-lb: #d1dced;
--code-blk-bg-clr: #f5f5f5;
--pmry-bknd: #FFFFFF;
--lnk-clr: #00558d;
--lnk-vistd: var(--lnk-clr);
/* --lnk-vistd: #6c6c6c; */
--bc: #738691;
--hr: #dfe2e7;
--nb-bkgd: var(--hln);
--nb-txt-color: var(--pmry-bknd);
}
@media (prefers-color-scheme: dark) {
:root {
--headline: #f0f0f0;
--body-text-color: #ffffff;
--block-quote-left-border: #d1dced;
--code-block-background-color: #4a4a4a;
--primary-background: #323131;
--link-color: #3faff9;
/* --link-visited: #d8dbde; */
--border-color: #bdcad2;
--horizontal-rule: #626468;
}
}
html {
font-family: Arial, Helvetica, sans-serif;
@@ -37,7 +24,7 @@ h3,
h4,
h5,
h6 {
color: var(--headline);
color: var(--hln);
line-height: 1.45;
letter-spacing: -0.01em;
line-height: 1.25em;
@@ -51,8 +38,8 @@ body {
text-rendering: optimizeLegibility;
letter-spacing: -0.01em;
line-height: 1.9rem;
background-color: var(--primary-background);
color: var(--body-text-color);
background-color: var(--pmry-bknd);
color: var(--bdy-txt-clr);
font-size: 1.125rem;
margin: 0;
}
@@ -87,7 +74,7 @@ body {
}
blockquote {
border-left: 2px solid var(--block-quote-left-border);
border-left: 2px solid var(--blk-qt-lb);
padding: 0.4em 1.2em;
}
@@ -97,7 +84,7 @@ pre {
font-family: "Courier New", Courier, monospace;
font-weight: 600;
border-radius: 3px;
background: var(--code-block-background-color);
background: var(--code-blk-bg-clr);
padding: 0 0.4em;
overflow-x: scroll;
letter-spacing: .02em;
@@ -109,16 +96,16 @@ pre > code {
}
a {
color: var(--link-color);
color: var(--lnk-clr);
font-weight: 400;
}
a:visited {
color: var(--link-visited);
color: var(--lnk-vistd);
}
.btmRule {
border-bottom: 1px solid var(--horizontal-rule);
border-bottom: 1px solid var(--hr);
padding-bottom: 3rem;
}
@@ -126,8 +113,8 @@ a:visited {
display: flex;
flex-direction: column;
align-items: center;
background: var(--nav-bar-background);
color: var(--nav-bar-text-color);
background: var(--nb-bkgd);
color: var(--nb-txt-color);
padding-top: 20px;
height: 100vh;
z-index: 40;
@@ -141,9 +128,9 @@ a:visited {
.header {
display: flex;
align-items: center;
border-bottom: 1px solid var(--horizontal-rule);
color: var(--headline);
background-color: var(--primary-background);
border-bottom: 1px solid var(--hr);
color: var(--hln);
background-color: var(--pmry-bknd);
z-index: 20;
padding: 0;
margin: 0;
@@ -186,21 +173,21 @@ a:visited {
.btn {
width: auto;
height: auto;
background: var(--primary-background);
background: var(--pmry-bknd);
border-radius: 3px;
margin: 0;
cursor: pointer;
color: var(--body-text-color);
border: 1px solid var(--body-text-color);
color: var(--bdy-txt-clr);
border: 1px solid var(--bdy-txt-clr);
padding: 0.3em 0.2em;
text-decoration: none;
font-size: 1.1rem;
text-transform: uppercase;
}
.btn:visited {
background: var(--primary-background);
color: var(--border-color);
border: 1px solid var(--border-color);
background: var(--pmry-bknd);
color: var(--bc);
border: 1px solid var(--bc);
}
.btn.block {