From 32372a3f9f4cb1742670a042c39992db7c05905f Mon Sep 17 00:00:00 2001 From: "Daniel J. Summers" Date: Sat, 11 Jul 2026 17:58:00 -0400 Subject: [PATCH] Remove DotLiquid (#47) --- src/Directory.Packages.props | 1 - src/MyWebLog/DotLiquidBespoke.fs | 240 ------------------------------- src/MyWebLog/MyWebLog.fsproj | 2 - src/MyWebLog/Program.fs | 3 - src/MyWebLog/Template.fs | 13 +- 5 files changed, 5 insertions(+), 254 deletions(-) delete mode 100644 src/MyWebLog/DotLiquidBespoke.fs diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index c585bd5..68ee001 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -6,7 +6,6 @@ - diff --git a/src/MyWebLog/DotLiquidBespoke.fs b/src/MyWebLog/DotLiquidBespoke.fs deleted file mode 100644 index 2748712..0000000 --- a/src/MyWebLog/DotLiquidBespoke.fs +++ /dev/null @@ -1,240 +0,0 @@ -/// Custom DotLiquid filters and tags -module MyWebLog.DotLiquidBespoke - -open System -open System.IO -open System.Web -open DotLiquid -open MyWebLog.ViewModels - -/// Extensions on the DotLiquid Context object -type Context with - - /// Get the current web log from the DotLiquid context - member this.WebLog = - this.Environments[0].["web_log"] :?> WebLog - - -/// Does an asset exist for the current theme? -let assetExists fileName (webLog: WebLog) = - ThemeAssetCache.get webLog.ThemeId |> List.exists (fun it -> it = fileName) - -/// Obtain the link from known types -let permalink (item: obj) (linkFunc: Permalink -> string) = - match item with - | :? String as link -> Some link - | :? DisplayPage as page -> Some page.Permalink - | :? PostListItem as post -> Some post.Permalink - | :? DropProxy as proxy -> Option.ofObj proxy["Permalink"] |> Option.map string - | _ -> None - |> function - | Some link -> linkFunc (Permalink link) - | None -> $"alert('unknown item type {item.GetType().Name}')" - - -/// A filter to generate an absolute link -type AbsoluteLinkFilter() = - static member AbsoluteLink(ctx: Context, item: obj) = - permalink item ctx.WebLog.AbsoluteUrl - - -/// A filter to generate a link with posts categorized under the given category -type CategoryLinkFilter() = - static member CategoryLink(ctx: Context, catObj: obj) = - match catObj with - | :? DisplayCategory as cat -> Some cat.Slug - | :? DropProxy as proxy -> Option.ofObj proxy["Slug"] |> Option.map string - | _ -> None - |> function - | Some slug -> ctx.WebLog.RelativeUrl(Permalink $"category/{slug}/") - | None -> $"alert('unknown category object type {catObj.GetType().Name}')" - - -/// A filter to generate a link that will edit a page -type EditPageLinkFilter() = - static member EditPageLink(ctx: Context, pageObj: obj) = - match pageObj with - | :? DisplayPage as page -> Some page.Id - | :? DropProxy as proxy -> Option.ofObj proxy["Id"] |> Option.map string - | :? String as theId -> Some theId - | _ -> None - |> function - | Some pageId -> ctx.WebLog.RelativeUrl(Permalink $"admin/page/{pageId}/edit") - | None -> $"alert('unknown page object type {pageObj.GetType().Name}')" - - -/// A filter to generate a link that will edit a post -type EditPostLinkFilter() = - static member EditPostLink(ctx: Context, postObj: obj) = - match postObj with - | :? PostListItem as post -> Some post.Id - | :? DropProxy as proxy -> Option.ofObj proxy["Id"] |> Option.map string - | :? String as theId -> Some theId - | _ -> None - |> function - | Some postId -> ctx.WebLog.RelativeUrl(Permalink $"admin/post/{postId}/edit") - | None -> $"alert('unknown post object type {postObj.GetType().Name}')" - - -/// A filter to generate nav links, highlighting the active link (exact match) -type NavLinkFilter() = - static member NavLink(ctx: Context, url: string, text: string) = - let extraPath = ctx.WebLog.ExtraPath - let path = if extraPath = "" then "" else $"{extraPath[1..]}/" - seq { - "