5 Commits

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

View File

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

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

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

@@ -9,7 +9,7 @@
"type": "coreclr",
"request": "launch",
"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": [],
"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:7.0-alpine AS build
FROM mcr.microsoft.com/dotnet/sdk:6.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:7.0-alpine-amd64
FROM mcr.microsoft.com/dotnet/runtime-deps:6.0-alpine-amd64
WORKDIR /app
COPY --from=build /app ./

View File

@@ -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
# Copy everything else and build

View File

@@ -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_timeout = 5
processes = []
@@ -10,6 +10,7 @@ processes = []
[experimental]
allowed_public_ports = []
auto_rollback = true
private_network = true
[[services]]
http_checks = []
@@ -18,8 +19,8 @@ processes = []
protocol = "tcp"
script_checks = []
[services.concurrency]
hard_limit = 25
soft_limit = 20
hard_limit = 200
soft_limit = 100
type = "connections"
[[services.ports]]
@@ -27,12 +28,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 = "2s"
interval = "3s"
grace_period = "1s"
interval = "15s"
restart_limit = 0
timeout = "2s"

View File

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

View File

@@ -9,19 +9,16 @@ 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, ILogger<HomeController> logger)
public HomeController(PostCache postCache)
{
this.logger = logger;
this.postCache = postCache;
}
@@ -30,26 +27,18 @@ namespace TerribleDev.Blog.Web.Controllers
[Route("/index.html", Order = 2)]
[Route("/")]
[Route("/page/{pageNumber:required:int:min(1)}")]
[OutputCache(Duration = 31536000, VaryByRouteValueNames = new string[] { "pageNumber" })]
[OutputCache(Duration = 31536000, VaryByParam = "pageNumber")]
[ResponseCache(Duration = 900)]
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 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)
@@ -71,34 +60,28 @@ namespace TerribleDev.Blog.Web.Controllers
}
[Route("{postUrl}/{amp?}")]
[OutputCache(Duration = 31536000, VaryByRouteValueNames = new string[] { "postUrl", "amp" })]
[OutputCache(Duration = 31536000, VaryByParam = "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}");
}
// 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.CaseInsensitiveUrlToPost.TryGetValue(postUrl, out var caseInsensitivePost))
if(postCache.LandingPagesUrl.TryGetValue(postUrl, out var landingPage))
{
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);
return View(nameof(FourOhFour));
}

View File

@@ -7,7 +7,6 @@ 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,7 +3,6 @@ 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;
@@ -25,7 +24,7 @@ namespace TerribleDev.Blog.Web.Controllers
return View(postCache.TagsToPosts);
}
[Route("/tags/{tagName}")]
[OutputCache(Duration = 31536000, VaryByRouteValueNames = new string[]{"tagName"})]
[OutputCache(Duration = 31536000, VaryByParam = "tagName")]
public IActionResult TagPluralRedirect(string tagName)
{
if(string.IsNullOrEmpty(tagName))
@@ -35,7 +34,7 @@ namespace TerribleDev.Blog.Web.Controllers
return Redirect($"/tag/{tagName}/");
}
[Route("/tag/{tagName}")]
[OutputCache(Duration = 31536000, VaryByRouteValueNames = new string[] {"tagName"})]
[OutputCache(Duration = 31536000, VaryByParam = "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:7.0-alpine AS build
FROM mcr.microsoft.com/dotnet/sdk:6.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:7.0-alpine-amd64
FROM mcr.microsoft.com/dotnet/runtime-deps:6.0-alpine-amd64
WORKDIR /app
COPY --from=build /app ./

View File

@@ -18,7 +18,6 @@ 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>();
@@ -31,7 +30,6 @@ 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())
@@ -124,8 +122,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"),
CaseInsensitiveUrlToPost = caseInsensitiveUrlToPost
SiteLDString = website.ToHtmlEscapedString().Replace("https://schema.org", "https://schema.org/true")
};
}
}

View File

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

View File

@@ -8,13 +8,8 @@ namespace TerribleDev.Blog.Web.Filters
{
public class Http2PushFilter : ActionFilterAttribute
{
private static bool IsHttp2PushDisabled = String.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("DISABLE_HTTP2_PUSH"));
public override void OnActionExecuted(ActionExecutedContext context)
public override void OnResultExecuted(ResultExecutedContext 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))
@@ -38,7 +33,6 @@ 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,7 +8,6 @@ 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.AspNetCore7;
using WebMarkupMin.AspNetCore6;
using Microsoft.Extensions.Logging;
using TerribleDev.Blog.Web.Filters;
@@ -68,23 +68,16 @@ namespace TerribleDev.Blog.Web
controllerBuilder.AddRazorRuntimeCompilation();
}
#endif
services
.AddResponseCompression(a =>
services.AddResponseCompression(a =>
{
a.EnableForHttps = true;
})
.AddResponseCaching()
.AddMemoryCache();
// if(Env.IsProduction())
// {
// }
services.AddOutputCache(a =>{
a.AddBasePolicy(b => {
b.Cache();
});
});
if(Env.IsProduction())
{
services.AddOutputCaching();
}
services.AddWebMarkupMin(a => {
a.AllowMinificationInDevelopmentEnvironment = true;
a.DisablePoweredByHttpHeaders = true;
@@ -97,15 +90,19 @@ 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() ? 1 : 31536000;
var cacheTime = env.IsDevelopment() ? 0 : 31536000;
app.UseStaticFiles(new StaticFileOptions
{
OnPrepareResponse = ctx =>
@@ -123,16 +120,6 @@ 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();
@@ -155,6 +142,20 @@ 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 =>
@@ -163,4 +164,4 @@ namespace TerribleDev.Blog.Web
});
}
}
}
}

View File

@@ -16,7 +16,6 @@ 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]
@@ -29,11 +28,9 @@ 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)
};
@@ -44,6 +41,7 @@ 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,12 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<RuntimeIdentifiers>linux-musl-x64</RuntimeIdentifiers>
</PropertyGroup>
<ItemGroup>
<Content Remove="compilerconfig.json" />
<Content Remove="bundleconfig.json" />
@@ -23,11 +21,12 @@
<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.AspNetCore7" Version="2.13.0-rc1" />
<PackageReference Include="WebMarkupMin.AspNetCore6" Version="2.11.0" />
<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="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>

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 onclick="toggleNav()" class="link-unstyled" id="closeNav">Close Navbar</span></li>
<li><span 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" 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>
</header>
<partial name="Nav" />
@@ -53,10 +53,10 @@
</div>
@RenderSection("Scripts", required: false)
<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 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>
</body>
</html>

View File

@@ -1,13 +1,14 @@
@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;
--hln: #f0f0f0;
--bdy-txt-clr: #ffffff;
--blk-qt-lb: #d1dced;
--code-blk-bg-clr: #4a4a4a;
--pmry-bknd: #323131;
--lnk-clr: #3faff9;
/* --lnk-vistd: #d8dbde; */
--bc: #bdcad2;
--hr: #626468;
}
}
}

View File

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

View File

@@ -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
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(() => {
console.log('SW');
}).then(function (reg) {
console.log('Service worker has been registered for scope:' + reg.scope);
});
}
function toggleNav () {
var toggleNav = function () {
var nav = document.getElementById('navBar');
if (!nav) {
return;
@@ -22,4 +23,15 @@ function toggleNav () {
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,3 +1,2 @@
User-agent: *
Allow: /
Sitemap: https://blog.terrible.dev/sitemap.xml
Allow: /