Compare commits
5 Commits
master
...
backup-nav
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b776c14feb | ||
|
|
26780cf00f | ||
|
|
d85c0c8c99 | ||
|
|
75e329b3df | ||
|
|
c252cd2d4b |
@@ -1,42 +0,0 @@
|
|||||||
name: Trigger auto deployment for blogcontainergroup
|
|
||||||
|
|
||||||
# When this action will be executed
|
|
||||||
on:
|
|
||||||
# Automatically trigger it when detected changes in repo
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
[ master ]
|
|
||||||
paths:
|
|
||||||
- '**'
|
|
||||||
- '.github/workflows/blogcontainergroup-AutoDeployTrigger-ab8fcfc6-eced-47ac-8584-4f5a983b4ee2.yml'
|
|
||||||
|
|
||||||
# Allow mannually trigger
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build-and-deploy:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout to the branch
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Azure Login
|
|
||||||
uses: azure/login@v1
|
|
||||||
with:
|
|
||||||
creds: ${{ secrets.BLOGCONTAINERGROUP_AZURE_CREDENTIALS }}
|
|
||||||
|
|
||||||
- name: Build and push container image to registry
|
|
||||||
uses: azure/container-apps-deploy-action@v1
|
|
||||||
with:
|
|
||||||
appSourcePath: ${{ github.workspace }}
|
|
||||||
registryUrl: terribledevreg.azurecr.io
|
|
||||||
registryUsername: ${{ secrets.BLOGCONTAINERGROUP_REGISTRY_USERNAME }}
|
|
||||||
registryPassword: ${{ secrets.BLOGCONTAINERGROUP_REGISTRY_PASSWORD }}
|
|
||||||
containerAppName: blogcontainergroup
|
|
||||||
resourceGroup: ContainerGroup
|
|
||||||
imageToBuild: terribledevreg.azurecr.io/blogcontainergroup:${{ github.sha }}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
51
.github/workflows/master_tparnellbloglinux.yml
vendored
Normal file
51
.github/workflows/master_tparnellbloglinux.yml
vendored
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
|
||||||
|
# More GitHub Actions for Azure: https://github.com/Azure/actions
|
||||||
|
|
||||||
|
name: Build and deploy container app to Azure Web App - tparnellbloglinux
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: 'ubuntu-latest'
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
|
- name: Log in to registry
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
registry: https://terribledevreg.azurecr.io/
|
||||||
|
username: ${{ secrets.AzureAppService_ContainerUsername_aec4619fe53744eab156fa2356a5e1e4 }}
|
||||||
|
password: ${{ secrets.AzureAppService_ContainerPassword_1a9d2b89f86245f982b0fbfc81951798 }}
|
||||||
|
|
||||||
|
- name: Build and push container image to registry
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
push: true
|
||||||
|
tags: terribledevreg.azurecr.io/${{ secrets.AzureAppService_ContainerUsername_aec4619fe53744eab156fa2356a5e1e4 }}/tparnellbloglinux-img:${{ github.sha }}
|
||||||
|
file: ./Dockerfile
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: build
|
||||||
|
environment:
|
||||||
|
name: 'production'
|
||||||
|
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Deploy to Azure Web App
|
||||||
|
id: deploy-to-webapp
|
||||||
|
uses: azure/webapps-deploy@v2
|
||||||
|
with:
|
||||||
|
app-name: 'tparnellbloglinux'
|
||||||
|
slot-name: 'production'
|
||||||
|
publish-profile: ${{ secrets.AzureAppService_PublishProfile_110e4da4c4b44f4fbd30c6811b6cb64c }}
|
||||||
|
images: 'terribledevreg.azurecr.io/${{ secrets.AzureAppService_ContainerUsername_aec4619fe53744eab156fa2356a5e1e4 }}/tparnellbloglinux-img:${{ github.sha }}'
|
||||||
60
.github/workflows/tparnellblogk8s-AutoDeployTrigger-63a78573-0450-4fa7-92eb-43918b0e6169.yml
vendored
Normal file
60
.github/workflows/tparnellblogk8s-AutoDeployTrigger-63a78573-0450-4fa7-92eb-43918b0e6169.yml
vendored
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
name: Trigger auto deployment for tparnellblogk8s
|
||||||
|
|
||||||
|
# When this action will be executed
|
||||||
|
on:
|
||||||
|
# Automatically trigger it when detected changes in repo
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
[ master ]
|
||||||
|
paths:
|
||||||
|
- '**'
|
||||||
|
- '.github/workflows/tparnellblogk8s-AutoDeployTrigger-63a78573-0450-4fa7-92eb-43918b0e6169.yml'
|
||||||
|
|
||||||
|
# Allow mannually trigger
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout to the branch
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
|
- name: Log in to container registry
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
registry: terribledevreg.azurecr.io
|
||||||
|
username: ${{ secrets.TPARNELLBLOGK8S_REGISTRY_USERNAME }}
|
||||||
|
password: ${{ secrets.TPARNELLBLOGK8S_REGISTRY_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Build and push container image to registry
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
push: true
|
||||||
|
tags: terribledevreg.azurecr.io/tparnellblogk8s:${{ github.sha }}
|
||||||
|
file: ./Dockerfile
|
||||||
|
context: ./
|
||||||
|
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: build
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Azure Login
|
||||||
|
uses: azure/login@v1
|
||||||
|
with:
|
||||||
|
creds: ${{ secrets.TPARNELLBLOGK8S_AZURE_CREDENTIALS }}
|
||||||
|
|
||||||
|
|
||||||
|
- name: Deploy to containerapp
|
||||||
|
uses: azure/CLI@v1
|
||||||
|
with:
|
||||||
|
inlineScript: |
|
||||||
|
az config set extension.use_dynamic_install=yes_without_prompt
|
||||||
|
az containerapp registry set -n tparnellblogk8s -g containerapp --server terribledevreg.azurecr.io --username ${{ secrets.TPARNELLBLOGK8S_REGISTRY_USERNAME }} --password ${{ secrets.TPARNELLBLOGK8S_REGISTRY_PASSWORD }}
|
||||||
|
az containerapp update -n tparnellblogk8s -g containerapp --image terribledevreg.azurecr.io/tparnellblogk8s:${{ github.sha }}
|
||||||
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@@ -9,7 +9,7 @@
|
|||||||
"type": "coreclr",
|
"type": "coreclr",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"preLaunchTask": "build",
|
"preLaunchTask": "build",
|
||||||
"program": "${workspaceFolder}/src/TerribleDev.Blog.Web/bin/Debug/net7.0/TerribleDev.Blog.Web.dll",
|
"program": "${workspaceFolder}/src/TerribleDev.Blog.Web/bin/Debug/netcoreapp3.1/TerribleDev.Blog.Web.dll",
|
||||||
"args": [],
|
"args": [],
|
||||||
"cwd": "${workspaceFolder}/src/TerribleDev.Blog.Web",
|
"cwd": "${workspaceFolder}/src/TerribleDev.Blog.Web",
|
||||||
"stopAtEntry": false,
|
"stopAtEntry": false,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# https://hub.docker.com/_/microsoft-dotnet
|
# https://hub.docker.com/_/microsoft-dotnet
|
||||||
FROM mcr.microsoft.com/dotnet/sdk:7.0-alpine AS build
|
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
|
||||||
WORKDIR /source
|
WORKDIR /source
|
||||||
|
|
||||||
# copy csproj and restore as distinct layers
|
# copy csproj and restore as distinct layers
|
||||||
@@ -11,7 +11,7 @@ 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 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
|
RUN date +%s > /app/buildtime.txt
|
||||||
# final stage/image
|
# final stage/image
|
||||||
FROM mcr.microsoft.com/dotnet/runtime-deps:7.0-alpine-amd64
|
FROM mcr.microsoft.com/dotnet/runtime-deps:6.0-alpine-amd64
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=build /app ./
|
COPY --from=build /app ./
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM mcr.microsoft.com/dotnet/sdk:7.0-alpine AS build
|
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy everything else and build
|
# Copy everything else and build
|
||||||
|
|||||||
19
fly.toml
19
fly.toml
@@ -1,6 +1,6 @@
|
|||||||
# fly.toml file generated for dry-meadow-9911 on 2022-11-09T12:09:05-05:00
|
# fly.toml file generated for tparnellblog on 2022-08-20T09:53:58-04:00
|
||||||
|
|
||||||
app = "dry-meadow-9911"
|
app = "tparnellblog"
|
||||||
kill_signal = "SIGINT"
|
kill_signal = "SIGINT"
|
||||||
kill_timeout = 5
|
kill_timeout = 5
|
||||||
processes = []
|
processes = []
|
||||||
@@ -10,6 +10,7 @@ processes = []
|
|||||||
[experimental]
|
[experimental]
|
||||||
allowed_public_ports = []
|
allowed_public_ports = []
|
||||||
auto_rollback = true
|
auto_rollback = true
|
||||||
|
private_network = true
|
||||||
|
|
||||||
[[services]]
|
[[services]]
|
||||||
http_checks = []
|
http_checks = []
|
||||||
@@ -18,8 +19,8 @@ processes = []
|
|||||||
protocol = "tcp"
|
protocol = "tcp"
|
||||||
script_checks = []
|
script_checks = []
|
||||||
[services.concurrency]
|
[services.concurrency]
|
||||||
hard_limit = 25
|
hard_limit = 200
|
||||||
soft_limit = 20
|
soft_limit = 100
|
||||||
type = "connections"
|
type = "connections"
|
||||||
|
|
||||||
[[services.ports]]
|
[[services.ports]]
|
||||||
@@ -27,12 +28,12 @@ processes = []
|
|||||||
handlers = ["http"]
|
handlers = ["http"]
|
||||||
port = 80
|
port = 80
|
||||||
|
|
||||||
# [[services.ports]]
|
[[services.ports]]
|
||||||
# handlers = ["tls", "http"]
|
handlers = ["tls", "http"]
|
||||||
# port = 443
|
port = 443
|
||||||
|
|
||||||
[[services.tcp_checks]]
|
[[services.tcp_checks]]
|
||||||
grace_period = "2s"
|
grace_period = "1s"
|
||||||
interval = "3s"
|
interval = "15s"
|
||||||
restart_limit = 0
|
restart_limit = 0
|
||||||
timeout = "2s"
|
timeout = "2s"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>netcoreapp7.0</TargetFramework>
|
<TargetFramework>netcoreapp6.0</TargetFramework>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<PackAsTool>true</PackAsTool>
|
<PackAsTool>true</PackAsTool>
|
||||||
<ToolCommandName>tempo</ToolCommandName>
|
<ToolCommandName>tempo</ToolCommandName>
|
||||||
|
|||||||
@@ -9,19 +9,16 @@ using System.IO;
|
|||||||
using Microsoft.AspNetCore.Html;
|
using Microsoft.AspNetCore.Html;
|
||||||
using TerribleDev.Blog.Web.Filters;
|
using TerribleDev.Blog.Web.Filters;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.AspNetCore.OutputCaching;
|
|
||||||
|
|
||||||
namespace TerribleDev.Blog.Web.Controllers
|
namespace TerribleDev.Blog.Web.Controllers
|
||||||
{
|
{
|
||||||
[Http2PushFilter]
|
[Http2PushFilter]
|
||||||
public class HomeController : Controller
|
public class HomeController : Controller
|
||||||
{
|
{
|
||||||
private readonly ILogger<HomeController> logger;
|
|
||||||
private readonly PostCache postCache;
|
private readonly PostCache postCache;
|
||||||
|
|
||||||
public HomeController(PostCache postCache, ILogger<HomeController> logger)
|
public HomeController(PostCache postCache)
|
||||||
{
|
{
|
||||||
this.logger = logger;
|
|
||||||
this.postCache = postCache;
|
this.postCache = postCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,26 +27,18 @@ namespace TerribleDev.Blog.Web.Controllers
|
|||||||
[Route("/index.html", Order = 2)]
|
[Route("/index.html", Order = 2)]
|
||||||
[Route("/")]
|
[Route("/")]
|
||||||
[Route("/page/{pageNumber:required:int:min(1)}")]
|
[Route("/page/{pageNumber:required:int:min(1)}")]
|
||||||
[OutputCache(Duration = 31536000, VaryByRouteValueNames = new string[] { "pageNumber" })]
|
[OutputCache(Duration = 31536000, VaryByParam = "pageNumber")]
|
||||||
[ResponseCache(Duration = 900)]
|
[ResponseCache(Duration = 900)]
|
||||||
public IActionResult Index(int pageNumber = 1)
|
public IActionResult Index(int pageNumber = 1)
|
||||||
{
|
{
|
||||||
this.logger.LogWarning("Viewing page", pageNumber);
|
if(!postCache.PostsByPage.TryGetValue(pageNumber, out var result))
|
||||||
if (!postCache.PostsByPage.TryGetValue(pageNumber, out var result))
|
|
||||||
{
|
{
|
||||||
return Redirect($"/404/?from=/page/{pageNumber}/");
|
return Redirect($"/404/?from=/page/{pageNumber}/");
|
||||||
}
|
}
|
||||||
return View(new HomeViewModel()
|
return View(new HomeViewModel() { Posts = result, Page = pageNumber, HasNext = postCache.PostsByPage.ContainsKey(pageNumber + 1), HasPrevious = postCache.PostsByPage.ContainsKey(pageNumber - 1),
|
||||||
{
|
BlogLD = postCache.BlogLD,
|
||||||
Posts = result,
|
SiteLD = postCache.SiteLD,
|
||||||
Page = pageNumber,
|
BlogLDString = postCache.BlogLDString, SiteLDString = postCache.SiteLDString });
|
||||||
HasNext = postCache.PostsByPage.ContainsKey(pageNumber + 1),
|
|
||||||
HasPrevious = postCache.PostsByPage.ContainsKey(pageNumber - 1),
|
|
||||||
BlogLD = postCache.BlogLD,
|
|
||||||
SiteLD = postCache.SiteLD,
|
|
||||||
BlogLDString = postCache.BlogLDString,
|
|
||||||
SiteLDString = postCache.SiteLDString
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
[Route("/theme/{postName?}")]
|
[Route("/theme/{postName?}")]
|
||||||
public IActionResult Theme(string postName)
|
public IActionResult Theme(string postName)
|
||||||
@@ -71,34 +60,28 @@ namespace TerribleDev.Blog.Web.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Route("{postUrl}/{amp?}")]
|
[Route("{postUrl}/{amp?}")]
|
||||||
[OutputCache(Duration = 31536000, VaryByRouteValueNames = new string[] { "postUrl", "amp" })]
|
[OutputCache(Duration = 31536000, VaryByParam = "postUrl,amp")]
|
||||||
[ResponseCache(Duration = 900)]
|
[ResponseCache(Duration = 900)]
|
||||||
public IActionResult Post(string postUrl, string amp = "")
|
public IActionResult Post(string postUrl, string amp = "")
|
||||||
{
|
{
|
||||||
if (!String.IsNullOrEmpty(amp) && amp != "amp")
|
if(!String.IsNullOrEmpty(amp) && amp != "amp")
|
||||||
{
|
{
|
||||||
return Redirect($"/404/?from=/{postUrl}/{amp}/");
|
return Redirect($"/404/?from=/{postUrl}/{amp}/");
|
||||||
}
|
}
|
||||||
var isAmp = amp == "amp";
|
var isAmp = amp == "amp";
|
||||||
if (isAmp)
|
if(isAmp)
|
||||||
{
|
{
|
||||||
return this.RedirectPermanent($"/{postUrl}");
|
return this.RedirectPermanent($"/{postUrl}");
|
||||||
}
|
}
|
||||||
// case sensitive lookup
|
if(postCache.UrlToPost.TryGetValue(postUrl, out var currentPost))
|
||||||
if (postCache.UrlToPost.TryGetValue(postUrl, out var currentPost))
|
|
||||||
{
|
{
|
||||||
return View("Post", model: new PostViewModel() { Post = currentPost });
|
return View("Post", model: new PostViewModel() { Post = currentPost });
|
||||||
}
|
}
|
||||||
// case insensitive lookup on post
|
if(postCache.LandingPagesUrl.TryGetValue(postUrl, out var landingPage))
|
||||||
if (postCache.CaseInsensitiveUrlToPost.TryGetValue(postUrl, out var caseInsensitivePost))
|
|
||||||
{
|
{
|
||||||
return View("Post", model: new PostViewModel() { Post = caseInsensitivePost });
|
return View("Post", model: new PostViewModel() { Post = landingPage });
|
||||||
}
|
}
|
||||||
if (postCache.LandingPagesUrl.TryGetValue(postUrl, out var landingPage))
|
|
||||||
{
|
|
||||||
return View("Post", model: new PostViewModel() { Post = landingPage });
|
|
||||||
}
|
|
||||||
|
|
||||||
this.StatusCode(404);
|
this.StatusCode(404);
|
||||||
return View(nameof(FourOhFour));
|
return View(nameof(FourOhFour));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ using System.Threading.Tasks;
|
|||||||
using System.Xml;
|
using System.Xml;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.OutputCaching;
|
|
||||||
using Microsoft.SyndicationFeed;
|
using Microsoft.SyndicationFeed;
|
||||||
using Microsoft.SyndicationFeed.Rss;
|
using Microsoft.SyndicationFeed.Rss;
|
||||||
using TerribleDev.Blog.Web.Models;
|
using TerribleDev.Blog.Web.Models;
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.OutputCaching;
|
|
||||||
using TerribleDev.Blog.Web.Filters;
|
using TerribleDev.Blog.Web.Filters;
|
||||||
using TerribleDev.Blog.Web.Models;
|
using TerribleDev.Blog.Web.Models;
|
||||||
|
|
||||||
@@ -25,7 +24,7 @@ namespace TerribleDev.Blog.Web.Controllers
|
|||||||
return View(postCache.TagsToPosts);
|
return View(postCache.TagsToPosts);
|
||||||
}
|
}
|
||||||
[Route("/tags/{tagName}")]
|
[Route("/tags/{tagName}")]
|
||||||
[OutputCache(Duration = 31536000, VaryByRouteValueNames = new string[]{"tagName"})]
|
[OutputCache(Duration = 31536000, VaryByParam = "tagName")]
|
||||||
public IActionResult TagPluralRedirect(string tagName)
|
public IActionResult TagPluralRedirect(string tagName)
|
||||||
{
|
{
|
||||||
if(string.IsNullOrEmpty(tagName))
|
if(string.IsNullOrEmpty(tagName))
|
||||||
@@ -35,7 +34,7 @@ namespace TerribleDev.Blog.Web.Controllers
|
|||||||
return Redirect($"/tag/{tagName}/");
|
return Redirect($"/tag/{tagName}/");
|
||||||
}
|
}
|
||||||
[Route("/tag/{tagName}")]
|
[Route("/tag/{tagName}")]
|
||||||
[OutputCache(Duration = 31536000, VaryByRouteValueNames = new string[] {"tagName"})]
|
[OutputCache(Duration = 31536000, VaryByParam = "tagName")]
|
||||||
public IActionResult GetTag(string tagName)
|
public IActionResult GetTag(string tagName)
|
||||||
{
|
{
|
||||||
if(!postCache.TagsToPosts.TryGetValue(tagName.ToLower(), out var models))
|
if(!postCache.TagsToPosts.TryGetValue(tagName.ToLower(), out var models))
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# https://hub.docker.com/_/microsoft-dotnet
|
# https://hub.docker.com/_/microsoft-dotnet
|
||||||
FROM mcr.microsoft.com/dotnet/sdk:7.0-alpine AS build
|
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
|
||||||
WORKDIR /source
|
WORKDIR /source
|
||||||
|
|
||||||
# copy csproj and restore as distinct layers
|
# copy csproj and restore as distinct layers
|
||||||
@@ -9,9 +9,9 @@ RUN dotnet restore -r linux-musl-x64 /p:PublishReadyToRunComposite=true
|
|||||||
# copy everything else and build app
|
# copy everything else and build app
|
||||||
COPY . .
|
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 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
|
# final stage/image
|
||||||
FROM mcr.microsoft.com/dotnet/runtime-deps:7.0-alpine-amd64
|
FROM mcr.microsoft.com/dotnet/runtime-deps:6.0-alpine-amd64
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=build /app ./
|
COPY --from=build /app ./
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ namespace TerribleDev.Blog.Web.Factories
|
|||||||
var orderedPosts = rawPosts.OrderByDescending(a => a.PublishDate);
|
var orderedPosts = rawPosts.OrderByDescending(a => a.PublishDate);
|
||||||
var posts = new List<IPost>(orderedPosts);
|
var posts = new List<IPost>(orderedPosts);
|
||||||
var urlToPosts = new Dictionary<string, IPost>();
|
var urlToPosts = new Dictionary<string, IPost>();
|
||||||
var caseInsensitiveUrlToPost = new Dictionary<string, IPost>(StringComparer.OrdinalIgnoreCase);
|
|
||||||
var tagsToPost = new Dictionary<string, IList<Post>>();
|
var tagsToPost = new Dictionary<string, IList<Post>>();
|
||||||
var postsByPage = new Dictionary<int, IList<Post>>();
|
var postsByPage = new Dictionary<int, IList<Post>>();
|
||||||
var syndicationPosts = new List<SyndicationItem>();
|
var syndicationPosts = new List<SyndicationItem>();
|
||||||
@@ -31,7 +30,6 @@ namespace TerribleDev.Blog.Web.Factories
|
|||||||
{
|
{
|
||||||
var castedPost = post as Post;
|
var castedPost = post as Post;
|
||||||
urlToPosts.Add(post.UrlWithoutPath, castedPost);
|
urlToPosts.Add(post.UrlWithoutPath, castedPost);
|
||||||
caseInsensitiveUrlToPost.Add(post.UrlWithoutPath.ToLower(), castedPost);
|
|
||||||
syndicationPosts.Add(castedPost.ToSyndicationItem());
|
syndicationPosts.Add(castedPost.ToSyndicationItem());
|
||||||
blogPostsLD.Add(post.Content.JsonLD);
|
blogPostsLD.Add(post.Content.JsonLD);
|
||||||
foreach (var tag in castedPost.ToNormalizedTagList())
|
foreach (var tag in castedPost.ToNormalizedTagList())
|
||||||
@@ -124,8 +122,8 @@ namespace TerribleDev.Blog.Web.Factories
|
|||||||
BlogLD = ld,
|
BlogLD = ld,
|
||||||
SiteLD = website,
|
SiteLD = website,
|
||||||
BlogLDString = ld.ToHtmlEscapedString().Replace("https://schema.org", "https://schema.org/true"),
|
BlogLDString = ld.ToHtmlEscapedString().Replace("https://schema.org", "https://schema.org/true"),
|
||||||
SiteLDString = website.ToHtmlEscapedString().Replace("https://schema.org", "https://schema.org/true"),
|
SiteLDString = website.ToHtmlEscapedString().Replace("https://schema.org", "https://schema.org/true")
|
||||||
CaseInsensitiveUrlToPost = caseInsensitiveUrlToPost
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ namespace TerribleDev.Blog.Web.Factories
|
|||||||
if(!codeContent.IsSuccessStatusCode)
|
if(!codeContent.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine("Error posting code to prisma");
|
Console.Error.WriteLine("Error posting code to prisma");
|
||||||
|
Console.Error.WriteLine("status code: " + codeContent.StatusCode);
|
||||||
}
|
}
|
||||||
return (code, await codeContent.Content.ReadAsStringAsync());
|
return (code, await codeContent.Content.ReadAsStringAsync());
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -8,13 +8,8 @@ namespace TerribleDev.Blog.Web.Filters
|
|||||||
{
|
{
|
||||||
public class Http2PushFilter : ActionFilterAttribute
|
public class Http2PushFilter : ActionFilterAttribute
|
||||||
{
|
{
|
||||||
private static bool IsHttp2PushDisabled = String.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("DISABLE_HTTP2_PUSH"));
|
public override void OnResultExecuted(ResultExecutedContext context)
|
||||||
public override void OnActionExecuted(ActionExecutedContext context)
|
|
||||||
{
|
{
|
||||||
if(IsHttp2PushDisabled)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var logger = context.HttpContext.RequestServices.GetService(typeof(ILogger<Http2PushFilter>)) as ILogger<Http2PushFilter>;
|
var logger = context.HttpContext.RequestServices.GetService(typeof(ILogger<Http2PushFilter>)) as ILogger<Http2PushFilter>;
|
||||||
logger.LogDebug("Http2PushFilter.OnActionExecuted");
|
logger.LogDebug("Http2PushFilter.OnActionExecuted");
|
||||||
if(!context.HttpContext.Items.TryGetValue(HttpPush.Key, out var links))
|
if(!context.HttpContext.Items.TryGetValue(HttpPush.Key, out var links))
|
||||||
@@ -38,7 +33,6 @@ namespace TerribleDev.Blog.Web.Filters
|
|||||||
}
|
}
|
||||||
logger.LogDebug("Http2PushFilter.OnActionExecuted: " + headerBuilder.ToString());
|
logger.LogDebug("Http2PushFilter.OnActionExecuted: " + headerBuilder.ToString());
|
||||||
context.HttpContext.Response.Headers.Add("Link", headerBuilder.ToString());
|
context.HttpContext.Response.Headers.Add("Link", headerBuilder.ToString());
|
||||||
base.OnActionExecuted(context);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,6 @@ namespace TerribleDev.Blog.Web.Models
|
|||||||
public IList<IPost> PostsAsLists { get; set;}
|
public IList<IPost> PostsAsLists { get; set;}
|
||||||
public IDictionary<string, IList<Post>> TagsToPosts { get; set; }
|
public IDictionary<string, IList<Post>> TagsToPosts { get; set; }
|
||||||
public IDictionary<string, IPost> UrlToPost { get; set; }
|
public IDictionary<string, IPost> UrlToPost { get; set; }
|
||||||
public IDictionary<string, IPost> CaseInsensitiveUrlToPost { get; set; }
|
|
||||||
public IDictionary<int, IList<Post>> PostsByPage { get; set; }
|
public IDictionary<int, IList<Post>> PostsByPage { get; set; }
|
||||||
public IList<SyndicationItem> PostsAsSyndication { get; set; }
|
public IList<SyndicationItem> PostsAsSyndication { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ using HardHat;
|
|||||||
using TerribleDev.Blog.Web.Models;
|
using TerribleDev.Blog.Web.Models;
|
||||||
using TerribleDev.Blog.Web.Factories;
|
using TerribleDev.Blog.Web.Factories;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using WebMarkupMin.AspNetCore7;
|
using WebMarkupMin.AspNetCore6;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using TerribleDev.Blog.Web.Filters;
|
using TerribleDev.Blog.Web.Filters;
|
||||||
|
|
||||||
@@ -68,23 +68,16 @@ namespace TerribleDev.Blog.Web
|
|||||||
controllerBuilder.AddRazorRuntimeCompilation();
|
controllerBuilder.AddRazorRuntimeCompilation();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
services
|
services.AddResponseCompression(a =>
|
||||||
.AddResponseCompression(a =>
|
|
||||||
{
|
{
|
||||||
a.EnableForHttps = true;
|
a.EnableForHttps = true;
|
||||||
|
|
||||||
})
|
})
|
||||||
.AddResponseCaching()
|
|
||||||
.AddMemoryCache();
|
.AddMemoryCache();
|
||||||
// if(Env.IsProduction())
|
if(Env.IsProduction())
|
||||||
// {
|
{
|
||||||
|
services.AddOutputCaching();
|
||||||
// }
|
}
|
||||||
services.AddOutputCache(a =>{
|
|
||||||
a.AddBasePolicy(b => {
|
|
||||||
b.Cache();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
services.AddWebMarkupMin(a => {
|
services.AddWebMarkupMin(a => {
|
||||||
a.AllowMinificationInDevelopmentEnvironment = true;
|
a.AllowMinificationInDevelopmentEnvironment = true;
|
||||||
a.DisablePoweredByHttpHeaders = true;
|
a.DisablePoweredByHttpHeaders = true;
|
||||||
@@ -97,15 +90,19 @@ namespace TerribleDev.Blog.Web
|
|||||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||||
{
|
{
|
||||||
Console.WriteLine("ETag Detected As: " + StaticETag.staticEtag);
|
Console.WriteLine("ETag Detected As: " + StaticETag.staticEtag);
|
||||||
|
if (env.IsDevelopment())
|
||||||
|
{
|
||||||
|
app.UseDeveloperExceptionPage();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
app.UseExceptionHandler("/Error");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
if (env.IsProduction())
|
|
||||||
{
|
|
||||||
app.UseOutputCache();
|
|
||||||
app.UseResponseCaching();
|
|
||||||
}
|
|
||||||
app.UseResponseCompression();
|
app.UseResponseCompression();
|
||||||
var cacheTime = env.IsDevelopment() ? 1 : 31536000;
|
var cacheTime = env.IsDevelopment() ? 0 : 31536000;
|
||||||
app.UseStaticFiles(new StaticFileOptions
|
app.UseStaticFiles(new StaticFileOptions
|
||||||
{
|
{
|
||||||
OnPrepareResponse = ctx =>
|
OnPrepareResponse = ctx =>
|
||||||
@@ -123,16 +120,6 @@ namespace TerribleDev.Blog.Web
|
|||||||
"public,max-age=" + cacheTime;
|
"public,max-age=" + cacheTime;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (env.IsDevelopment())
|
|
||||||
{
|
|
||||||
app.UseDeveloperExceptionPage();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
app.UseExceptionHandler("/Error");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
app.UseRewriter(new Microsoft.AspNetCore.Rewrite.RewriteOptions().AddRedirect("(.*[^/|.xml|.html])$", "$1/", 301));
|
app.UseRewriter(new Microsoft.AspNetCore.Rewrite.RewriteOptions().AddRedirect("(.*[^/|.xml|.html])$", "$1/", 301));
|
||||||
app.UseIENoOpen();
|
app.UseIENoOpen();
|
||||||
app.UseNoMimeSniff();
|
app.UseNoMimeSniff();
|
||||||
@@ -155,6 +142,20 @@ namespace TerribleDev.Blog.Web
|
|||||||
// },
|
// },
|
||||||
UpgradeInsecureRequests = true
|
UpgradeInsecureRequests = true
|
||||||
});
|
});
|
||||||
|
app.Use(async (context, next) => {
|
||||||
|
var etag = context.Request.Headers.IfNoneMatch.ToString();
|
||||||
|
if(etag != null && string.Equals(etag, StaticETag.staticEtag, StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
context.Response.StatusCode = 304;
|
||||||
|
await context.Response.CompleteAsync();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await next();
|
||||||
|
});
|
||||||
|
if(Env.IsProduction())
|
||||||
|
{
|
||||||
|
app.UseOutputCaching();
|
||||||
|
}
|
||||||
app.UseWebMarkupMin();
|
app.UseWebMarkupMin();
|
||||||
app.UseRouting();
|
app.UseRouting();
|
||||||
app.UseEndpoints(endpoints =>
|
app.UseEndpoints(endpoints =>
|
||||||
@@ -163,4 +164,4 @@ namespace TerribleDev.Blog.Web
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ namespace TerribleDev.Blog.Web.Taghelpers
|
|||||||
public record PushUrl(string Url, string asProperty);
|
public record PushUrl(string Url, string asProperty);
|
||||||
[HtmlTargetElement("link", Attributes = "[rel=stylesheet],href,push")]
|
[HtmlTargetElement("link", Attributes = "[rel=stylesheet],href,push")]
|
||||||
[HtmlTargetElement("img", Attributes = "src,push")]
|
[HtmlTargetElement("img", Attributes = "src,push")]
|
||||||
[HtmlTargetElement("script", Attributes = "src,push")]
|
|
||||||
public class HttpPush : LinkTagHelper
|
public class HttpPush : LinkTagHelper
|
||||||
{
|
{
|
||||||
[HtmlAttributeNotBound]
|
[HtmlAttributeNotBound]
|
||||||
@@ -29,11 +28,9 @@ namespace TerribleDev.Blog.Web.Taghelpers
|
|||||||
}
|
}
|
||||||
|
|
||||||
private (string Url, string AsProperty) GetTagInfo(string tag) =>
|
private (string Url, string AsProperty) GetTagInfo(string tag) =>
|
||||||
tag switch
|
tag switch {
|
||||||
{
|
|
||||||
"link" => ("href", "link"),
|
"link" => ("href", "link"),
|
||||||
"img" => ("src", "image"),
|
"img" => ("src", "image"),
|
||||||
"script" => ("src", "script"),
|
|
||||||
_ => (null, null)
|
_ => (null, null)
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -44,6 +41,7 @@ namespace TerribleDev.Blog.Web.Taghelpers
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var (urlAttribute, asProperty) = GetTagInfo(output.TagName);
|
var (urlAttribute, asProperty) = GetTagInfo(output.TagName);
|
||||||
|
// var urlAttribute = context.TagName == "link" ? "href" : "src";
|
||||||
var url = base.TryResolveUrl(output.Attributes[urlAttribute].Value.ToString(), out string resolvedUrl) ? resolvedUrl : output.Attributes[urlAttribute].Value.ToString();
|
var url = base.TryResolveUrl(output.Attributes[urlAttribute].Value.ToString(), out string resolvedUrl) ? resolvedUrl : output.Attributes[urlAttribute].Value.ToString();
|
||||||
var linkList = ViewContext.HttpContext.Items.TryGetValue(Key, out var links) ? links as List<PushUrl> : null;
|
var linkList = ViewContext.HttpContext.Items.TryGetValue(Key, out var links) ? links as List<PushUrl> : null;
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
|
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
|
||||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
<RuntimeIdentifiers>linux-musl-x64</RuntimeIdentifiers>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Remove="compilerconfig.json" />
|
<Content Remove="compilerconfig.json" />
|
||||||
<Content Remove="bundleconfig.json" />
|
<Content Remove="bundleconfig.json" />
|
||||||
@@ -23,11 +21,12 @@
|
|||||||
<PackageReference Include="Markdig" Version="0.15.7" />
|
<PackageReference Include="Markdig" Version="0.15.7" />
|
||||||
<PackageReference Include="Schema.NET" Version="11.0.1" />
|
<PackageReference Include="Schema.NET" Version="11.0.1" />
|
||||||
<PackageReference Include="UriBuilder.Fluent" Version="1.5.2" />
|
<PackageReference Include="UriBuilder.Fluent" Version="1.5.2" />
|
||||||
<PackageReference Include="WebMarkupMin.AspNetCore7" Version="2.13.0-rc1" />
|
<PackageReference Include="WebMarkupMin.AspNetCore6" Version="2.11.0" />
|
||||||
<PackageReference Include="YamlDotNet" Version="5.3.0" />
|
<PackageReference Include="YamlDotNet" Version="5.3.0" />
|
||||||
<PackageReference Include="HardHat" Version="2.1.1" />
|
<PackageReference Include="HardHat" Version="2.1.1" />
|
||||||
<PackageReference Include="Microsoft.SyndicationFeed.ReaderWriter" Version="1.0.2" />
|
<PackageReference Include="Microsoft.SyndicationFeed.ReaderWriter" Version="1.0.2" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="7.0.0" Condition="'$(Configuration)' == 'Debug'" />
|
<PackageReference Include="WebEssentials.AspNetCore.OutputCaching" Version="1.0.16" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="6.0.1" Condition="'$(Configuration)' == 'Debug'" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<li><a href="https://github.com/terribledev" rel="noopener" target="_blank" class="link-unstyled">Github</a></li>
|
<li><a href="https://github.com/terribledev" rel="noopener" target="_blank" class="link-unstyled">Github</a></li>
|
||||||
<li><a href="https://twitter.com/terribledev" rel="noopener" target="_blank" class="link-unstyled">Twitter</a></li>
|
<li><a href="https://twitter.com/terribledev" rel="noopener" target="_blank" class="link-unstyled">Twitter</a></li>
|
||||||
<li><a href="mailto:tommy@terribledev.io" class="link-unstyled">Email</a></li>
|
<li><a href="mailto:tommy@terribledev.io" class="link-unstyled">Email</a></li>
|
||||||
<li><span onclick="toggleNav()" class="link-unstyled" id="closeNav">Close Navbar</span></li>
|
<li><span class="link-unstyled" id="closeNav">Close Navbar</span></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
<a class="skip-main" href="#main">Skip to main content</a>
|
<a class="skip-main" href="#main">Skip to main content</a>
|
||||||
<div class="rootbox">
|
<div class="rootbox">
|
||||||
<header class="header">
|
<header class="header">
|
||||||
<svg aria-label="Open Menu" onclick="toggleNav()" id="menuBtn" role="button" xmlns="http://www.w3.org/2000/svg" width="32" height="32"><path d="M4 10h24c1.104 0 2-.896 2-2s-.896-2-2-2H4c-1.104 0-2 .896-2 2s.896 2 2 2zm24 4H4c-1.104 0-2 .896-2 2s.896 2 2 2h24c1.104 0 2-.896 2-2s-.896-2-2-2zm0 8H4c-1.104 0-2 .896-2 2s.896 2 2 2h24c1.104 0 2-.896 2-2s-.896-2-2-2z"/></svg>
|
<svg aria-label="Open Menu" id="menuBtn" role="button" xmlns="http://www.w3.org/2000/svg" width="32" height="32"><path d="M4 10h24c1.104 0 2-.896 2-2s-.896-2-2-2H4c-1.104 0-2 .896-2 2s.896 2 2 2zm24 4H4c-1.104 0-2 .896-2 2s.896 2 2 2h24c1.104 0 2-.896 2-2s-.896-2-2-2zm0 8H4c-1.104 0-2 .896-2 2s.896 2 2 2h24c1.104 0 2-.896 2-2s-.896-2-2-2z" /></svg>
|
||||||
<div class="headerCallout"><a href="/" class="link-unstyled ">@config.Title</a></div>
|
<div class="headerCallout"><a href="/" class="link-unstyled ">@config.Title</a></div>
|
||||||
</header>
|
</header>
|
||||||
<partial name="Nav" />
|
<partial name="Nav" />
|
||||||
@@ -53,10 +53,10 @@
|
|||||||
</div>
|
</div>
|
||||||
@RenderSection("Scripts", required: false)
|
@RenderSection("Scripts", required: false)
|
||||||
<environment names="Development">
|
<environment names="Development">
|
||||||
<script push asp-append-version="true" src="~/js/swi.js" async></script>
|
<script asp-append-version="true" src="~/js/swi.js" async></script>
|
||||||
</environment>
|
</environment>
|
||||||
<environment names="Production">
|
<environment names="Production">
|
||||||
<script push asp-append-version="true" src="~/js/site.min.js" async></script>
|
<script asp-append-version="true" src="~/js/site.min.js" async></script>
|
||||||
</environment>
|
</environment>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
|
|
||||||
@media (prefers-color-scheme: dark) {
|
@media (prefers-color-scheme: dark) {
|
||||||
:root {
|
:root {
|
||||||
--headline: #f0f0f0;
|
--hln: #f0f0f0;
|
||||||
--body-text-color: #ffffff;
|
--bdy-txt-clr: #ffffff;
|
||||||
--block-quote-left-border: #d1dced;
|
--blk-qt-lb: #d1dced;
|
||||||
--code-block-background-color: #4a4a4a;
|
--code-blk-bg-clr: #4a4a4a;
|
||||||
--primary-background: #323131;
|
--pmry-bknd: #323131;
|
||||||
--link-color: #3faff9;
|
--lnk-clr: #3faff9;
|
||||||
/* --link-visited: #d8dbde; */
|
/* --lnk-vistd: #d8dbde; */
|
||||||
--border-color: #bdcad2;
|
--bc: #bdcad2;
|
||||||
--horizontal-rule: #626468;
|
--hr: #626468;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,18 +1,19 @@
|
|||||||
:root {
|
:root {
|
||||||
--headline: #4a4a4a;
|
--hln: #4a4a4a;
|
||||||
--body-text-color: #5d686f;
|
--bdy-txt-clr: #5d686f;
|
||||||
--block-quote-left-border: #d1dced;
|
--blk-qt-lb: #d1dced;
|
||||||
--code-block-background-color: #f5f5f5;
|
--code-blk-bg-clr: #f5f5f5;
|
||||||
--primary-background: #FFFFFF;
|
--pmry-bknd: #FFFFFF;
|
||||||
--link-color: #00558d;
|
--lnk-clr: #00558d;
|
||||||
--link-visited: var(--link-color);
|
--lnk-vistd: var(--lnk-clr);
|
||||||
/* --link-visited: #6c6c6c; */
|
/* --lnk-vistd: #6c6c6c; */
|
||||||
--border-color: #738691;
|
--bc: #738691;
|
||||||
--horizontal-rule: #dfe2e7;
|
--hr: #dfe2e7;
|
||||||
--nav-bar-background: var(--headline);
|
--nb-bkgd: var(--hln);
|
||||||
--nav-bar-text-color: var(--primary-background);
|
--nb-txt-color: var(--pmry-bknd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
html {
|
html {
|
||||||
font-family: Arial, Helvetica, sans-serif;
|
font-family: Arial, Helvetica, sans-serif;
|
||||||
}
|
}
|
||||||
@@ -23,7 +24,7 @@ h3,
|
|||||||
h4,
|
h4,
|
||||||
h5,
|
h5,
|
||||||
h6 {
|
h6 {
|
||||||
color: var(--headline);
|
color: var(--hln);
|
||||||
line-height: 1.45;
|
line-height: 1.45;
|
||||||
letter-spacing: -0.01em;
|
letter-spacing: -0.01em;
|
||||||
line-height: 1.25em;
|
line-height: 1.25em;
|
||||||
@@ -37,8 +38,8 @@ body {
|
|||||||
text-rendering: optimizeLegibility;
|
text-rendering: optimizeLegibility;
|
||||||
letter-spacing: -0.01em;
|
letter-spacing: -0.01em;
|
||||||
line-height: 1.9rem;
|
line-height: 1.9rem;
|
||||||
background-color: var(--primary-background);
|
background-color: var(--pmry-bknd);
|
||||||
color: var(--body-text-color);
|
color: var(--bdy-txt-clr);
|
||||||
font-size: 1.125rem;
|
font-size: 1.125rem;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
@@ -73,7 +74,7 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
blockquote {
|
blockquote {
|
||||||
border-left: 2px solid var(--block-quote-left-border);
|
border-left: 2px solid var(--blk-qt-lb);
|
||||||
padding: 0.4em 1.2em;
|
padding: 0.4em 1.2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +84,7 @@ pre {
|
|||||||
font-family: "Courier New", Courier, monospace;
|
font-family: "Courier New", Courier, monospace;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
background: var(--code-block-background-color);
|
background: var(--code-blk-bg-clr);
|
||||||
padding: 0 0.4em;
|
padding: 0 0.4em;
|
||||||
overflow-x: scroll;
|
overflow-x: scroll;
|
||||||
letter-spacing: .02em;
|
letter-spacing: .02em;
|
||||||
@@ -95,16 +96,16 @@ pre > code {
|
|||||||
}
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: var(--link-color);
|
color: var(--lnk-clr);
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
}
|
}
|
||||||
|
|
||||||
a:visited {
|
a:visited {
|
||||||
color: var(--link-visited);
|
color: var(--lnk-vistd);
|
||||||
}
|
}
|
||||||
|
|
||||||
.btmRule {
|
.btmRule {
|
||||||
border-bottom: 1px solid var(--horizontal-rule);
|
border-bottom: 1px solid var(--hr);
|
||||||
padding-bottom: 3rem;
|
padding-bottom: 3rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,8 +113,8 @@ a:visited {
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
background: var(--nav-bar-background);
|
background: var(--nb-bkgd);
|
||||||
color: var(--nav-bar-text-color);
|
color: var(--nb-txt-color);
|
||||||
padding-top: 20px;
|
padding-top: 20px;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
z-index: 40;
|
z-index: 40;
|
||||||
@@ -127,9 +128,9 @@ a:visited {
|
|||||||
.header {
|
.header {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
border-bottom: 1px solid var(--horizontal-rule);
|
border-bottom: 1px solid var(--hr);
|
||||||
color: var(--headline);
|
color: var(--hln);
|
||||||
background-color: var(--primary-background);
|
background-color: var(--pmry-bknd);
|
||||||
z-index: 20;
|
z-index: 20;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@@ -172,21 +173,21 @@ a:visited {
|
|||||||
.btn {
|
.btn {
|
||||||
width: auto;
|
width: auto;
|
||||||
height: auto;
|
height: auto;
|
||||||
background: var(--primary-background);
|
background: var(--pmry-bknd);
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
color: var(--body-text-color);
|
color: var(--bdy-txt-clr);
|
||||||
border: 1px solid var(--body-text-color);
|
border: 1px solid var(--bdy-txt-clr);
|
||||||
padding: 0.3em 0.2em;
|
padding: 0.3em 0.2em;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
font-size: 1.1rem;
|
font-size: 1.1rem;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
}
|
}
|
||||||
.btn:visited {
|
.btn:visited {
|
||||||
background: var(--primary-background);
|
background: var(--pmry-bknd);
|
||||||
color: var(--border-color);
|
color: var(--bc);
|
||||||
border: 1px solid var(--border-color);
|
border: 1px solid var(--bc);
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn.block {
|
.btn.block {
|
||||||
|
|||||||
@@ -1,16 +1,17 @@
|
|||||||
//Add this below content to your HTML page, or add the js file to your page at the very top to register sercie worker
|
//Add this below content to your HTML page, or add the js file to your page at the very top to register sercie worker
|
||||||
if (navigator && navigator.serviceWorker && navigator.serviceWorker.controller) {
|
if (navigator && navigator.serviceWorker && navigator.serviceWorker.controller) {
|
||||||
|
console.log('[PWA Builder] active service worker found, no need to register')
|
||||||
} else if (navigator && navigator.serviceWorker) {
|
} else if (navigator && navigator.serviceWorker) {
|
||||||
|
|
||||||
//Register the ServiceWorker
|
//Register the ServiceWorker
|
||||||
navigator.serviceWorker.register('/sw.min.js', {
|
navigator.serviceWorker.register('/sw.min.js', {
|
||||||
scope: '/'
|
scope: '/'
|
||||||
}).then(() => {
|
}).then(function (reg) {
|
||||||
console.log('SW');
|
console.log('Service worker has been registered for scope:' + reg.scope);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleNav () {
|
var toggleNav = function () {
|
||||||
var nav = document.getElementById('navBar');
|
var nav = document.getElementById('navBar');
|
||||||
if (!nav) {
|
if (!nav) {
|
||||||
return;
|
return;
|
||||||
@@ -22,4 +23,15 @@ function toggleNav () {
|
|||||||
else {
|
else {
|
||||||
nav.classList.add('hide');
|
nav.classList.add('hide');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function attachNavToggle(elementId) {
|
||||||
|
var menuButton = document.getElementById(elementId);
|
||||||
|
if (menuButton) {
|
||||||
|
menuButton.addEventListener('click', function () {
|
||||||
|
toggleNav();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
attachNavToggle('menuBtn');
|
||||||
|
attachNavToggle('closeNav');
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,2 @@
|
|||||||
User-agent: *
|
User-agent: *
|
||||||
Allow: /
|
Allow: /
|
||||||
Sitemap: https://blog.terrible.dev/sitemap.xml
|
|
||||||
Reference in New Issue
Block a user