Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
rm deprecated 💥
Browse files Browse the repository at this point in the history
  • Loading branch information
Freymaurer committed Jul 11, 2022
1 parent df516b0 commit 30baf0a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 121 deletions.
6 changes: 4 additions & 2 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
51 changes: 0 additions & 51 deletions src/Nfdi4Plants.Fornax/Components.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,6 @@ namespace Fornax.Nfdi4Plants

open Html

[<System.ObsoleteAttribute("Use type Component instead")>]
module Components =
open Docs

/// <summary>Creates nfdi-webcomponent layout for documentation.</summary>
/// <param name="contentGithubUrl">Base path of fornax client. Is used to generate "Edit this page"-link</param>
/// <param name="docs">`DocsData` from generated by loaders.</param>
/// <returns>Returns `HtmlElement`. Best put as direct child of `&lt;body&gt;` element.</returns>
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
/// <summary>Creates nfdi-webcomponent layout for documentation.</summary>
Expand Down
68 changes: 0 additions & 68 deletions src/Nfdi4Plants.Fornax/Loaders.fs
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,6 @@ type SidebarElement = {
Content: string
}

[<System.ObsoleteAttribute("Start using the Docs type")>]
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
Expand Down Expand Up @@ -145,62 +133,6 @@ module internal Aux =

Markdig.Markdown.ToHtml(content, Pipelines.markdownPipeline)

[<System.Obsolete("Start using the Docs type")>]
module Docs =

open System.IO

/// <summary>Parse markdown `fileContent` to HTML with markdig and custom nfdi-webcomponent converter.</summary>
/// <param name="rootDir">Base root directory path, will be appended to 'contentDir'.</param>
/// <param name="contentDir">Folder which to search for docs .md files. This folder will be used a relative root for sidebars.</param>
/// <param name="filePath">Relative path to specific `.md` file.</param>
/// <returns>Returns html as string.</returns>
[<System.Obsolete("Start using the Docs.load type")>]
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

/// <summary>Parse markdown `fileContent` to HTML with markdig and custom nfdi-webcomponent converter.</summary>
Expand Down

0 comments on commit 30baf0a

Please sign in to comment.