Compare commits
12 Commits
backup-nav
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a74dec639a | ||
|
|
f93aea2696 | ||
|
|
63828b3003 | ||
|
|
1b372b3501 | ||
|
|
5edba65844 | ||
|
|
afcae26bc1 | ||
|
|
5a253f6ada | ||
|
|
e8c548ab20 | ||
|
|
0871e037d8 | ||
|
|
a5931f48c6 | ||
|
|
2cff53f5d3 | ||
|
|
e065871145 |
@@ -4,6 +4,6 @@
|
|||||||
.gitignore
|
.gitignore
|
||||||
.vs
|
.vs
|
||||||
.vscode
|
.vscode
|
||||||
*/bin
|
**/bin
|
||||||
*/obj
|
**/obj
|
||||||
**/.toolstarget
|
**/.toolstarget
|
||||||
42
.github/workflows/blogcontainergroup-AutoDeployTrigger-ab8fcfc6-eced-47ac-8584-4f5a983b4ee2.yml
vendored
Normal file
42
.github/workflows/blogcontainergroup-AutoDeployTrigger-ab8fcfc6-eced-47ac-8584-4f5a983b4ee2.yml
vendored
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
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
51
.github/workflows/master_tparnellbloglinux.yml
vendored
@@ -1,51 +0,0 @@
|
|||||||
# 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 }}'
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
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/netcoreapp3.1/TerribleDev.Blog.Web.dll",
|
"program": "${workspaceFolder}/src/TerribleDev.Blog.Web/bin/Debug/net7.0/TerribleDev.Blog.Web.dll",
|
||||||
"args": [],
|
"args": [],
|
||||||
"cwd": "${workspaceFolder}/src/TerribleDev.Blog.Web",
|
"cwd": "${workspaceFolder}/src/TerribleDev.Blog.Web",
|
||||||
"stopAtEntry": false,
|
"stopAtEntry": false,
|
||||||
|
|||||||
37
Dockerfile
37
Dockerfile
@@ -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:7.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:7.0-alpine-amd64
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
COPY --from=build /app ./
|
||||||
|
|
||||||
# Copy csproj and restore as distinct layers
|
# See: https://github.com/dotnet/announcements/issues/20
|
||||||
COPY *.sln .
|
# Uncomment to enable globalization APIs (or delete)
|
||||||
COPY . .
|
# ENV \
|
||||||
RUN dotnet restore
|
# 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
|
ENTRYPOINT ["./TerribleDev.Blog.Web"]
|
||||||
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"]
|
|
||||||
12
Dockerfile.old
Normal file
12
Dockerfile.old
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
FROM mcr.microsoft.com/dotnet/sdk:7.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"]
|
||||||
38
fly.toml
Normal file
38
fly.toml
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
# fly.toml file generated for dry-meadow-9911 on 2022-11-09T12:09:05-05:00
|
||||||
|
|
||||||
|
app = "dry-meadow-9911"
|
||||||
|
kill_signal = "SIGINT"
|
||||||
|
kill_timeout = 5
|
||||||
|
processes = []
|
||||||
|
|
||||||
|
[env]
|
||||||
|
|
||||||
|
[experimental]
|
||||||
|
allowed_public_ports = []
|
||||||
|
auto_rollback = true
|
||||||
|
|
||||||
|
[[services]]
|
||||||
|
http_checks = []
|
||||||
|
internal_port = 80
|
||||||
|
processes = ["app"]
|
||||||
|
protocol = "tcp"
|
||||||
|
script_checks = []
|
||||||
|
[services.concurrency]
|
||||||
|
hard_limit = 25
|
||||||
|
soft_limit = 20
|
||||||
|
type = "connections"
|
||||||
|
|
||||||
|
[[services.ports]]
|
||||||
|
force_https = true
|
||||||
|
handlers = ["http"]
|
||||||
|
port = 80
|
||||||
|
|
||||||
|
# [[services.ports]]
|
||||||
|
# handlers = ["tls", "http"]
|
||||||
|
# port = 443
|
||||||
|
|
||||||
|
[[services.tcp_checks]]
|
||||||
|
grace_period = "2s"
|
||||||
|
interval = "3s"
|
||||||
|
restart_limit = 0
|
||||||
|
timeout = "2s"
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>netcoreapp6.0</TargetFramework>
|
<TargetFramework>netcoreapp7.0</TargetFramework>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<PackAsTool>true</PackAsTool>
|
<PackAsTool>true</PackAsTool>
|
||||||
<ToolCommandName>tempo</ToolCommandName>
|
<ToolCommandName>tempo</ToolCommandName>
|
||||||
|
|||||||
@@ -9,16 +9,19 @@ 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)
|
public HomeController(PostCache postCache, ILogger<HomeController> logger)
|
||||||
{
|
{
|
||||||
|
this.logger = logger;
|
||||||
this.postCache = postCache;
|
this.postCache = postCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,18 +30,26 @@ 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, VaryByParam = "pageNumber")]
|
[OutputCache(Duration = 31536000, VaryByRouteValueNames = new string[] { "pageNumber" })]
|
||||||
[ResponseCache(Duration = 900)]
|
[ResponseCache(Duration = 900)]
|
||||||
public IActionResult Index(int pageNumber = 1)
|
public IActionResult Index(int pageNumber = 1)
|
||||||
{
|
{
|
||||||
if(!postCache.PostsByPage.TryGetValue(pageNumber, out var result))
|
this.logger.LogWarning("Viewing page", pageNumber);
|
||||||
|
if (!postCache.PostsByPage.TryGetValue(pageNumber, out var result))
|
||||||
{
|
{
|
||||||
return Redirect($"/404/?from=/page/{pageNumber}/");
|
return Redirect($"/404/?from=/page/{pageNumber}/");
|
||||||
}
|
}
|
||||||
return View(new HomeViewModel() { Posts = result, Page = pageNumber, HasNext = postCache.PostsByPage.ContainsKey(pageNumber + 1), HasPrevious = postCache.PostsByPage.ContainsKey(pageNumber - 1),
|
return View(new HomeViewModel()
|
||||||
BlogLD = postCache.BlogLD,
|
{
|
||||||
SiteLD = postCache.SiteLD,
|
Posts = result,
|
||||||
BlogLDString = postCache.BlogLDString, SiteLDString = postCache.SiteLDString });
|
Page = pageNumber,
|
||||||
|
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)
|
||||||
@@ -60,28 +71,34 @@ namespace TerribleDev.Blog.Web.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Route("{postUrl}/{amp?}")]
|
[Route("{postUrl}/{amp?}")]
|
||||||
[OutputCache(Duration = 31536000, VaryByParam = "postUrl,amp")]
|
[OutputCache(Duration = 31536000, VaryByRouteValueNames = new string[] { "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}");
|
||||||
}
|
}
|
||||||
if(postCache.UrlToPost.TryGetValue(postUrl, out var currentPost))
|
// case sensitive lookup
|
||||||
|
if (postCache.UrlToPost.TryGetValue(postUrl, out var currentPost))
|
||||||
{
|
{
|
||||||
return View("Post", model: new PostViewModel() { Post = currentPost });
|
return View("Post", model: new PostViewModel() { Post = currentPost });
|
||||||
}
|
}
|
||||||
if(postCache.LandingPagesUrl.TryGetValue(postUrl, out var landingPage))
|
// case insensitive lookup on post
|
||||||
|
if (postCache.CaseInsensitiveUrlToPost.TryGetValue(postUrl, out var caseInsensitivePost))
|
||||||
{
|
{
|
||||||
return View("Post", model: new PostViewModel() { Post = landingPage });
|
return View("Post", model: new PostViewModel() { Post = caseInsensitivePost });
|
||||||
}
|
}
|
||||||
|
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,6 +7,7 @@ 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,6 +3,7 @@ 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;
|
||||||
|
|
||||||
@@ -24,7 +25,7 @@ namespace TerribleDev.Blog.Web.Controllers
|
|||||||
return View(postCache.TagsToPosts);
|
return View(postCache.TagsToPosts);
|
||||||
}
|
}
|
||||||
[Route("/tags/{tagName}")]
|
[Route("/tags/{tagName}")]
|
||||||
[OutputCache(Duration = 31536000, VaryByParam = "tagName")]
|
[OutputCache(Duration = 31536000, VaryByRouteValueNames = new string[]{"tagName"})]
|
||||||
public IActionResult TagPluralRedirect(string tagName)
|
public IActionResult TagPluralRedirect(string tagName)
|
||||||
{
|
{
|
||||||
if(string.IsNullOrEmpty(tagName))
|
if(string.IsNullOrEmpty(tagName))
|
||||||
@@ -34,7 +35,7 @@ namespace TerribleDev.Blog.Web.Controllers
|
|||||||
return Redirect($"/tag/{tagName}/");
|
return Redirect($"/tag/{tagName}/");
|
||||||
}
|
}
|
||||||
[Route("/tag/{tagName}")]
|
[Route("/tag/{tagName}")]
|
||||||
[OutputCache(Duration = 31536000, VaryByParam = "tagName")]
|
[OutputCache(Duration = 31536000, VaryByRouteValueNames = new string[] {"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:6.0-alpine AS build
|
FROM mcr.microsoft.com/dotnet/sdk:7.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 . .
|
|||||||
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
|
||||||
|
|
||||||
# final stage/image
|
# final stage/image
|
||||||
FROM mcr.microsoft.com/dotnet/runtime-deps:6.0-alpine-amd64
|
FROM mcr.microsoft.com/dotnet/runtime-deps:7.0-alpine-amd64
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=build /app ./
|
COPY --from=build /app ./
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ 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>();
|
||||||
@@ -30,6 +31,7 @@ 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())
|
||||||
@@ -122,8 +124,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
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
@@ -9,7 +11,26 @@ namespace TerribleDev.Blog.Web.Filters
|
|||||||
{
|
{
|
||||||
public class StaticETag: ActionFilterAttribute
|
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 static ConcurrentDictionary<string, string> cache = new ConcurrentDictionary<string, string>();
|
||||||
public override void OnActionExecuted(ActionExecutedContext context)
|
public override void OnActionExecuted(ActionExecutedContext context)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,8 +8,13 @@ namespace TerribleDev.Blog.Web.Filters
|
|||||||
{
|
{
|
||||||
public class Http2PushFilter : ActionFilterAttribute
|
public class Http2PushFilter : ActionFilterAttribute
|
||||||
{
|
{
|
||||||
public override void OnResultExecuted(ResultExecutedContext context)
|
private static bool IsHttp2PushDisabled = String.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("DISABLE_HTTP2_PUSH"));
|
||||||
|
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))
|
||||||
@@ -33,6 +38,7 @@ 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,6 +8,7 @@ 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.AspNetCore6;
|
using WebMarkupMin.AspNetCore7;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using TerribleDev.Blog.Web.Filters;
|
using TerribleDev.Blog.Web.Filters;
|
||||||
|
|
||||||
@@ -68,16 +68,23 @@ namespace TerribleDev.Blog.Web
|
|||||||
controllerBuilder.AddRazorRuntimeCompilation();
|
controllerBuilder.AddRazorRuntimeCompilation();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
services.AddResponseCompression(a =>
|
services
|
||||||
|
.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;
|
||||||
@@ -89,19 +96,16 @@ namespace TerribleDev.Blog.Web
|
|||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||||
{
|
{
|
||||||
if (env.IsDevelopment())
|
Console.WriteLine("ETag Detected As: " + StaticETag.staticEtag);
|
||||||
{
|
|
||||||
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() ? 0 : 31536000;
|
var cacheTime = env.IsDevelopment() ? 1 : 31536000;
|
||||||
app.UseStaticFiles(new StaticFileOptions
|
app.UseStaticFiles(new StaticFileOptions
|
||||||
{
|
{
|
||||||
OnPrepareResponse = ctx =>
|
OnPrepareResponse = ctx =>
|
||||||
@@ -119,6 +123,16 @@ 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();
|
||||||
@@ -141,20 +155,6 @@ 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 +163,4 @@ namespace TerribleDev.Blog.Web
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,6 +16,7 @@ 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]
|
||||||
@@ -28,9 +29,11 @@ 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)
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -41,7 +44,6 @@ 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,9 +1,10 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
|
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
|
||||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
|
<RuntimeIdentifiers>linux-musl-x64</RuntimeIdentifiers>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -22,12 +23,11 @@
|
|||||||
<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.AspNetCore6" Version="2.11.0" />
|
<PackageReference Include="WebMarkupMin.AspNetCore7" Version="2.13.0-rc1" />
|
||||||
<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="WebEssentials.AspNetCore.OutputCaching" Version="1.0.16" />
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="7.0.0" Condition="'$(Configuration)' == 'Debug'" />
|
||||||
<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 class="link-unstyled" id="closeNav">Close Navbar</span></li>
|
<li><span onclick="toggleNav()" 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" 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" 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>
|
||||||
<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 asp-append-version="true" src="~/js/swi.js" async></script>
|
<script push asp-append-version="true" src="~/js/swi.js" async></script>
|
||||||
</environment>
|
</environment>
|
||||||
<environment names="Production">
|
<environment names="Production">
|
||||||
<script asp-append-version="true" src="~/js/site.min.js" async></script>
|
<script push asp-append-version="true" src="~/js/site.min.js" async></script>
|
||||||
</environment>
|
</environment>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
13
src/TerribleDev.Blog.Web/wwwroot/css/dark.old.css
Normal file
13
src/TerribleDev.Blog.Web/wwwroot/css/dark.old.css
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
@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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,20 +13,6 @@
|
|||||||
--nav-bar-text-color: var(--primary-background);
|
--nav-bar-text-color: var(--primary-background);
|
||||||
}
|
}
|
||||||
|
|
||||||
@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 {
|
html {
|
||||||
font-family: Arial, Helvetica, sans-serif;
|
font-family: Arial, Helvetica, sans-serif;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
//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(function (reg) {
|
}).then(() => {
|
||||||
console.log('Service worker has been registered for scope:' + reg.scope);
|
console.log('SW');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var toggleNav = function () {
|
function toggleNav () {
|
||||||
var nav = document.getElementById('navBar');
|
var nav = document.getElementById('navBar');
|
||||||
if (!nav) {
|
if (!nav) {
|
||||||
return;
|
return;
|
||||||
@@ -23,15 +22,4 @@ var toggleNav = function () {
|
|||||||
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,2 +1,3 @@
|
|||||||
User-agent: *
|
User-agent: *
|
||||||
Allow: /
|
Allow: /
|
||||||
|
Sitemap: https://blog.terrible.dev/sitemap.xml
|
||||||
Reference in New Issue
Block a user