Move redirect rule to 2 row, remove no-wrap (#55)

- Fix redirect rule handling with endpoint routing (#59)
- Make subtitle non-nullable string (#47)
This commit is contained in:
2026-07-18 12:50:27 -04:00
parent 816a156d79
commit 3a19952f39
6 changed files with 14 additions and 17 deletions
+2 -3
View File
@@ -101,10 +101,9 @@ module WebLogCache =
let relUrl = Permalink >> webLog.RelativeUrl
let urlTo = if it.To.Contains "://" then it.To else relUrl it.To
if it.IsRegex then
let pattern = if it.From.StartsWith "^" then $"^{relUrl it.From[1..]}" else it.From
RegEx(Regex(pattern, RegexOptions.Compiled ||| RegexOptions.IgnoreCase), urlTo)
RegEx(Regex(it.From, RegexOptions.Compiled ||| RegexOptions.IgnoreCase), urlTo)
else
Text(relUrl it.From, urlTo))
Text(it.From, urlTo))
/// <summary>Get all cached web logs</summary>
/// <returns>All cached web logs</returns>
+1 -1
View File
@@ -139,7 +139,7 @@ let pageOfCategorizedPosts slugAndPage : HttpHandler = fun next ctx -> task {
return!
{ viewCtx with
PageTitle = $"{cat.Name}: Category Archive{pgTitle}"
Subtitle = cat.Description
Subtitle = defaultArg cat.Description ""
IsCategory = true
IsCategoryHome = (pageNbr = 1)
Slug = Some slug }
+4 -4
View File
@@ -39,15 +39,15 @@ type RedirectRuleMiddleware(next: RequestDelegate, _log: ILogger<RedirectRuleMid
String.Equals(str1, str2, StringComparison.InvariantCultureIgnoreCase)
member _.InvokeAsync(ctx: HttpContext) = task {
let path = ctx.Request.Path.Value.ToLower()
let path = ctx.Request.Path.Value.ToLower()[1..]
let matched =
WebLogCache.redirectRules ctx.WebLog.Id
|> List.tryPick (fun rule ->
match rule with
| WebLogCache.CachedRedirectRule.Text (urlFrom, urlTo) ->
| WebLogCache.CachedRedirectRule.Text(urlFrom, urlTo) ->
if ciEquals path urlFrom then Some urlTo else None
| WebLogCache.CachedRedirectRule.RegEx (regExFrom, patternTo) ->
if regExFrom.IsMatch path then Some (regExFrom.Replace(path, patternTo)) else None)
| WebLogCache.CachedRedirectRule.RegEx(regExFrom, patternTo) ->
if regExFrom.IsMatch path then regExFrom.Replace(path, patternTo) |> Some else None)
match matched with
| Some url when url.StartsWith "http" && ctx.Request.IsHtmx ->
do! ctx.Response.WriteAsync $"""<script>window.location.href = "{url}"</script>"""
+3 -3
View File
@@ -18,7 +18,7 @@ type AppViewContext = {
PageTitle: string
/// <summary>The subtitle for the page</summary>
Subtitle: string option
Subtitle: string
/// <summary>The anti-Cross Site Request Forgery (CSRF) token set to use when rendering a form</summary>
Csrf: AntiforgeryTokenSet option
@@ -94,7 +94,7 @@ type AppViewContext = {
/// <summary>The payload for this page as a <c>PostDisplay</c></summary>
member this.Posts =
this.Payload :?> PostDisplay
/// <summary>The model for this view (prior versions used <c>model</c> for the v3 <c>payload</c>)</summary>
member this.Model =
this.Payload
@@ -104,7 +104,7 @@ type AppViewContext = {
{ WebLog = WebLog.Empty
UserId = None
PageTitle = ""
Subtitle = None
Subtitle = ""
Csrf = None
PageList = [||]
Categories = [||]
+3 -5
View File
@@ -453,8 +453,8 @@ let redirectList (model: RedirectRule list) app = [
let ruleDetail idx (rule: RedirectRule) =
let ruleId = $"rule_{idx}"
div [ _class "row mwl-table-detail"; _id ruleId ] [
div [ _class "col-5 no-wrap" ] [
txt rule.From; br []
div [ _class "col-10" ] [
txt rule.From; br []; raw "&#xbb; "; txt rule.To; br []
small [] [
let ruleUrl = relUrl app $"admin/settings/redirect-rules/{idx}"
a [ _href ruleUrl; _hxBoost; _hxTarget $"#{ruleId}"
@@ -472,7 +472,6 @@ let redirectList (model: RedirectRule list) app = [
]
]
]
div [ _class "col-5" ] [ txt rule.To ]
div [ _class "col-2 text-center" ] [ yesOrNo rule.IsRegex ]
]
h2 [ _class "my-3" ] [ raw app.PageTitle ]
@@ -496,8 +495,7 @@ let redirectList (model: RedirectRule list) app = [
else
div [ _class "container g-0" ] [
div [ _class "row mwl-table-heading" ] [
div [ _class "col-5" ] [ raw "From" ]
div [ _class "col-5" ] [ raw "To" ]
div [ _class "col-10" ] [ raw "From &#xbb; To" ]
div [ _class "col-2 text-center" ] [ raw "RegEx?" ]
]
]
+1 -1
View File
@@ -1,6 +1,6 @@
{%- if is_category or is_tag %}
<h1 class=index-title>{{ page_title }}</h1>
{%- if subtitle %}<h4 class=text-muted>{{ subtitle }}</h4>{% endif -%}
{%- if subtitle <> "" %}<h4 class=text-muted>{{ subtitle }}</h4>{% endif -%}
{% endif %}
{%- assign post_count = model.posts | size -%}
{%- if post_count > 0 %}