12 Commits

Author SHA1 Message Date
Tommy Parnell
a74dec639a push filter 2023-10-11 15:38:53 -04:00
Tommy Parnell
f93aea2696 rm old versions 2023-08-10 07:29:16 -04:00
Tommy Parnell
63828b3003 Create an auto-deploy file 2023-08-09 11:09:27 -04:00
Tommy Parnell
1b372b3501 reduce log 2022-11-14 17:08:59 -05:00
Tommy Parnell
5edba65844 rm some script 2022-11-14 16:41:42 -05:00
Tommy Parnell
afcae26bc1 push js 2022-11-14 16:13:23 -05:00
Tommy Parnell
5a253f6ada missed a dockerfile 2022-11-09 11:47:09 -05:00
Tommy Parnell
e8c548ab20 set target 2022-11-09 11:46:17 -05:00
Tommy Parnell
0871e037d8 dotnet 7 2022-11-09 11:43:42 -05:00
Tommy Parnell
a5931f48c6 sitemap 2022-08-26 13:35:50 -04:00
Tommy Parnell
2cff53f5d3 case insensitive url on post 2022-08-26 13:28:41 -04:00
Tommy Parnell
e065871145 revert some things 2022-08-21 22:40:44 -04:00
25 changed files with 197 additions and 251 deletions

View 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 }}

View File

@@ -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 }}'

View File

@@ -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
View File

@@ -9,7 +9,7 @@
"type": "coreclr",
"request": "launch",
"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": [],
"cwd": "${workspaceFolder}/src/TerribleDev.Blog.Web",
"stopAtEntry": false,

View File

@@ -1,5 +1,5 @@
# 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
# 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 date +%s > /app/buildtime.txt
# 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
COPY --from=build /app ./

View File

@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
FROM mcr.microsoft.com/dotnet/sdk:7.0-alpine AS build
WORKDIR /app
# Copy everything else and build

View File

@@ -1,6 +1,6 @@
# fly.toml file generated for tparnellblog on 2022-08-20T09:53:58-04:00
# fly.toml file generated for dry-meadow-9911 on 2022-11-09T12:09:05-05:00
app = "tparnellblog"
app = "dry-meadow-9911"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []
@@ -10,7 +10,6 @@ processes = []
[experimental]
allowed_public_ports = []
auto_rollback = true
private_network = true
[[services]]
http_checks = []
@@ -19,8 +18,8 @@ processes = []
protocol = "tcp"
script_checks = []
[services.concurrency]
hard_limit = 200
soft_limit = 100
hard_limit = 25
soft_limit = 20
type = "connections"
[[services.ports]]
@@ -28,12 +27,12 @@ processes = []
handlers = ["http"]
port = 80
[[services.ports]]
handlers = ["tls", "http"]
port = 443
# [[services.ports]]
# handlers = ["tls", "http"]
# port = 443
[[services.tcp_checks]]
grace_period = "1s"
interval = "15s"
grace_period = "2s"
interval = "3s"
restart_limit = 0
timeout = "2s"

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp6.0</TargetFramework>
<TargetFramework>netcoreapp7.0</TargetFramework>
<IsPackable>true</IsPackable>
<PackAsTool>true</PackAsTool>
<ToolCommandName>tempo</ToolCommandName>

View File

@@ -9,16 +9,19 @@ using System.IO;
using Microsoft.AspNetCore.Html;
using TerribleDev.Blog.Web.Filters;
using Microsoft.Extensions.Logging;
using Microsoft.AspNetCore.OutputCaching;
namespace TerribleDev.Blog.Web.Controllers
{
[Http2PushFilter]
public class HomeController : Controller
{
private readonly ILogger<HomeController> logger;
private readonly PostCache postCache;
public HomeController(PostCache postCache)
public HomeController(PostCache postCache, ILogger<HomeController> logger)
{
this.logger = logger;
this.postCache = postCache;
}
@@ -27,18 +30,26 @@ namespace TerribleDev.Blog.Web.Controllers
[Route("/index.html", Order = 2)]
[Route("/")]
[Route("/page/{pageNumber:required:int:min(1)}")]
[OutputCache(Duration = 31536000, VaryByParam = "pageNumber")]
[OutputCache(Duration = 31536000, VaryByRouteValueNames = new string[] { "pageNumber" })]
[ResponseCache(Duration = 900)]
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 View(new HomeViewModel() { Posts = result, 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 });
return View(new HomeViewModel()
{
Posts = result,
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?}")]
public IActionResult Theme(string postName)
@@ -60,28 +71,34 @@ namespace TerribleDev.Blog.Web.Controllers
}
[Route("{postUrl}/{amp?}")]
[OutputCache(Duration = 31536000, VaryByParam = "postUrl,amp")]
[OutputCache(Duration = 31536000, VaryByRouteValueNames = new string[] { "postUrl", "amp" })]
[ResponseCache(Duration = 900)]
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}/");
}
var isAmp = amp == "amp";
if(isAmp)
if (isAmp)
{
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);
return View(nameof(FourOhFour));
}

View File

@@ -7,6 +7,7 @@ using System.Threading.Tasks;
using System.Xml;
using System.Xml.Serialization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OutputCaching;
using Microsoft.SyndicationFeed;
using Microsoft.SyndicationFeed.Rss;
using TerribleDev.Blog.Web.Models;

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OutputCaching;
using TerribleDev.Blog.Web.Filters;
using TerribleDev.Blog.Web.Models;
@@ -24,7 +25,7 @@ namespace TerribleDev.Blog.Web.Controllers
return View(postCache.TagsToPosts);
}
[Route("/tags/{tagName}")]
[OutputCache(Duration = 31536000, VaryByParam = "tagName")]
[OutputCache(Duration = 31536000, VaryByRouteValueNames = new string[]{"tagName"})]
public IActionResult TagPluralRedirect(string tagName)
{
if(string.IsNullOrEmpty(tagName))
@@ -34,7 +35,7 @@ namespace TerribleDev.Blog.Web.Controllers
return Redirect($"/tag/{tagName}/");
}
[Route("/tag/{tagName}")]
[OutputCache(Duration = 31536000, VaryByParam = "tagName")]
[OutputCache(Duration = 31536000, VaryByRouteValueNames = new string[] {"tagName"})]
public IActionResult GetTag(string tagName)
{
if(!postCache.TagsToPosts.TryGetValue(tagName.ToLower(), out var models))

View File

@@ -1,5 +1,5 @@
# 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
# 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 . .
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
FROM mcr.microsoft.com/dotnet/runtime-deps:7.0-alpine-amd64
WORKDIR /app
COPY --from=build /app ./

View File

@@ -18,6 +18,7 @@ namespace TerribleDev.Blog.Web.Factories
var orderedPosts = rawPosts.OrderByDescending(a => a.PublishDate);
var posts = new List<IPost>(orderedPosts);
var urlToPosts = new Dictionary<string, IPost>();
var caseInsensitiveUrlToPost = new Dictionary<string, IPost>(StringComparer.OrdinalIgnoreCase);
var tagsToPost = new Dictionary<string, IList<Post>>();
var postsByPage = new Dictionary<int, IList<Post>>();
var syndicationPosts = new List<SyndicationItem>();
@@ -30,6 +31,7 @@ namespace TerribleDev.Blog.Web.Factories
{
var castedPost = post as Post;
urlToPosts.Add(post.UrlWithoutPath, castedPost);
caseInsensitiveUrlToPost.Add(post.UrlWithoutPath.ToLower(), castedPost);
syndicationPosts.Add(castedPost.ToSyndicationItem());
blogPostsLD.Add(post.Content.JsonLD);
foreach (var tag in castedPost.ToNormalizedTagList())
@@ -122,8 +124,8 @@ namespace TerribleDev.Blog.Web.Factories
BlogLD = ld,
SiteLD = website,
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
};
}
}

View File

@@ -27,7 +27,6 @@ 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

@@ -8,8 +8,13 @@ namespace TerribleDev.Blog.Web.Filters
{
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>;
logger.LogDebug("Http2PushFilter.OnActionExecuted");
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());
context.HttpContext.Response.Headers.Add("Link", headerBuilder.ToString());
base.OnActionExecuted(context);
}
}
}

View File

@@ -8,6 +8,7 @@ namespace TerribleDev.Blog.Web.Models
public IList<IPost> PostsAsLists { get; set;}
public IDictionary<string, IList<Post>> TagsToPosts { 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 IList<SyndicationItem> PostsAsSyndication { get; set; }

View File

@@ -12,7 +12,7 @@ using HardHat;
using TerribleDev.Blog.Web.Models;
using TerribleDev.Blog.Web.Factories;
using Microsoft.Extensions.Hosting;
using WebMarkupMin.AspNetCore6;
using WebMarkupMin.AspNetCore7;
using Microsoft.Extensions.Logging;
using TerribleDev.Blog.Web.Filters;
@@ -68,16 +68,23 @@ namespace TerribleDev.Blog.Web
controllerBuilder.AddRazorRuntimeCompilation();
}
#endif
services.AddResponseCompression(a =>
services
.AddResponseCompression(a =>
{
a.EnableForHttps = true;
})
.AddResponseCaching()
.AddMemoryCache();
if(Env.IsProduction())
{
services.AddOutputCaching();
}
// if(Env.IsProduction())
// {
// }
services.AddOutputCache(a =>{
a.AddBasePolicy(b => {
b.Cache();
});
});
services.AddWebMarkupMin(a => {
a.AllowMinificationInDevelopmentEnvironment = true;
a.DisablePoweredByHttpHeaders = true;
@@ -90,19 +97,15 @@ namespace TerribleDev.Blog.Web
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
Console.WriteLine("ETag Detected As: " + StaticETag.staticEtag);
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
}
app.UseHttpsRedirection();
if (env.IsProduction())
{
app.UseOutputCache();
app.UseResponseCaching();
}
app.UseResponseCompression();
var cacheTime = env.IsDevelopment() ? 0 : 31536000;
var cacheTime = env.IsDevelopment() ? 1 : 31536000;
app.UseStaticFiles(new StaticFileOptions
{
OnPrepareResponse = ctx =>
@@ -120,6 +123,16 @@ namespace TerribleDev.Blog.Web
"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.UseIENoOpen();
app.UseNoMimeSniff();
@@ -142,20 +155,6 @@ namespace TerribleDev.Blog.Web
// },
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.UseRouting();
app.UseEndpoints(endpoints =>
@@ -164,4 +163,4 @@ namespace TerribleDev.Blog.Web
});
}
}
}
}

View File

@@ -16,6 +16,7 @@ namespace TerribleDev.Blog.Web.Taghelpers
public record PushUrl(string Url, string asProperty);
[HtmlTargetElement("link", Attributes = "[rel=stylesheet],href,push")]
[HtmlTargetElement("img", Attributes = "src,push")]
[HtmlTargetElement("script", Attributes = "src,push")]
public class HttpPush : LinkTagHelper
{
[HtmlAttributeNotBound]
@@ -28,9 +29,11 @@ namespace TerribleDev.Blog.Web.Taghelpers
}
private (string Url, string AsProperty) GetTagInfo(string tag) =>
tag switch {
tag switch
{
"link" => ("href", "link"),
"img" => ("src", "image"),
"script" => ("src", "script"),
_ => (null, null)
};
@@ -41,7 +44,6 @@ namespace TerribleDev.Blog.Web.Taghelpers
return;
}
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 linkList = ViewContext.HttpContext.Items.TryGetValue(Key, out var links) ? links as List<PushUrl> : null;

View File

@@ -1,10 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<RuntimeIdentifiers>linux-musl-x64</RuntimeIdentifiers>
</PropertyGroup>
<ItemGroup>
<Content Remove="compilerconfig.json" />
<Content Remove="bundleconfig.json" />
@@ -21,12 +23,11 @@
<PackageReference Include="Markdig" Version="0.15.7" />
<PackageReference Include="Schema.NET" Version="11.0.1" />
<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="HardHat" Version="2.1.1" />
<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="6.0.1" Condition="'$(Configuration)' == 'Debug'" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="7.0.0" Condition="'$(Configuration)' == 'Debug'" />
</ItemGroup>

View File

@@ -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://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><span class="link-unstyled" id="closeNav">Close Navbar</span></li>
<li><span onclick="toggleNav()" class="link-unstyled" id="closeNav">Close Navbar</span></li>
</ul>
</div>
</nav>

View File

@@ -42,7 +42,7 @@
<a class="skip-main" href="#main">Skip to main content</a>
<div class="rootbox">
<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>
</header>
<partial name="Nav" />
@@ -53,10 +53,10 @@
</div>
@RenderSection("Scripts", required: false)
<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 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>
</body>
</html>

View File

@@ -1,14 +1,13 @@
@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;
--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;
}
}
}

View File

@@ -1,19 +1,18 @@
:root {
--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);
--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);
}
html {
font-family: Arial, Helvetica, sans-serif;
}
@@ -24,7 +23,7 @@ h3,
h4,
h5,
h6 {
color: var(--hln);
color: var(--headline);
line-height: 1.45;
letter-spacing: -0.01em;
line-height: 1.25em;
@@ -38,8 +37,8 @@ body {
text-rendering: optimizeLegibility;
letter-spacing: -0.01em;
line-height: 1.9rem;
background-color: var(--pmry-bknd);
color: var(--bdy-txt-clr);
background-color: var(--primary-background);
color: var(--body-text-color);
font-size: 1.125rem;
margin: 0;
}
@@ -74,7 +73,7 @@ body {
}
blockquote {
border-left: 2px solid var(--blk-qt-lb);
border-left: 2px solid var(--block-quote-left-border);
padding: 0.4em 1.2em;
}
@@ -84,7 +83,7 @@ pre {
font-family: "Courier New", Courier, monospace;
font-weight: 600;
border-radius: 3px;
background: var(--code-blk-bg-clr);
background: var(--code-block-background-color);
padding: 0 0.4em;
overflow-x: scroll;
letter-spacing: .02em;
@@ -96,16 +95,16 @@ pre > code {
}
a {
color: var(--lnk-clr);
color: var(--link-color);
font-weight: 400;
}
a:visited {
color: var(--lnk-vistd);
color: var(--link-visited);
}
.btmRule {
border-bottom: 1px solid var(--hr);
border-bottom: 1px solid var(--horizontal-rule);
padding-bottom: 3rem;
}
@@ -113,8 +112,8 @@ a:visited {
display: flex;
flex-direction: column;
align-items: center;
background: var(--nb-bkgd);
color: var(--nb-txt-color);
background: var(--nav-bar-background);
color: var(--nav-bar-text-color);
padding-top: 20px;
height: 100vh;
z-index: 40;
@@ -128,9 +127,9 @@ a:visited {
.header {
display: flex;
align-items: center;
border-bottom: 1px solid var(--hr);
color: var(--hln);
background-color: var(--pmry-bknd);
border-bottom: 1px solid var(--horizontal-rule);
color: var(--headline);
background-color: var(--primary-background);
z-index: 20;
padding: 0;
margin: 0;
@@ -173,21 +172,21 @@ a:visited {
.btn {
width: auto;
height: auto;
background: var(--pmry-bknd);
background: var(--primary-background);
border-radius: 3px;
margin: 0;
cursor: pointer;
color: var(--bdy-txt-clr);
border: 1px solid var(--bdy-txt-clr);
color: var(--body-text-color);
border: 1px solid var(--body-text-color);
padding: 0.3em 0.2em;
text-decoration: none;
font-size: 1.1rem;
text-transform: uppercase;
}
.btn:visited {
background: var(--pmry-bknd);
color: var(--bc);
border: 1px solid var(--bc);
background: var(--primary-background);
color: var(--border-color);
border: 1px solid var(--border-color);
}
.btn.block {

View File

@@ -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
if (navigator && navigator.serviceWorker && navigator.serviceWorker.controller) {
console.log('[PWA Builder] active service worker found, no need to register')
} else if (navigator && navigator.serviceWorker) {
//Register the ServiceWorker
navigator.serviceWorker.register('/sw.min.js', {
scope: '/'
}).then(function (reg) {
console.log('Service worker has been registered for scope:' + reg.scope);
}).then(() => {
console.log('SW');
});
}
var toggleNav = function () {
function toggleNav () {
var nav = document.getElementById('navBar');
if (!nav) {
return;
@@ -23,15 +22,4 @@ var toggleNav = function () {
else {
nav.classList.add('hide');
}
}
function attachNavToggle(elementId) {
var menuButton = document.getElementById(elementId);
if (menuButton) {
menuButton.addEventListener('click', function () {
toggleNav();
});
}
}
attachNavToggle('menuBtn');
attachNavToggle('closeNav');
}

View File

@@ -1,2 +1,3 @@
User-agent: *
Allow: /
Allow: /
Sitemap: https://blog.terrible.dev/sitemap.xml