case insensitive url on post
This commit is contained in:
38
fly.toml
Normal file
38
fly.toml
Normal file
@@ -0,0 +1,38 @@
|
||||
# fly.toml file generated for tp-blog-2 on 2022-08-26T12:21:08-04:00
|
||||
|
||||
app = "tp-blog-2"
|
||||
kill_signal = "SIGINT"
|
||||
kill_timeout = 5
|
||||
processes = []
|
||||
|
||||
[env]
|
||||
|
||||
[experimental]
|
||||
allowed_public_ports = []
|
||||
auto_rollback = true
|
||||
|
||||
[[services]]
|
||||
http_checks = []
|
||||
internal_port = 80
|
||||
processes = ["app"]
|
||||
protocol = "tcp"
|
||||
script_checks = []
|
||||
[services.concurrency]
|
||||
hard_limit = 25
|
||||
soft_limit = 20
|
||||
type = "connections"
|
||||
|
||||
[[services.ports]]
|
||||
force_https = true
|
||||
handlers = ["http"]
|
||||
port = 80
|
||||
|
||||
[[services.ports]]
|
||||
handlers = ["tls", "http"]
|
||||
port = 443
|
||||
|
||||
[[services.tcp_checks]]
|
||||
grace_period = "1s"
|
||||
interval = "15s"
|
||||
restart_limit = 0
|
||||
timeout = "2s"
|
||||
@@ -73,10 +73,16 @@ namespace TerribleDev.Blog.Web.Controllers
|
||||
{
|
||||
return this.RedirectPermanent($"/{postUrl}");
|
||||
}
|
||||
// case sensitive lookup
|
||||
if(postCache.UrlToPost.TryGetValue(postUrl, out var currentPost))
|
||||
{
|
||||
return View("Post", model: new PostViewModel() { Post = currentPost });
|
||||
}
|
||||
// case insensitive lookup on post
|
||||
if(postCache.CaseInsensitiveUrlToPost.TryGetValue(postUrl, out var caseInsensitivePost))
|
||||
{
|
||||
return View("Post", model: new PostViewModel() { Post = caseInsensitivePost });
|
||||
}
|
||||
if(postCache.LandingPagesUrl.TryGetValue(postUrl, out var landingPage))
|
||||
{
|
||||
return View("Post", model: new PostViewModel() { Post = landingPage });
|
||||
|
||||
@@ -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
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user