From 30baf0a5d1d91f43f15c42561d18bf2875e91183 Mon Sep 17 00:00:00 2001 From: Kevin F Date: Mon, 11 Jul 2022 10:06:29 +0200 Subject: [PATCH] rm deprecated :boom: --- RELEASE_NOTES.md | 6 ++- src/Nfdi4Plants.Fornax/Components.fs | 51 --------------------- src/Nfdi4Plants.Fornax/Loaders.fs | 68 ---------------------------- 3 files changed, 4 insertions(+), 121 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 1674cdf..1eaee1d 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,9 +1,11 @@ -### 0.5.0+1de8f07 (Released 2022-7-8) +### 0.5.0+df516b0 (Released 2022-7-11) * Additions: - * latest commit #1de8f07 + * latest commit #df516b0 * [[#6aec175](https://github.com/Freymaurer/Nfdi4Plants.Fornax/commit/6aec175b5141ad87f113b6a0ac5e7bcf9d740850)] Update to rm deprecated from test client * [[#3036cf4](https://github.com/Freymaurer/Nfdi4Plants.Fornax/commit/3036cf47d8a46e9b4f3084d1e4430267d60173ae)] Merge branch 'main' of https://github.com/Freymaurer/nfdi4plants-fornax-template * [[#1de8f07](https://github.com/Freymaurer/Nfdi4Plants.Fornax/commit/1de8f0722c7d61c82441e2f3af5536be9ee10f52)] add sidebar basepath logic +* Bugfixes: + * [[#df516b0](https://github.com/Freymaurer/Nfdi4Plants.Fornax/commit/df516b0fcef211b3d2d6a727987fbd976d9d531e)] Fix basepath parsing issues :bug: ### 0.4.0+9e56047 (Released 2022-7-8) * Additions: diff --git a/src/Nfdi4Plants.Fornax/Components.fs b/src/Nfdi4Plants.Fornax/Components.fs index 555687b..f8ac687 100644 --- a/src/Nfdi4Plants.Fornax/Components.fs +++ b/src/Nfdi4Plants.Fornax/Components.fs @@ -2,57 +2,6 @@ namespace Fornax.Nfdi4Plants open Html -[] -module Components = - open Docs - - /// Creates nfdi-webcomponent layout for documentation. - /// Base path of fornax client. Is used to generate "Edit this page"-link - /// `DocsData` from generated by loaders. - /// Returns `HtmlElement`. Best put as direct child of `<body>` element. - let docsLayout (contentGithubUrl:string) (docs: DocsData) = - - let publishedDate = docs.published.Value.ToString("yyyy-MM-dd") - let sidebar = [ - if Array.isEmpty docs.sidebar |> not then - for sidebarEle in docs.sidebar do - yield custom "nfdi-sidebar-element" [HtmlProperties.Custom ("slot", "sidebar"); HtmlProperties.Custom ("isActive","true") ] [ - div [HtmlProperties.Custom ("slot", "title")] [!! sidebarEle.Title] - !! sidebarEle.Content - ] - else () - ] - custom "nfdi-body" [Class "content"; if Array.isEmpty docs.sidebar |> not then HtmlProperties.Custom("hasSidebar", "true")] [ - yield! sidebar - - h1 [Class "front-header"] [!! docs.title] - i [Class "help" ] [!! $"last updated at {publishedDate}" ] - - if docs.add_toc then custom "nfdi-toc" [] [] - !! docs.content - - // support contact - h3 [] [!! "Dataplant Support"] - div [] [ - !! "Besides these technical solutions, DataPLANT supports you with community-engaged data stewardship. For further assistance, feel free to reach out via our " - a [Href "https://support.nfdi4plants.org"] [!! "helpdesk"] - !! " or by contacting us " - a [Href "javascript:location='mailto:\u0069\u006e\u0066\u006f\u0040\u006e\u0066\u0064\u0069\u0034\u0070\u006c\u0061\u006e\u0074\u0073\u002e\u006f\u0072\u0067';void 0"] [!! "directly"] - !! "." - ] - - // Edit this page link - // https://github.com/nfdi4plants/nfdi4plants.github.io/tree/main/src/ - let editUrl = System.IO.Path.Combine(contentGithubUrl, docs.file) - div [] [ - a [ - Target "_blank" - Href editUrl; - HtmlProperties.Style [MarginLeft "auto"; Display "block"; CSSProperties.Width "130px"] - ] [!! "✏️ Edit this page"] - ] - ] - type Components = class end with /// Creates nfdi-webcomponent layout for documentation. diff --git a/src/Nfdi4Plants.Fornax/Loaders.fs b/src/Nfdi4Plants.Fornax/Loaders.fs index 2e29419..5eb9a4e 100644 --- a/src/Nfdi4Plants.Fornax/Loaders.fs +++ b/src/Nfdi4Plants.Fornax/Loaders.fs @@ -25,18 +25,6 @@ type SidebarElement = { Content: string } -[] -type DocsData = { - file: string - link : string - title: string - author: string option - published: System.DateTime option - add_toc: bool - sidebar: SidebarElement [] - content: string -} - type Docs = { file: string @@ -145,62 +133,6 @@ module internal Aux = Markdig.Markdown.ToHtml(content, Pipelines.markdownPipeline) -[] -module Docs = - - open System.IO - - /// Parse markdown `fileContent` to HTML with markdig and custom nfdi-webcomponent converter. - /// Base root directory path, will be appended to 'contentDir'. - /// Folder which to search for docs .md files. This folder will be used a relative root for sidebars. - /// Relative path to specific `.md` file. - /// Returns html as string. - [] - let loadFile (rootDir: string) (contentDir: string) (filePath: string) : DocsData = - try - let text = File.ReadAllText filePath - - let config = Aux.getConfig text - - let title = - config |> Map.tryFind "title" - // same as "fun x -> match x with" - |> function | Some title -> Aux.trimString title | None -> failwith $"""Could not find "Title"-metadata.""" - let author = - config |> Map.tryFind "author" |> Option.map Aux.trimString - let published = - config |> Map.tryFind "published" |> Option.map (Aux.trimString >> System.DateTime.Parse) - let addToc = - config |> Map.tryFind "add toc" |> Option.map (Aux.trimString >> System.Boolean.Parse) |> Option.defaultValue true - let addSidebar = - let docsPath = Path.Combine(rootDir, contentDir) - config |> Map.tryFind "add sidebar" |> Option.map (Aux.trimString >> fun x -> Path.Combine(docsPath, x.Replace('\\','/'))) - - let content = Aux.getContent text - let sidebar = addSidebar |> Option.map (Aux.getSidebar contentDir None) - let chopLength = - if rootDir.EndsWith(Path.DirectorySeparatorChar) then rootDir.Length - else rootDir.Length + 1 - - let dirPart = - filePath - |> Path.GetDirectoryName - |> fun x -> x.[chopLength .. ] - - let file = Path.Combine(dirPart, (filePath |> Path.GetFileNameWithoutExtension) + ".md").Replace("\\", "/") - let link = "/" + Path.Combine(dirPart, (filePath |> Path.GetFileNameWithoutExtension) + ".html").Replace("\\", "/") - - { file = file - link = link - title = title - author = author - published = published - content = content - add_toc = addToc - sidebar = if sidebar.IsSome then sidebar.Value else [||] } - with - | e -> failwith $"""[Error in file {filePath}] {e.Message}""" - type Docs with /// Parse markdown `fileContent` to HTML with markdig and custom nfdi-webcomponent converter.