Support directory installations

- Add web log to HttpContext on first retrieval per req
- Add several DotLiquid filters
- Use int for page numbers
- Update all themes to use rel/abs link and other filters
This commit is contained in:
2022-05-21 22:55:13 -04:00
parent 63425ad806
commit cbf87f5b49
41 changed files with 658 additions and 485 deletions

View File

@@ -289,8 +289,20 @@ module WebLog =
timeZone = ""
}
/// Convert a permalink to an absolute URL
let absoluteUrl webLog = function Permalink link -> $"{webLog.urlBase}{link}"
/// Get the host (including scheme) and extra path from the URL base
let hostAndPath webLog =
let scheme = webLog.urlBase.Split "://"
let host = scheme[1].Split "/"
$"{scheme[0]}://{host[0]}", if host.Length > 1 then $"""/{String.Join ("/", host |> Array.skip 1)}""" else ""
/// Generate an absolute URL for the given link
let absoluteUrl webLog permalink =
$"{webLog.urlBase}/{Permalink.toString permalink}"
/// Generate a relative URL for the given link
let relativeUrl webLog permalink =
let _, leadPath = hostAndPath webLog
$"{leadPath}/{Permalink.toString permalink}"
/// Convert a date/time to the web log's local date/time
let localTime webLog (date : DateTime) =

View File

@@ -400,7 +400,8 @@ type PostListItem =
/// Create a post list item from a post
static member fromPost (webLog : WebLog) (post : Post) =
let inTZ = WebLog.localTime webLog
let _, extra = WebLog.hostAndPath webLog
let inTZ = WebLog.localTime webLog
{ id = PostId.toString post.id
authorId = WebLogUserId.toString post.authorId
status = PostStatus.toString post.status
@@ -408,7 +409,7 @@ type PostListItem =
permalink = Permalink.toString post.permalink
publishedOn = post.publishedOn |> Option.map inTZ |> Option.toNullable
updatedOn = inTZ post.updatedOn
text = post.text
text = if extra = "" then post.text else post.text.Replace ("href=\"/", $"href=\"{extra}/")
categoryIds = post.categoryIds |> List.map CategoryId.toString
tags = post.tags
meta = post.metadata