Vendor htmx 2.0.6 (#57)

This commit is contained in:
Daniel J. Summers 2025-07-04 18:18:13 -04:00
parent e8953d6072
commit 87fbb1a8c7
5 changed files with 34 additions and 14 deletions

View File

@ -8,6 +8,7 @@ open MyWebLog
/// Module to resolve routes that do not match any other known route (web blog content)
module CatchAll =
open System.IO
open MyWebLog.ViewModels
/// Sequence where the first returned value is the proper handler for the link
@ -22,6 +23,20 @@ module CatchAll =
let await it = (Async.AwaitTask >> Async.RunSynchronously) it
seq {
debug (fun () -> $"Considering URL {textLink}")
let staticFileName =
[ ctx.GetWebHostEnvironment().ContentRootPath
"wwwroot"
if textLink.Length > 1 then textLink[1..] else textLink ]
|> String.concat (string Path.DirectorySeparatorChar)
match File.Exists staticFileName with
| true ->
debug (fun () -> $"File {textLink} is a static file")
yield
File.GetLastWriteTimeUtc staticFileName
|> System.DateTimeOffset
|> Some
|> streamFile true staticFileName None
| false -> ()
// Home page directory without the directory slash
if textLink = "" then yield redirectTo true (webLog.RelativeUrl Permalink.Empty)
let permalink = Permalink textLink[1..]
@ -84,9 +99,11 @@ module CatchAll =
}
// GET {all-of-the-above}
let route : HttpHandler = fun next ctx ->
match deriveAction ctx |> Seq.tryHead with Some handler -> handler next ctx | None -> Error.notFound next ctx
let route : HttpHandler = fun next ctx -> task {
match deriveAction ctx |> Seq.tryHead with
| Some handler -> return! handler next ctx
| None -> return None // Error.notFound next ctx
}
/// Serve theme assets
module Asset =
@ -242,7 +259,7 @@ let router : HttpHandler = choose [
]
])
GET_HEAD >=> CatchAll.route
Error.notFound
//Error.notFound
]
/// Wrap a router in a sub-route

View File

@ -28,6 +28,7 @@
<Compile Include="DotLiquidBespoke.fs" />
<Compile Include="Maintenance.fs" />
<Compile Include="Program.fs" />
<Content Include="wwwroot\htmx.min.js" CopyToOutputDirectory="Always" />
</ItemGroup>
<ItemGroup>

View File

@ -7,7 +7,6 @@ open System.IO
open System.Text
open Fluid
open Fluid.Values
open Giraffe.ViewEngine
open Microsoft.AspNetCore.Antiforgery
open Microsoft.Extensions.FileProviders
open MyWebLog
@ -237,7 +236,9 @@ let parser =
fun writer encoder context ->
let webLog = context.App.WebLog
if webLog.AutoHtmx then
writer.WriteLine $"{s}{RenderView.AsString.htmlNode Htmx.Script.minified}"
context.App.WebLog.RelativeUrl(Permalink "htmx.min.js")
|> sprintf "%s<script src=\"%s\"></script>" s
|> writer.WriteLine
if assetExists "script.js" webLog then
themeAsset (StringValue "script.js") context
|> sprintf "%s<script src=\"%s\"></script>" s

View File

@ -317,7 +317,7 @@ module Layout =
script [ _src "https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"
_integrity "sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
_crossorigin "anonymous" ] []
Script.minified
script [ _src (relUrl app "htmx.min.js") ] []
script [ _src (relUrl app "themes/admin/admin.js") ] []
]
]

1
src/MyWebLog/wwwroot/htmx.min.js vendored Normal file

File diff suppressed because one or more lines are too long