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:
@@ -101,10 +101,9 @@ module WebLogCache =
|
|||||||
let relUrl = Permalink >> webLog.RelativeUrl
|
let relUrl = Permalink >> webLog.RelativeUrl
|
||||||
let urlTo = if it.To.Contains "://" then it.To else relUrl it.To
|
let urlTo = if it.To.Contains "://" then it.To else relUrl it.To
|
||||||
if it.IsRegex then
|
if it.IsRegex then
|
||||||
let pattern = if it.From.StartsWith "^" then $"^{relUrl it.From[1..]}" else it.From
|
RegEx(Regex(it.From, RegexOptions.Compiled ||| RegexOptions.IgnoreCase), urlTo)
|
||||||
RegEx(Regex(pattern, RegexOptions.Compiled ||| RegexOptions.IgnoreCase), urlTo)
|
|
||||||
else
|
else
|
||||||
Text(relUrl it.From, urlTo))
|
Text(it.From, urlTo))
|
||||||
|
|
||||||
/// <summary>Get all cached web logs</summary>
|
/// <summary>Get all cached web logs</summary>
|
||||||
/// <returns>All cached web logs</returns>
|
/// <returns>All cached web logs</returns>
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ let pageOfCategorizedPosts slugAndPage : HttpHandler = fun next ctx -> task {
|
|||||||
return!
|
return!
|
||||||
{ viewCtx with
|
{ viewCtx with
|
||||||
PageTitle = $"{cat.Name}: Category Archive{pgTitle}"
|
PageTitle = $"{cat.Name}: Category Archive{pgTitle}"
|
||||||
Subtitle = cat.Description
|
Subtitle = defaultArg cat.Description ""
|
||||||
IsCategory = true
|
IsCategory = true
|
||||||
IsCategoryHome = (pageNbr = 1)
|
IsCategoryHome = (pageNbr = 1)
|
||||||
Slug = Some slug }
|
Slug = Some slug }
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ type RedirectRuleMiddleware(next: RequestDelegate, _log: ILogger<RedirectRuleMid
|
|||||||
String.Equals(str1, str2, StringComparison.InvariantCultureIgnoreCase)
|
String.Equals(str1, str2, StringComparison.InvariantCultureIgnoreCase)
|
||||||
|
|
||||||
member _.InvokeAsync(ctx: HttpContext) = task {
|
member _.InvokeAsync(ctx: HttpContext) = task {
|
||||||
let path = ctx.Request.Path.Value.ToLower()
|
let path = ctx.Request.Path.Value.ToLower()[1..]
|
||||||
let matched =
|
let matched =
|
||||||
WebLogCache.redirectRules ctx.WebLog.Id
|
WebLogCache.redirectRules ctx.WebLog.Id
|
||||||
|> List.tryPick (fun rule ->
|
|> List.tryPick (fun rule ->
|
||||||
@@ -47,7 +47,7 @@ type RedirectRuleMiddleware(next: RequestDelegate, _log: ILogger<RedirectRuleMid
|
|||||||
| WebLogCache.CachedRedirectRule.Text(urlFrom, urlTo) ->
|
| WebLogCache.CachedRedirectRule.Text(urlFrom, urlTo) ->
|
||||||
if ciEquals path urlFrom then Some urlTo else None
|
if ciEquals path urlFrom then Some urlTo else None
|
||||||
| WebLogCache.CachedRedirectRule.RegEx(regExFrom, patternTo) ->
|
| WebLogCache.CachedRedirectRule.RegEx(regExFrom, patternTo) ->
|
||||||
if regExFrom.IsMatch path then Some (regExFrom.Replace(path, patternTo)) else None)
|
if regExFrom.IsMatch path then regExFrom.Replace(path, patternTo) |> Some else None)
|
||||||
match matched with
|
match matched with
|
||||||
| Some url when url.StartsWith "http" && ctx.Request.IsHtmx ->
|
| Some url when url.StartsWith "http" && ctx.Request.IsHtmx ->
|
||||||
do! ctx.Response.WriteAsync $"""<script>window.location.href = "{url}"</script>"""
|
do! ctx.Response.WriteAsync $"""<script>window.location.href = "{url}"</script>"""
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ type AppViewContext = {
|
|||||||
PageTitle: string
|
PageTitle: string
|
||||||
|
|
||||||
/// <summary>The subtitle for the page</summary>
|
/// <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>
|
/// <summary>The anti-Cross Site Request Forgery (CSRF) token set to use when rendering a form</summary>
|
||||||
Csrf: AntiforgeryTokenSet option
|
Csrf: AntiforgeryTokenSet option
|
||||||
@@ -104,7 +104,7 @@ type AppViewContext = {
|
|||||||
{ WebLog = WebLog.Empty
|
{ WebLog = WebLog.Empty
|
||||||
UserId = None
|
UserId = None
|
||||||
PageTitle = ""
|
PageTitle = ""
|
||||||
Subtitle = None
|
Subtitle = ""
|
||||||
Csrf = None
|
Csrf = None
|
||||||
PageList = [||]
|
PageList = [||]
|
||||||
Categories = [||]
|
Categories = [||]
|
||||||
|
|||||||
@@ -453,8 +453,8 @@ let redirectList (model: RedirectRule list) app = [
|
|||||||
let ruleDetail idx (rule: RedirectRule) =
|
let ruleDetail idx (rule: RedirectRule) =
|
||||||
let ruleId = $"rule_{idx}"
|
let ruleId = $"rule_{idx}"
|
||||||
div [ _class "row mwl-table-detail"; _id ruleId ] [
|
div [ _class "row mwl-table-detail"; _id ruleId ] [
|
||||||
div [ _class "col-5 no-wrap" ] [
|
div [ _class "col-10" ] [
|
||||||
txt rule.From; br []
|
txt rule.From; br []; raw "» "; txt rule.To; br []
|
||||||
small [] [
|
small [] [
|
||||||
let ruleUrl = relUrl app $"admin/settings/redirect-rules/{idx}"
|
let ruleUrl = relUrl app $"admin/settings/redirect-rules/{idx}"
|
||||||
a [ _href ruleUrl; _hxBoost; _hxTarget $"#{ruleId}"
|
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 ]
|
div [ _class "col-2 text-center" ] [ yesOrNo rule.IsRegex ]
|
||||||
]
|
]
|
||||||
h2 [ _class "my-3" ] [ raw app.PageTitle ]
|
h2 [ _class "my-3" ] [ raw app.PageTitle ]
|
||||||
@@ -496,8 +495,7 @@ let redirectList (model: RedirectRule list) app = [
|
|||||||
else
|
else
|
||||||
div [ _class "container g-0" ] [
|
div [ _class "container g-0" ] [
|
||||||
div [ _class "row mwl-table-heading" ] [
|
div [ _class "row mwl-table-heading" ] [
|
||||||
div [ _class "col-5" ] [ raw "From" ]
|
div [ _class "col-10" ] [ raw "From » To" ]
|
||||||
div [ _class "col-5" ] [ raw "To" ]
|
|
||||||
div [ _class "col-2 text-center" ] [ raw "RegEx?" ]
|
div [ _class "col-2 text-center" ] [ raw "RegEx?" ]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{%- if is_category or is_tag %}
|
{%- if is_category or is_tag %}
|
||||||
<h1 class=index-title>{{ page_title }}</h1>
|
<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 %}
|
{% endif %}
|
||||||
{%- assign post_count = model.posts | size -%}
|
{%- assign post_count = model.posts | size -%}
|
||||||
{%- if post_count > 0 %}
|
{%- if post_count > 0 %}
|
||||||
|
|||||||
Reference in New Issue
Block a user