Compare commits
41 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a1f34d81c | ||
|
|
e539263aa4 | ||
|
|
c3a583a33b | ||
|
|
718b938a76 | ||
|
|
415b62e1e7 | ||
|
|
e367072f21 | ||
|
|
1327d87b96 | ||
|
|
39dfcfe70d | ||
|
|
86cb0cec23 | ||
|
|
f87bd029f4 | ||
|
|
69b2112e4b | ||
|
|
0b57031fc1 | ||
|
|
71929bb1ba | ||
|
|
b1959082dc | ||
|
|
be5c4cc806 | ||
|
|
ca0344c902 | ||
|
|
5a844f34f9 | ||
|
|
57a129cf8d | ||
|
|
a31b9d4fa9 | ||
|
|
7013e61c2f | ||
|
|
6ce47adb8a | ||
|
|
b9b9e81213 | ||
|
|
53b8b448da | ||
|
|
aa6ed52d93 | ||
|
|
16c10c9ca1 | ||
|
|
c3cb61619b | ||
|
|
7ff61450f9 | ||
|
|
f3faede79e | ||
|
|
38f82061e9 | ||
|
|
57a8bba66a | ||
|
|
43d6e33638 | ||
|
|
d875ca6fea | ||
|
|
d846a538a0 | ||
|
|
00b711aef4 | ||
|
|
dbb6ae208b | ||
|
|
de62e6275d | ||
|
|
d873be97d8 | ||
|
|
f3080faae0 | ||
|
|
6ed0ef4205 | ||
|
|
ab9250b968 | ||
|
|
c24684fa8b |
13
.vscode/extensions.json
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
// See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
|
||||
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
|
||||
|
||||
// List of extensions which should be recommended for users of this workspace.
|
||||
"recommendations": [
|
||||
"ban.spellright"
|
||||
],
|
||||
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
|
||||
"unwantedRecommendations": [
|
||||
|
||||
]
|
||||
}
|
||||
17
.vscode/launch.json
vendored
@@ -1,18 +1,17 @@
|
||||
{
|
||||
// Use IntelliSense to find out which attributes exist for C# debugging
|
||||
// Use hover for the description of the existing attributes
|
||||
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": ".NET Core Launch (web)",
|
||||
"type": "coreclr",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "build",
|
||||
// If you have changed target frameworks, make sure to update the program path.
|
||||
"program": "${workspaceFolder}/TerribleDev.Blog.Web/bin/Debug/netcoreapp2.2/TerribleDev.Blog.Web.dll",
|
||||
"program": "${workspaceFolder}/src/TerribleDev.Blog.Web/bin/Debug/netcoreapp2.2/TerribleDev.Blog.Web.dll",
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}/TerribleDev.Blog.Web",
|
||||
"cwd": "${workspaceFolder}/src/TerribleDev.Blog.Web",
|
||||
"stopAtEntry": false,
|
||||
"internalConsoleOptions": "openOnSessionStart",
|
||||
"launchBrowser": {
|
||||
@@ -42,5 +41,5 @@
|
||||
"request": "attach",
|
||||
"processId": "${command:pickProcess}"
|
||||
}
|
||||
,]
|
||||
]
|
||||
}
|
||||
19
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"files.eol": "\n",
|
||||
"spellchecker.language": "en_US",
|
||||
"spellchecker.ignoreWordsList": [
|
||||
"dotnet",
|
||||
"csproj's",
|
||||
"VS2017",
|
||||
"vs2017",
|
||||
"refactor"
|
||||
],
|
||||
"spellchecker.documentTypes": [
|
||||
"markdown",
|
||||
"latex",
|
||||
"plaintext"
|
||||
],
|
||||
"spellchecker.ignoreRegExp": [],
|
||||
"spellchecker.ignoreFileExtensions": [],
|
||||
"spellchecker.checkInterval": 5000
|
||||
}
|
||||
5
.vscode/spellright.dict
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
intellisense
|
||||
docker
|
||||
env
|
||||
mydocklinting
|
||||
eslint
|
||||
2
.vscode/tasks.json
vendored
@@ -7,7 +7,7 @@
|
||||
"type": "process",
|
||||
"args": [
|
||||
"build",
|
||||
"${workspaceFolder}/TerribleDev.Blog.Web/TerribleDev.Blog.Web.csproj"
|
||||
"${workspaceFolder}/src/TerribleDev.Blog.Web/TerribleDev.Blog.Web.csproj"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
}
|
||||
|
||||
10
Readme.md
Normal file
@@ -0,0 +1,10 @@
|
||||
## Compress webp
|
||||
|
||||
find . -iname '*.png' -exec cwebp -lossless '{}' -o '{}'.webp \;
|
||||
find . -iname '*.jpg' -exec cwebp '{}' -o '{}'.webp \;
|
||||
find . -iname '*.gif' -exec gif2webp -mixed '{}' -o '{}'.webp \;
|
||||
|
||||
|
||||
## resize image
|
||||
|
||||
find . -iname '*' -exec convert '{}' -resize 750 '{}' \;
|
||||
7
docker-compose.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
version: '3'
|
||||
services:
|
||||
webapp:
|
||||
build: ./src/TerribleDev.Blog.Web
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"ProviderId": "Microsoft.ApplicationInsights.ConnectedService.ConnectedServiceProvider",
|
||||
"Version": "8.14.11009.1",
|
||||
"GettingStartedDocument": {
|
||||
"Uri": "https://go.microsoft.com/fwlink/?LinkID=798432"
|
||||
}
|
||||
}
|
||||
@@ -12,48 +12,25 @@ namespace TerribleDev.Blog.Web.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
public static List<IPost> postsAsList = new BlogFactory().GetAllPosts().OrderByDescending(a=>a.PublishDate).ToList();
|
||||
public static Dictionary<string, List<IPost>> tagToPost = postsAsList.Where(a=>a.tags != null)
|
||||
.Aggregate(
|
||||
new Dictionary<string, List<IPost>>(),
|
||||
(accum, item) => {
|
||||
foreach(var tag in item.tags)
|
||||
{
|
||||
if(accum.TryGetValue(tag, out var list))
|
||||
{
|
||||
list.Add(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
accum[tag] = new List<IPost>() { item };
|
||||
}
|
||||
}
|
||||
return accum;
|
||||
});
|
||||
public static IDictionary<string, IPost> posts = postsAsList.ToDictionary(a => a.Url);
|
||||
public static IDictionary<int, List<IPost>> postsByPage = postsAsList.Aggregate(new Dictionary<int, List<IPost>>() { [1] = new List<IPost>() }, (accum, item) =>
|
||||
{
|
||||
var highestPage = accum.Keys.Max();
|
||||
var current = accum[highestPage].Count;
|
||||
if (current >= 10)
|
||||
{
|
||||
accum[highestPage + 1] = new List<IPost>() { item };
|
||||
return accum;
|
||||
}
|
||||
accum[highestPage].Add(item);
|
||||
return accum;
|
||||
});
|
||||
private readonly PostCache postCache;
|
||||
|
||||
public HomeController(PostCache postCache)
|
||||
{
|
||||
this.postCache = postCache;
|
||||
}
|
||||
|
||||
[Route("/")]
|
||||
[Route("/index.html")]
|
||||
[Route("/page/{pageNumber?}" )]
|
||||
[OutputCache(Duration = 31536000, VaryByParam = "pageNumber")]
|
||||
[ResponseCache(Duration = 900)]
|
||||
public IActionResult Index(int pageNumber = 1)
|
||||
{
|
||||
if(!postsByPage.TryGetValue(pageNumber, out var result))
|
||||
if(!postCache.PostsByPage.TryGetValue(pageNumber, out var result))
|
||||
{
|
||||
return Redirect("/404/");
|
||||
return Redirect($"/404/?from=/page/{pageNumber}/");
|
||||
}
|
||||
return View(new HomeViewModel() { Posts = result, Page = pageNumber, HasNext = postsByPage.ContainsKey(pageNumber + 1), HasPrevious = postsByPage.ContainsKey(pageNumber - 1) });
|
||||
return View(new HomeViewModel() { Posts = result, Page = pageNumber, HasNext = postCache.PostsByPage.ContainsKey(pageNumber + 1), HasPrevious = postCache.PostsByPage.ContainsKey(pageNumber - 1) });
|
||||
}
|
||||
[Route("/theme/{postName?}")]
|
||||
public IActionResult Theme(string postName)
|
||||
@@ -76,12 +53,12 @@ namespace TerribleDev.Blog.Web.Controllers
|
||||
|
||||
[Route("{postUrl}")]
|
||||
[OutputCache(Duration = 31536000, VaryByParam = "postUrl")]
|
||||
[ResponseCache(Duration = 180)]
|
||||
[ResponseCache(Duration = 900)]
|
||||
public IActionResult Post(string postUrl)
|
||||
{
|
||||
if(!posts.TryGetValue(postUrl, out var currentPost))
|
||||
if(!postCache.UrlToPost.TryGetValue(postUrl, out var currentPost))
|
||||
{
|
||||
return Redirect("/404/");
|
||||
return Redirect($"/404/?from={postUrl}");
|
||||
}
|
||||
return View(model: currentPost);
|
||||
}
|
||||
@@ -95,10 +72,10 @@ namespace TerribleDev.Blog.Web.Controllers
|
||||
[Route("/404")]
|
||||
[Route("{*url}", Order = 999)]
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult FourOhFour()
|
||||
public IActionResult FourOhFour(string from = null)
|
||||
{
|
||||
this.Response.StatusCode = 404;
|
||||
return View();
|
||||
return View(viewName: nameof(FourOhFour));
|
||||
}
|
||||
[Route("/404.html")]
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
|
||||
@@ -15,12 +15,19 @@ namespace TerribleDev.Blog.Web.Controllers
|
||||
{
|
||||
public class SeoController : Controller
|
||||
{
|
||||
private readonly BlogConfiguration configuration;
|
||||
private readonly PostCache postCache;
|
||||
|
||||
public SeoController(BlogConfiguration configuration, PostCache postCache)
|
||||
{
|
||||
this.configuration = configuration;
|
||||
this.postCache = postCache;
|
||||
}
|
||||
public static DateTimeOffset publishDate = DateTimeOffset.UtcNow; // keep publish date in memory so we just return when the server was kicked
|
||||
public static IEnumerable<SyndicationItem> postsToSyndication = HomeController.postsAsList.Select(a => a.ToSyndicationItem()).ToList();
|
||||
[Route("/rss")]
|
||||
[Route("/rss.xml")]
|
||||
[ResponseCache(Duration = 7200)]
|
||||
[OutputCache(Duration = 86400)]
|
||||
[OutputCache(Duration = 31536000)]
|
||||
public async Task Rss()
|
||||
{
|
||||
Response.StatusCode = 200;
|
||||
@@ -28,11 +35,11 @@ namespace TerribleDev.Blog.Web.Controllers
|
||||
using (XmlWriter xmlWriter = XmlWriter.Create(this.Response.Body, new XmlWriterSettings() { Async = true, Indent = false, Encoding = Encoding.UTF8 }))
|
||||
{
|
||||
var writer = new RssFeedWriter(xmlWriter);
|
||||
await writer.WriteTitle("The Ramblings of TerribleDev");
|
||||
await writer.WriteValue("link", "https://blog.terribledev.io");
|
||||
await writer.WriteTitle(configuration.Title);
|
||||
await writer.WriteValue("link", configuration.Link);
|
||||
await writer.WriteDescription("My name is Tommy Parnell. I usually go by TerribleDev on the internets. These are just some of my writings and rants about the software space.");
|
||||
|
||||
foreach (var item in postsToSyndication)
|
||||
foreach (var item in postCache.PostsAsSyndication)
|
||||
{
|
||||
await writer.Write(item);
|
||||
}
|
||||
@@ -43,19 +50,19 @@ namespace TerribleDev.Blog.Web.Controllers
|
||||
}
|
||||
[Route("/sitemap.xml")]
|
||||
[ResponseCache(Duration = 7200)]
|
||||
[OutputCache(Duration = 86400)]
|
||||
[OutputCache(Duration = 31536000)]
|
||||
public void SiteMap()
|
||||
{
|
||||
Response.StatusCode = 200;
|
||||
Response.ContentType = "text/xml";
|
||||
var sitewideLinks = new List<SiteMapItem>(HomeController.tagToPost.Keys.Select(a=> new SiteMapItem() { LastModified = DateTime.UtcNow, Location = $"https://blog.terribledev.io/tag/{a}/"}))
|
||||
var sitewideLinks = new List<SiteMapItem>(postCache.TagsToPosts.Keys.Select(a => new SiteMapItem() { LastModified = DateTime.UtcNow, Location = $"https://blog.terribledev.io/tag/{a}/" }))
|
||||
{
|
||||
new SiteMapItem() { LastModified = DateTime.UtcNow, Location="https://blog.terribledev.io/all-tags/" }
|
||||
};
|
||||
var ser = new XmlSerializer(typeof(SiteMapRoot));
|
||||
var sitemap = new SiteMapRoot()
|
||||
{
|
||||
Urls = HomeController.postsAsList.Select(a => new SiteMapItem() { LastModified = DateTime.UtcNow, Location = $"https://blog.terribledev.io/{a.Url}/" }).ToList()
|
||||
Urls = postCache.PostsAsLists.Select(a => new SiteMapItem() { LastModified = DateTime.UtcNow, Location = $"https://blog.terribledev.io/{a.Url}/" }).ToList()
|
||||
};
|
||||
sitemap.Urls.AddRange(sitewideLinks);
|
||||
ser.Serialize(this.Response.Body, sitemap);
|
||||
|
||||
@@ -3,24 +3,31 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using TerribleDev.Blog.Web.Models;
|
||||
|
||||
namespace TerribleDev.Blog.Web.Controllers
|
||||
{
|
||||
public class TagsController : Controller
|
||||
{
|
||||
private readonly PostCache postCache;
|
||||
|
||||
public TagsController(PostCache postCache)
|
||||
{
|
||||
this.postCache = postCache;
|
||||
}
|
||||
[Route("/all-tags")]
|
||||
[OutputCache(Duration = 31536000)]
|
||||
public IActionResult AllTags()
|
||||
{
|
||||
return View(HomeController.tagToPost);
|
||||
return View(postCache.TagsToPosts);
|
||||
}
|
||||
[Route("/tag/{tagName}")]
|
||||
[OutputCache(Duration = 31536000, VaryByParam = "tagName")]
|
||||
public IActionResult GetTag(string tagName)
|
||||
{
|
||||
if(!HomeController.tagToPost.TryGetValue(tagName, out var models))
|
||||
if(!postCache.TagsToPosts.TryGetValue(tagName.ToLower(), out var models))
|
||||
{
|
||||
return NotFound();
|
||||
return Redirect($"/404/?from=/tag/{tagName}/");
|
||||
}
|
||||
{
|
||||
return View(new Models.GetTagViewModel { Tag = tagName, Posts = models });
|
||||
|
||||
@@ -11,13 +11,16 @@ namespace TerribleDev.Blog.Web
|
||||
{
|
||||
public static SyndicationItem ToSyndicationItem(this IPost x)
|
||||
{
|
||||
return new SyndicationItem()
|
||||
Uri.TryCreate($"https://blog.terribledev.io/{x.Url}/", UriKind.Absolute, out var url);
|
||||
var syn = new SyndicationItem()
|
||||
{
|
||||
Title = x.Title,
|
||||
Description = x.Content.ToString(),
|
||||
Id = $"https://blog.terribledev.io/{x.Url}",
|
||||
Id = url.ToString(),
|
||||
Published = x.PublishDate
|
||||
};
|
||||
syn.AddLink(new SyndicationLink(url));
|
||||
return syn;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
54
src/TerribleDev.Blog.Web/Factories/BlogCacheFactory.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using System.Collections.Generic;
|
||||
using TerribleDev.Blog.Web.Models;
|
||||
using System.Linq;
|
||||
using System.Collections.Immutable;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace TerribleDev.Blog.Web.Factories
|
||||
{
|
||||
public static class BlogCacheFactory
|
||||
{
|
||||
public static PostCache ProjectPostCache(IEnumerable<IPost> rawPosts)
|
||||
{
|
||||
var posts = rawPosts.OrderByDescending(a => a.PublishDate).ToImmutableList();
|
||||
var tagsToPost = posts.Where(a=>a.tags != null)
|
||||
.Aggregate(
|
||||
ImmutableDictionary.Create<string, ImmutableList<IPost>>(),
|
||||
(accum, item) => {
|
||||
foreach(var tag in item.tags.Where(i => !string.IsNullOrWhiteSpace(i)).Select(i => i.ToLower()))
|
||||
{
|
||||
accum = accum.TryGetValue(tag, out var list) ? accum.SetItem(tag, list.Add(item)) : accum.Add(tag, ImmutableList.Create(item));
|
||||
}
|
||||
return accum;
|
||||
}).ToImmutableSortedDictionary();
|
||||
var urlToPosts = posts.ToImmutableDictionary(a => a.Url);
|
||||
var postsByPage =
|
||||
posts.Aggregate(ImmutableDictionary.Create<int, ImmutableList<IPost>>(), (accum, item) =>
|
||||
{
|
||||
if(!accum.Keys.Any())
|
||||
{
|
||||
accum = accum.SetItem(1, ImmutableList.Create<IPost>());
|
||||
}
|
||||
var highestPage = accum.Keys.Any() ? accum.Keys.Max() : 1;
|
||||
var current = accum[highestPage];
|
||||
if (current.Count >= 10)
|
||||
{
|
||||
return accum.Add(highestPage + 1, ImmutableList.Create(item));
|
||||
}
|
||||
|
||||
return accum.SetItem(highestPage, current.Add(item));
|
||||
}).ToImmutableDictionary();
|
||||
var syndicationPosts = posts.Select(i => i.ToSyndicationItem()).ToImmutableList();
|
||||
var postsToPosition = posts.Select((item, index) => (item, index)).ToImmutableDictionary(i => i.item, i => i.index);
|
||||
return new PostCache()
|
||||
{
|
||||
PostsAsLists = posts,
|
||||
TagsToPosts = tagsToPost,
|
||||
UrlToPost = urlToPosts,
|
||||
PostsByPage = postsByPage,
|
||||
PostsAsSyndication = syndicationPosts
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,17 +8,20 @@ using YamlDotNet.Serialization;
|
||||
using Microsoft.AspNetCore.Html;
|
||||
using Markdig;
|
||||
using TerribleDev.Blog.Web.MarkExtension.TerribleDev.Blog.Web.ExternalLinkParser;
|
||||
using TerribleDev.Blog.Web.MarkExtension;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace TerribleDev.Blog.Web
|
||||
{
|
||||
public class BlogFactory
|
||||
{
|
||||
public List<IPost> GetAllPosts()
|
||||
public List<IPost> GetAllPosts(string domain)
|
||||
{
|
||||
// why didn't I use f# I'd have a pipe operator by now
|
||||
var posts = GetPosts();
|
||||
var postsAsText = posts.Select(GetFileText);
|
||||
return Task.WhenAll(postsAsText).Result.AsParallel().Select(b => ParsePost(b.text, b.fileInfo.Name)).ToList();
|
||||
return Task.WhenAll(postsAsText).Result.Select(b => ParsePost(b.text, b.fileInfo.Name, domain)).ToList();
|
||||
}
|
||||
|
||||
private static async Task<(string text, FileInfo fileInfo)> GetFileText(string filePath)
|
||||
@@ -37,24 +40,28 @@ namespace TerribleDev.Blog.Web
|
||||
return serializer.Deserialize<PostSettings>(ymlText);
|
||||
|
||||
}
|
||||
public IPost ParsePost(string postText, string fileName)
|
||||
public IPost ParsePost(string postText, string fileName, string domain)
|
||||
{
|
||||
var splitFile = postText.Split("---");
|
||||
var ymlRaw = splitFile[0];
|
||||
var markdownText = string.Join("", splitFile.Skip(1));
|
||||
var postSettings = ParseYaml(ymlRaw);
|
||||
var resolvedUrl = !string.IsNullOrWhiteSpace(postSettings.permalink) ? postSettings.permalink : fileName.Split('.')[0].Replace(' ', '-').WithoutSpecialCharacters();
|
||||
List<string> postImages = new List<string>();
|
||||
var pipeline = new MarkdownPipelineBuilder()
|
||||
.Use<TargetLinkExtension>()
|
||||
.Use(new AbsoluteLinkConverter(resolvedUrl, domain))
|
||||
.Use<ImageRecorder>(new ImageRecorder(ref postImages))
|
||||
.Use<TargetLinkExtension>()
|
||||
.Use<PictureInline>()
|
||||
.UseMediaLinks()
|
||||
.UseEmojiAndSmiley()
|
||||
.Build();
|
||||
var postContent = Markdown.ToHtml(markdownText, pipeline);
|
||||
var postContentPlain = String.Join("", Markdown.ToPlainText(markdownText, pipeline).Split("<!-- more -->"));
|
||||
var postSettings = ParseYaml(ymlRaw);
|
||||
var resolvedUrl = !string.IsNullOrWhiteSpace(postSettings.permalink) ? postSettings.permalink : fileName.Split('.')[0].Replace(' ', '-').WithoutSpecialCharacters();
|
||||
|
||||
var summary = postContent.Split("<!-- more -->")[0];
|
||||
var postSummaryPlain = postContentPlain.Split("<!-- more -->")[0];
|
||||
|
||||
return new Post()
|
||||
{
|
||||
PublishDate = postSettings.date.ToUniversalTime(),
|
||||
@@ -66,7 +73,7 @@ namespace TerribleDev.Blog.Web
|
||||
SummaryPlain = postSummaryPlain,
|
||||
SummaryPlainShort = (postContentPlain.Length <= 147 ? postContentPlain : postContentPlain.Substring(0, 146)) + "...",
|
||||
ContentPlain = postContentPlain,
|
||||
Images = postImages.Distinct().Select(a => a.StartsWith('/') ? a : $"/{resolvedUrl}/{a}").ToList()
|
||||
Images = postImages.Distinct().ToList()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using Markdig;
|
||||
using Markdig.Renderers;
|
||||
using Markdig.Renderers.Html.Inlines;
|
||||
using Markdig.Syntax.Inlines;
|
||||
|
||||
namespace TerribleDev.Blog.Web.MarkExtension
|
||||
{
|
||||
public class AbsoluteLinkConverter : IMarkdownExtension
|
||||
{
|
||||
public string BaseUrl { get; }
|
||||
public string Domain { get; }
|
||||
|
||||
public AbsoluteLinkConverter(string baseUrl, string domain)
|
||||
{
|
||||
BaseUrl = baseUrl;
|
||||
Domain = domain;
|
||||
}
|
||||
|
||||
public void Setup(MarkdownPipelineBuilder pipeline)
|
||||
{
|
||||
}
|
||||
|
||||
public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer)
|
||||
{
|
||||
var htmlRenderer = renderer as HtmlRenderer;
|
||||
if (htmlRenderer != null)
|
||||
{
|
||||
var inlineRenderer = htmlRenderer.ObjectRenderers.FindExact<LinkInlineRenderer>();
|
||||
inlineRenderer.TryWriters.Add(TryLinkAbsoluteUrlWriter);
|
||||
}
|
||||
}
|
||||
private bool TryLinkAbsoluteUrlWriter(HtmlRenderer renderer, LinkInline linkInline)
|
||||
{
|
||||
var prevDynamic = linkInline.GetDynamicUrl;
|
||||
linkInline.GetDynamicUrl = () => {
|
||||
var escapeUrl = prevDynamic != null ? prevDynamic() ?? linkInline.Url : linkInline.Url;
|
||||
if(!System.Uri.TryCreate(escapeUrl, UriKind.RelativeOrAbsolute, out var parsedResult))
|
||||
{
|
||||
throw new Exception($"Error making link for {escapeUrl} @ {BaseUrl}");
|
||||
}
|
||||
if(parsedResult.IsAbsoluteUri)
|
||||
{
|
||||
return escapeUrl;
|
||||
}
|
||||
var uriBuilder = new UriBuilder(Domain);
|
||||
if(!escapeUrl.StartsWith("/"))
|
||||
{
|
||||
uriBuilder = uriBuilder.WithPathSegment($"/{BaseUrl}/{escapeUrl}");
|
||||
}
|
||||
else
|
||||
{
|
||||
uriBuilder = uriBuilder.WithPathSegment(parsedResult.ToString());
|
||||
}
|
||||
return uriBuilder.Uri.ToString();
|
||||
};
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,6 @@ namespace TerribleDev.Blog.Web.MarkExtension
|
||||
var inlineRenderer = htmlRenderer.ObjectRenderers.FindExact<LinkInlineRenderer>();
|
||||
if (inlineRenderer != null)
|
||||
{
|
||||
inlineRenderer.TryWriters.Remove(TryLinkInlineRenderer);
|
||||
inlineRenderer.TryWriters.Add(TryLinkInlineRenderer);
|
||||
}
|
||||
}
|
||||
@@ -49,7 +48,8 @@ namespace TerribleDev.Blog.Web.MarkExtension
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.images.Add(linkInline.Url);
|
||||
var url = linkInline.GetDynamicUrl != null ? linkInline.GetDynamicUrl(): linkInline.Url;
|
||||
this.images.Add(url);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
69
src/TerribleDev.Blog.Web/MarkExtension/PictureInline.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using Markdig;
|
||||
using Markdig.Renderers;
|
||||
using Markdig.Renderers.Html.Inlines;
|
||||
using Markdig.Syntax.Inlines;
|
||||
|
||||
namespace TerribleDev.Blog.Web.MarkExtension
|
||||
{
|
||||
public class PictureInline : IMarkdownExtension
|
||||
{
|
||||
public void Setup(MarkdownPipelineBuilder pipeline)
|
||||
{
|
||||
}
|
||||
|
||||
public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer)
|
||||
{
|
||||
var htmlRenderer = renderer as HtmlRenderer;
|
||||
if (htmlRenderer != null)
|
||||
{
|
||||
var inlineRenderer = htmlRenderer.ObjectRenderers.FindExact<LinkInlineRenderer>();
|
||||
inlineRenderer.TryWriters.Add(TryLinkInlineRenderer);
|
||||
}
|
||||
}
|
||||
private bool TryLinkInlineRenderer(HtmlRenderer renderer, LinkInline linkInline)
|
||||
{
|
||||
if (linkInline == null || !linkInline.IsImage)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
renderer.Write("<picture>");
|
||||
WriteImageTag(renderer, linkInline, ".webp", "image/webp");
|
||||
WriteImageTag(renderer, linkInline, string.Empty);
|
||||
renderer.Write("</picture>");
|
||||
return true;
|
||||
|
||||
}
|
||||
private void WriteImageTag(HtmlRenderer renderer, LinkInline link, string suffix, string type = null)
|
||||
{
|
||||
|
||||
|
||||
renderer.Write(string.IsNullOrWhiteSpace(type) ? $"<img src=\"" : $"<source type=\"{type}\" srcset=\"");
|
||||
var escapeUrl = link.GetDynamicUrl != null ? link.GetDynamicUrl() ?? link.Url : link.Url;
|
||||
|
||||
renderer.WriteEscapeUrl($"{escapeUrl}{suffix}");
|
||||
renderer.Write("\"");
|
||||
renderer.WriteAttributes(link);
|
||||
if (renderer.EnableHtmlForInline)
|
||||
{
|
||||
renderer.Write(" alt=\"");
|
||||
}
|
||||
var wasEnableHtmlForInline = renderer.EnableHtmlForInline;
|
||||
renderer.EnableHtmlForInline = false;
|
||||
renderer.WriteChildren(link);
|
||||
renderer.EnableHtmlForInline = wasEnableHtmlForInline;
|
||||
if (renderer.EnableHtmlForInline)
|
||||
{
|
||||
renderer.Write("\"");
|
||||
}
|
||||
|
||||
|
||||
if (renderer.EnableHtmlForInline)
|
||||
{
|
||||
renderer.Write(" />");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
8
src/TerribleDev.Blog.Web/Models/BlogConfiguration.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace TerribleDev.Blog.Web.Models
|
||||
{
|
||||
public class BlogConfiguration
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string Link { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -18,5 +18,7 @@ namespace TerribleDev.Blog.Web.Models
|
||||
public string SummaryPlainShort { get; set; }
|
||||
public IList<string> tags { get; set; }
|
||||
public IList<string> Images { get; set;}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
16
src/TerribleDev.Blog.Web/Models/PostCache.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System.Collections.Immutable;
|
||||
using Microsoft.SyndicationFeed;
|
||||
|
||||
namespace TerribleDev.Blog.Web.Models
|
||||
{
|
||||
public class PostCache
|
||||
{
|
||||
public ImmutableList<IPost> PostsAsLists { get; set;}
|
||||
public ImmutableSortedDictionary<string, ImmutableList<IPost>> TagsToPosts { get; set; }
|
||||
public ImmutableDictionary<string, IPost> UrlToPost { get; set; }
|
||||
public ImmutableDictionary<int, ImmutableList<IPost>> PostsByPage { get; set; }
|
||||
public ImmutableList<SyndicationItem> PostsAsSyndication { get; set; }
|
||||
public ImmutableDictionary<IPost, int> PostToPosition { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ Getting Started:
|
||||
|
||||
Ok, so the alexa .net sdk is for the full framework only, and its built for webapi. The best way to get going is in visual studio `file -> new project -> ASP.NET Web Application .net framework` A dialog comes up, and I picked `Azure API App`.
|
||||
|
||||

|
||||

|
||||
|
||||
Now you have an empty webapi project. We don't need swashbuckle/swagger so lets get rid of that
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
title: Must have vscode plugins for front-end devs
|
||||
date: 2019-02-06
|
||||
tags:
|
||||
- visual studio
|
||||
- javascript
|
||||
- css
|
||||
- front-end
|
||||
---
|
||||
|
||||
I've had a lot of people ask me about my choice of editors, and plugins. A while back I switched to vscode for all my programming work, for both front and back end. In the past I've blogged about [the best plugins for visual studio](/VS-2017-best-extensions-on-launch/) as a backend dev, but I thought I'd give you a more front-end angle
|
||||
|
||||
<!-- more -->
|
||||
|
||||
## Document this
|
||||
|
||||
My first one, and in my opinion the most underrated is [document this](https://marketplace.visualstudio.com/items?itemName=joelday.docthis). So if you have ever had to write [jsdoc](http://usejsdoc.org/) comments you can know how tedious it gets, and if you haven't, trust me you should. VSCode and most other editors can read [jsdoc](http://usejsdoc.org/) comments above functions, and class declarations to improve the intellisense and type completion statements. Simply have your cursor over a function, invoke document this, and quickly you will be given jsdoc comments for your code.
|
||||
|
||||

|
||||
|
||||
|
||||
## Import Cost
|
||||
|
||||
Another extension I find vital to my every day is [import cost](https://marketplace.visualstudio.com/items?itemName=wix.vscode-import-cost). This is a package, that leaves you little notes on the side of any import you have as to how big it will be. This package will even highlight the size text in red for large imports which you can configure. What I love about this package, is it tells me if the package I'm about to use is going to be very expensive size wise. That way I find out long before I commit the code, and my pages get slow.
|
||||
|
||||

|
||||
|
||||
## ESlint and Prettier
|
||||
|
||||
Hopefully both of these will not be new to you. ESLint is a linting tool that looks for potential errors in your code. Prettier is an opinionated style enforcer for your code. The [eslint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) and [prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) extensions for vscode can automatically show you problems in your code as you type, and can even fix your code on save. What I love about both of these tools, is together they make a great force for improving your code base. Prettier eliminates many debates over code style between team members, and eslint prevents you from shipping many bugs to production. These extensions can call out problems as you type, which decreases the feedback loops, and increases your productivity.
|
||||
|
||||
|
||||
|
||||
|
||||
## Filesize
|
||||
|
||||
As a web developer I spend a lot of my time looking at file size. Right now file sizes are ever inflating, and are causing pain for bandwidth constrained devices. I often download bundles, and inspect their compiled source, or just have to look at how big a file is on the filesystem. A big tool I have in my belt is [filesize](https://marketplace.visualstudio.com/items?itemName=mkxml.vscode-filesize). This is a crazy simple extension, but one that brings me joy everyday. The premise is simple, print the file size of the current file in the status bar at the bottom. Click on it, and you get a nice output of what its like gzipped, and the mime type. Dirt simple, but saved me a ton of time everyday!
|
||||
|
||||

|
||||
|
||||
|
||||
## Runner ups
|
||||
|
||||
Here is a list of additional extensions I certainly couldn't live without
|
||||
|
||||
* [path intellisense](https://marketplace.visualstudio.com/items?itemName=christian-kohler.path-intellisense) - autocomplete file paths in various files (including html)
|
||||
* [npm intellisense](https://marketplace.visualstudio.com/items?itemName=christian-kohler.npm-intellisense) - autocomplete npm pages in imports
|
||||
* [html 5 boilerplate](https://marketplace.visualstudio.com/items?itemName=sidthesloth.html5-boilerplate) - dirt simple html boilerplate snippets
|
||||
* [icon fonts](https://marketplace.visualstudio.com/items?itemName=idleberg.icon-fonts) - Autocomplete for various icon fonts such as font awesome
|
||||
* [git lens](https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens) - Show git history inline, along with other information from git
|
||||
@@ -26,6 +26,46 @@ So what I personally like to do is find orange bars that often make up the bulk
|
||||
|
||||
So digging into other blog posts, I found posts showing how to [visualize your redux actions](https://medium.com/@vcarl/performance-profiling-a-redux-app-c85e67bf84ae) using the same performance API mechanisms react uses. That blog post uses redux middleware to add timings to actions. This narrowed down on our performance problems, but did not point out the exact selector that was slow. Clearly we had an action that was triggering an expensive state update, but the time was still spent in `anonymous function`. Thats when I had the idea to wrap reselect selector functions in a function that can append the timings. [This gist is what I came up with](https://gist.github.com/TerribleDev/db48b2c8e143f9364292161346877f93)
|
||||
|
||||
```js
|
||||
|
||||
import {createSelector} from 'reselect';
|
||||
|
||||
const hasPerformanceApi =
|
||||
window &&
|
||||
window.performance &&
|
||||
window.performance.measure &&
|
||||
window.performance.mark;
|
||||
|
||||
const createFuncWithMark = (name, callback) => (...args) => {
|
||||
const startMark = `${name}-Startmark`;
|
||||
const endMark = `${name}-EndMark`;
|
||||
window.performance.mark(startMark);
|
||||
const result = callback(...args);
|
||||
window.performance.mark(endMark);
|
||||
window.performance.measure('♻️ ' + `${name}-Selector`, startMark, endMark);
|
||||
window.performance.clearMarks(startMark);
|
||||
window.performance.clearMarks(endMark);
|
||||
window.performance.clearMeasures(startMark);
|
||||
window.performance.clearMeasures(endMark);
|
||||
return result;
|
||||
};
|
||||
|
||||
export const createMarkedSelector = (name, ...args) => {
|
||||
if (!hasPerformanceApi) {
|
||||
return createSelector(...args);
|
||||
}
|
||||
if (!name || typeof name !== 'string') {
|
||||
throw new Error('marked selectors must have names');
|
||||
}
|
||||
const callback = args.pop();
|
||||
const funcWithMark = createFuncWithMark(name, callback);
|
||||
args.push(funcWithMark);
|
||||
return createSelector(...args);
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
|
||||
So how does this work exactly? Well its a library that wraps the function you pass to reselect that adds markers to the window to tell you how fast reselect selectors take to run. Combined with the previously mentioned blog post, you can now get timings in chrome's performance tool with selectors! You can also combine this with the [redux middleware](https://medium.com/@vcarl/performance-profiling-a-redux-app-c85e67bf84ae) I previously mentioned to get a deeper insight into how your app is performing
|
||||
|
||||

|
||||
|
||||
@@ -19,6 +19,7 @@ namespace TerribleDev.Blog.Web
|
||||
|
||||
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
|
||||
WebHost.CreateDefaultBuilder(args)
|
||||
.UseApplicationInsights()
|
||||
.UseStartup<Startup>()
|
||||
.ConfigureKestrel(a =>
|
||||
{
|
||||
|
||||
@@ -15,20 +15,38 @@ using Microsoft.Extensions.FileProviders;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
using HardHat.Middlewares;
|
||||
using HardHat;
|
||||
using TerribleDev.Blog.Web.Models;
|
||||
using TerribleDev.Blog.Web.Factories;
|
||||
|
||||
namespace TerribleDev.Blog.Web
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IConfiguration configuration)
|
||||
public Startup(IConfiguration configuration, IHostingEnvironment env)
|
||||
{
|
||||
Configuration = configuration;
|
||||
Env = env;
|
||||
}
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
public IHostingEnvironment Env { get; }
|
||||
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
Func<BlogConfiguration> getBlog = () => Configuration.GetSection("Blog").Get<BlogConfiguration>();
|
||||
if (Env.IsDevelopment())
|
||||
{
|
||||
services.AddTransient(a => getBlog());
|
||||
}
|
||||
else
|
||||
{
|
||||
services.AddSingleton(getBlog());
|
||||
}
|
||||
services.AddSingleton(i => {
|
||||
var posts = new BlogFactory().GetAllPosts(Env.IsDevelopment() ? "https://localhost:5001": "https://blog.terribledev.io");
|
||||
return BlogCacheFactory.ProjectPostCache(posts);
|
||||
});
|
||||
services.AddResponseCompression(a =>
|
||||
{
|
||||
a.EnableForHttps = true;
|
||||
@@ -57,31 +75,47 @@ namespace TerribleDev.Blog.Web
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
app.UseResponseCompression();
|
||||
|
||||
|
||||
var cacheTime = env.IsDevelopment() ? 0 : 31536000;
|
||||
app.UseStaticFiles(new StaticFileOptions
|
||||
{
|
||||
OnPrepareResponse = ctx =>
|
||||
{
|
||||
ctx.Context.Response.Headers[HeaderNames.CacheControl] =
|
||||
"public,max-age=" + cacheTime;
|
||||
}
|
||||
OnPrepareResponse = ctx =>
|
||||
{
|
||||
ctx.Context.Response.Headers[HeaderNames.CacheControl] =
|
||||
"public,max-age=" + cacheTime;
|
||||
}
|
||||
});
|
||||
app.UseStaticFiles(new StaticFileOptions
|
||||
{
|
||||
FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "img")),
|
||||
OnPrepareResponse = ctx =>
|
||||
{
|
||||
ctx.Context.Response.Headers[HeaderNames.CacheControl] =
|
||||
"public,max-age=" + cacheTime;
|
||||
}
|
||||
OnPrepareResponse = ctx =>
|
||||
{
|
||||
ctx.Context.Response.Headers[HeaderNames.CacheControl] =
|
||||
"public,max-age=" + cacheTime;
|
||||
}
|
||||
});
|
||||
app.UseRewriter(new Microsoft.AspNetCore.Rewrite.RewriteOptions().AddRedirect("(.*[^/|.xml|.html])$", "$1/", 301));
|
||||
app.UseIENoOpen();
|
||||
app.UseNoMimeSniff();
|
||||
app.UseCrossSiteScriptingFilters();
|
||||
app.UseFrameGuard(new FrameGuardOptions(FrameGuardOptions.FrameGuard.SAMEORIGIN));
|
||||
app.UseHsts(TimeSpan.FromDays(30), false, preload: true);
|
||||
app.UseHsts(TimeSpan.FromDays(365), false, preload: true);
|
||||
app.UseContentSecurityPolicy(
|
||||
new ContentSecurityPolicy()
|
||||
{
|
||||
// DefaultSrc = new HashSet<string>() {
|
||||
// CSPConstants.Self, "https://www.google-analytics.com", "https://www.googletagmanager.com", "https://stats.g.doubleclick.net"
|
||||
// },
|
||||
// ScriptSrc = new HashSet<string>()
|
||||
// {
|
||||
// CSPConstants.Self, CSPConstants.UnsafeInline, "https://www.google-analytics.com", "https://www.googletagmanager.com", "https://stats.g.doubleclick.net"
|
||||
// },
|
||||
// StyleSrc = new HashSet<string>()
|
||||
// {
|
||||
// CSPConstants.Self, CSPConstants.UnsafeInline
|
||||
// },
|
||||
UpgradeInsecureRequests = true
|
||||
});
|
||||
app.UseOutputCaching();
|
||||
app.UseMvc();
|
||||
}
|
||||
|
||||
72
src/TerribleDev.Blog.Web/Taghelpers/InlineCss.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Razor.TagHelpers;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.FileProviders;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TerribleDev.Blog.Web.Taghelpers
|
||||
{
|
||||
[HtmlTargetElement("inline-style")]
|
||||
public class InlineStyleTagHelper : TagHelper
|
||||
{
|
||||
[HtmlAttributeName("href")]
|
||||
public string Href { get; set; }
|
||||
|
||||
private IHostingEnvironment HostingEnvironment { get; }
|
||||
private IMemoryCache Cache { get; }
|
||||
|
||||
|
||||
|
||||
public InlineStyleTagHelper(IHostingEnvironment hostingEnvironment, IMemoryCache cache)
|
||||
{
|
||||
HostingEnvironment = hostingEnvironment;
|
||||
Cache = cache;
|
||||
}
|
||||
|
||||
|
||||
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
|
||||
{
|
||||
var path = Href;
|
||||
|
||||
// Get the value from the cache, or compute the value and add it to the cache
|
||||
var fileContent = await Cache.GetOrCreateAsync("InlineStyleTagHelper-" + path, async entry =>
|
||||
{
|
||||
var fileProvider = HostingEnvironment.WebRootFileProvider;
|
||||
if(HostingEnvironment.IsDevelopment())
|
||||
{
|
||||
var changeToken = fileProvider.Watch(path);
|
||||
entry.AddExpirationToken(changeToken);
|
||||
}
|
||||
|
||||
entry.SetPriority(CacheItemPriority.NeverRemove);
|
||||
|
||||
var file = fileProvider.GetFileInfo(path);
|
||||
if (file == null || !file.Exists)
|
||||
return null;
|
||||
|
||||
return await ReadFileContent(file);
|
||||
});
|
||||
|
||||
if (fileContent == null)
|
||||
{
|
||||
output.SuppressOutput();
|
||||
return;
|
||||
}
|
||||
|
||||
output.TagName = "style";
|
||||
output.Attributes.RemoveAll("href");
|
||||
output.Content.AppendHtml(fileContent);
|
||||
}
|
||||
|
||||
private static async Task<string> ReadFileContent(IFileInfo file)
|
||||
{
|
||||
using (var stream = file.CreateReadStream())
|
||||
using (var textReader = new StreamReader(stream))
|
||||
{
|
||||
return await textReader.ReadToEndAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,9 @@
|
||||
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
<UserSecretsId>9a1f51b6-f4d9-4df7-a0af-e345176e9927</UserSecretsId>
|
||||
<ApplicationInsightsResourceId>/subscriptions/088a81c7-d703-41c9-a1d0-476bce11df60/resourcegroups/WebResourceGroup/providers/microsoft.insights/components/tparnellblognew</ApplicationInsightsResourceId>
|
||||
<ApplicationInsightsAnnotationResourceId>/subscriptions/088a81c7-d703-41c9-a1d0-476bce11df60/resourcegroups/WebResourceGroup/providers/microsoft.insights/components/tparnellblognew</ApplicationInsightsAnnotationResourceId>
|
||||
<LangVersion>7.3</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -21,12 +24,14 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BuildBundlerMinifier" Version="2.8.391" />
|
||||
<PackageReference Include="Markdig" Version="0.15.7" />
|
||||
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.App" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.0.2105168" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.0" />
|
||||
<PackageReference Include="UriBuilder.Fluent" Version="1.5.2" />
|
||||
<PackageReference Include="YamlDotNet" Version="5.3.0" />
|
||||
<PackageReference Include="HardHat" Version="2.0.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" />
|
||||
</ItemGroup>
|
||||
@@ -36,4 +41,9 @@
|
||||
<Content Include="Posts\*.md" CopyToOutputDirectory="Always" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<WCFMetadata Include="Connected Services" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
@model IPost
|
||||
@inject BlogConfiguration config
|
||||
@model IPost
|
||||
@{
|
||||
ViewData["Title"] = "Post";
|
||||
ViewData["HideNav"] = true;
|
||||
@@ -13,20 +14,21 @@
|
||||
<meta property="og:type" content="blog">
|
||||
<meta property="og:title" content="@Model.Title">
|
||||
<meta property="og:url" content="https://blog.terribledev.io/@Model.Url/">
|
||||
<meta property="og:site_name" content="The Ramblings of TerribleDev">
|
||||
<meta property="og:site_name" content="@config.Title">
|
||||
<meta property="og:description" content="@Model.SummaryPlainShort">
|
||||
<meta property="og:updated_time" content="@Model.PublishDate.ToString("O")">
|
||||
<meta name="twitter:card" content="summary">
|
||||
<meta name="twitter:title" content="@Model.Title">
|
||||
<meta name="twitter:description" content="@Model.SummaryPlainShort">
|
||||
<meta name="twitter:site" content="@@TerribleDev">
|
||||
<meta name="twitter:creator" content="@@TerribleDev">
|
||||
<meta property="og:image" content="https://www.gravatar.com/avatar/333e3cea32cd17ff2007d131df336061?s=640" />
|
||||
@foreach(var image in Model.Images.Take(6))
|
||||
{
|
||||
<meta property="og:image" content="https://blog.terribledev.io@(image)">
|
||||
<meta property="og:image" content="@image">
|
||||
}
|
||||
@if(Model.Images.Count > 0)
|
||||
{
|
||||
<meta name="twitter:image" content="https://blog.terribledev.io@(Model.Images[0])">
|
||||
<meta name="twitter:image" content="@(Model.Images[0])">
|
||||
}
|
||||
<meta property="og:image" content="https://www.gravatar.com/avatar/333e3cea32cd17ff2007d131df336061?s=640" />
|
||||
}
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
|
||||
@inject Microsoft.ApplicationInsights.AspNetCore.JavaScriptSnippet JavaScriptSnippet
|
||||
@{
|
||||
Layout = null;
|
||||
}
|
||||
<link rel="preconnect" href="https://www.google-analytics.com">
|
||||
<link rel="preconnect" href="https://stats.g.doubleclick.net">
|
||||
<link rel="preconnect" href="https://www.googletagmanager.com">
|
||||
<link rel="preconnect" href="https://az416426.vo.msecnd.net" />
|
||||
<link rel="preconnect" href="https://dc.services.visualstudio.com" />
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-48128396-1"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
|
||||
gtag('config', 'UA-48128396-1');
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag() { dataLayer.push(arguments); }
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'UA-48128396-1');
|
||||
</script>
|
||||
@Html.Raw(JavaScriptSnippet.FullScript)
|
||||
@@ -2,7 +2,10 @@
|
||||
var hideNav = ViewData["HideNav"] != null ? "" : "withBody";
|
||||
}
|
||||
<nav class="navBar hide @hideNav" id="navBar">
|
||||
<img src="" alt="An image of TerribleDev" data-src="/content/tommyAvatar4.jpg" class="lazy round" />
|
||||
<picture>
|
||||
<source srcset="" type="image/webp" alt="An image of TerribleDev" data-src="/content/tommyAvatar4.jpg.webp" class="lazy round" />
|
||||
<img src="" alt="An image of TerribleDev" data-src="/content/tommyAvatar4.jpg" class="lazy round" />
|
||||
</picture>
|
||||
<span>Tommy "Terrible Dev" Parnell</span>
|
||||
<ul class="sidebarBtns">
|
||||
<li><a href="/" class="link-unstyled">Home</a></li>
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
<meta name="description" content="My name is Tommy Parnell. I usually go by TerribleDev on the internets. These are just some of my writings and rants about the software space." />
|
||||
@inject BlogConfiguration config
|
||||
<meta name="description" content="My name is Tommy Parnell. I usually go by TerribleDev on the internets. These are just some of my writings and rants about the software space." />
|
||||
<meta property="og:type" content="blog">
|
||||
<meta property="og:title" content="The Ramblings of TerribleDev">
|
||||
<meta property="og:title" content="@config.Title">
|
||||
<meta property="og:url" content="https://blog.terribledev.io/">
|
||||
<meta property="og:site_name" content="The Ramblings of TerribleDev">
|
||||
<meta property="og:site_name" content="@config.Title">
|
||||
<meta property="og:description" content="My name is Tommy Parnell. I usually go by TerribleDev on the internets. These are just some of my writings and rants about the software space.">
|
||||
<meta name="twitter:card" content="summary">
|
||||
<meta name="twitter:title" content="The Ramblings of TerribleDev">
|
||||
<meta name="twitter:title" content="@config.Title">
|
||||
<meta name="twitter:description" content="My name is Tommy Parnell. I usually go by TerribleDev on the internets. These are just some of my writings and rants about the software space.">
|
||||
<meta name="twitter:creator" content="@@TerribleDev">
|
||||
<meta property="og:image" content="https://www.gravatar.com/avatar/333e3cea32cd17ff2007d131df336061?s=640" />
|
||||
@@ -1,20 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
@inject BlogConfiguration config
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<partial name="Gtm" />
|
||||
<environment names="Production">
|
||||
<partial name="Gtm" />
|
||||
</environment>
|
||||
<meta name="author" content="Tommy "TerribleDev" Parnell" />
|
||||
<meta name="theme-color" content="#4A4A4A" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="alternate" type="application/atom+xml" async title="RSS" href="/rss.xml">
|
||||
<link rel="manifest" href="~/manifest.json" async asp-append-version="true">
|
||||
<link asp-append-version="true" rel="icon" async href="~/favicon.ico" />
|
||||
<title>@ViewData["Title"] - The Ramblings of TerribleDev</title>
|
||||
<title>@ViewData["Title"] - @config.Title</title>
|
||||
<environment names="Development">
|
||||
<link asp-append-version="true" rel="stylesheet" href="~/css/site.css" />
|
||||
<inline-style href="css/site.css"></inline-style>
|
||||
</environment>
|
||||
<environment names="Production">
|
||||
<link asp-append-version="true" rel="stylesheet" href="~/css/site.min.css" />
|
||||
<inline-style href="css/site.min.css"></inline-style>
|
||||
</environment>
|
||||
@RenderSection("Head", false)
|
||||
</head>
|
||||
@@ -22,7 +26,7 @@
|
||||
<partial name="Nav" />
|
||||
<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>
|
||||
<div class="headerCallout"><a href="/" class="link-unstyled ">The Ramblings of TerribleDev</a></div>
|
||||
<div class="headerCallout"><a href="/" class="link-unstyled ">@config.Title</a></div>
|
||||
</header>
|
||||
@{
|
||||
var bodyBump = ViewData["HideNav"] == null ? "bodyWithNav": "";
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
@model Dictionary<string, List<IPost>>
|
||||
@using System.Collections.Immutable;
|
||||
@model IDictionary<string, ImmutableList<IPost>>
|
||||
@{
|
||||
ViewData["Title"] = "all-tags";
|
||||
}
|
||||
|
||||
5
src/TerribleDev.Blog.Web/appsettings.Production.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"ApplicationInsights": {
|
||||
"InstrumentationKey": "974b47d2-1f08-42df-b498-bbfda7425f0b"
|
||||
}
|
||||
}
|
||||
@@ -9,5 +9,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
"AllowedHosts": "*",
|
||||
"Blog": {
|
||||
"title": "The Ramblings of TerribleDev",
|
||||
"link": "https://blog.terribledev.io"
|
||||
}
|
||||
}
|
||||
BIN
src/TerribleDev.Blog.Web/wwwroot/Banner.jpg.webp
Normal file
|
After Width: | Height: | Size: 300 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 152 KiB |
|
After Width: | Height: | Size: 152 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 113 KiB |
|
After Width: | Height: | Size: 113 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 4.9 KiB |
|
After Width: | Height: | Size: 7.0 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 195 KiB |
|
After Width: | Height: | Size: 72 KiB |
|
After Width: | Height: | Size: 44 KiB |
|
After Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 8.9 KiB |
|
After Width: | Height: | Size: 46 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 67 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 9.6 KiB |
|
After Width: | Height: | Size: 8.8 KiB |
|
After Width: | Height: | Size: 6.7 KiB |
|
After Width: | Height: | Size: 56 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 144 KiB |
BIN
src/TerribleDev.Blog.Web/wwwroot/content/pencil.png.webp
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
src/TerribleDev.Blog.Web/wwwroot/content/ppr.jpg.webp
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
src/TerribleDev.Blog.Web/wwwroot/content/profile.jpg.webp
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
src/TerribleDev.Blog.Web/wwwroot/content/tommyAvatar2.jpg.webp
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
src/TerribleDev.Blog.Web/wwwroot/content/tommyAvatar3.jpg.webp
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
src/TerribleDev.Blog.Web/wwwroot/content/tommyAvatar4.jpg.webp
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
@@ -29,6 +29,10 @@ h5 {
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
article {
|
||||
margin-top: .5em;
|
||||
}
|
||||
|
||||
body {
|
||||
text-rendering: optimizeLegibility;
|
||||
letter-spacing: -.01em;
|
||||
@@ -47,7 +51,7 @@ body {
|
||||
padding-bottom: 1.2em;
|
||||
}
|
||||
.headerBump {
|
||||
padding-top: 4rem;
|
||||
padding-top: 3.5rem;
|
||||
}
|
||||
|
||||
.main-content-wrap img {
|
||||
|
||||
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 75 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 64 KiB |
|
After Width: | Height: | Size: 7.4 KiB |
|
After Width: | Height: | Size: 9.3 KiB |
|
After Width: | Height: | Size: 9.4 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 8.4 KiB |
|
After Width: | Height: | Size: 6.7 KiB |