Skip to content

Commit bcd879c

Browse files
committed
Finish research read logic and add docs 📚
1 parent df0a7cf commit bcd879c

File tree

12 files changed

+2491
-48
lines changed

12 files changed

+2491
-48
lines changed

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,23 @@ alumni: 2020-Master Student
4040
phone: +49 000 111 4242 # this is only an example
4141
4242
---
43-
```
43+
```
44+
45+
### Research
46+
47+
Create a `.md` file in `src/content/research`. All fields without an `#!` are optional.
48+
49+
Images must be places in `src/content/images/research`.
50+
51+
Without `index` slides are sorted to the end.
52+
53+
```yaml
54+
---
55+
index: <int>
56+
img: <image_name_in_folder>
57+
img_url: <url_to_image>
58+
---
59+
# My cool research
60+
61+
Any content in **markdown**!
62+
```

src/config.fsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ let staticPredicate (projectRoot: string, page: string) =
1818
let fileShouldBeExcluded =
1919
ext = ".fsx" ||
2020
ext = ".md" ||
21+
ext = ".p" ||
22+
ext = ".bib" ||
2123
page.Contains "_public" ||
2224
page.Contains "_bin" ||
2325
page.Contains "_lib" ||

src/content/images/research/SharingisCaring.svg

Lines changed: 2340 additions & 0 deletions
Loading

src/content/research/ml_models.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
img_url: https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTA8xW91n5FW9fiEs9GLr6Zw3nCuwXJTKF68XU1OkStYr8VKd1ylTYi70pITgnI_Zk_ayg&usqp=CAU
3+
index: 2
4+
---
5+
6+
# Machine Learning Models in Bioscience
7+
8+
Machine learning (ML) models revolutionize bioscience by analyzing complex biological data, predicting outcomes, and discovering patterns. They accelerate drug discovery, enhance disease diagnosis, and personalize treatments. By handling vast datasets efficiently, ML models drive innovative research and advance our understanding of biological systems.

src/content/research/rdf.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
img: SharingisCaring.svg
3+
index: 1
4+
---
5+
6+
# Research Data Management
7+
8+
Effective research data management ensures data integrity, reproducibility, and accessibility. It enhances reliability, facilitates collaboration, and meets funding and regulatory requirements. Good RDM practices support scientific transparency, protect sensitive information, and maximize research impact, making it a vital component of successful research projects.

src/content/research/statistics.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
img_url: https://fslab.org/FSharp.Stats/img/logo.png
3+
---
4+
5+
# Statistic
6+
7+
Statistics in bioscience is essential for analyzing biological data, validating experimental results, and drawing reliable conclusions. It aids in understanding biological processes, designing experiments, and making informed decisions. Statistical methods ensure the accuracy and reproducibility of research, driving advancements in health, genetics, and environmental studies.
8+
9+
🔗 [F# Stats](https://fslab.org/FSharp.Stats/#FSharp-Stats)

src/generators/sections/research.fsx

Lines changed: 16 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,12 @@
11
#r "../../_lib/Fornax.Core.dll"
2+
#if !FORNAX
3+
#load "../../loaders/researchloader.fsx"
4+
#endif
25

36
open Html
47

5-
type FrameSlide = {
6-
Content: string
7-
Image: string
8-
}
98

10-
let Example1 = {
11-
Content = """<ul>
12-
<li>Main content categories, which describe common rules shared by many elements.</li>
13-
<li>Form-related content categories, which describe rules common to form-related elements.</li>
14-
<li>Specific content categories, which describe rare categories shared only by a few elements, sometimes only in a specific context.</li>
15-
</ul>"""
16-
Image = "https://picsum.photos/200/300"
17-
}
18-
19-
let Example2 = {
20-
Content = """<p>Flow content is a broad category that encompasses most elements that can go inside the <a href="/en-US/docs/Web/HTML/Element/body"><code>&lt;body&gt;</code></a> element, including heading elements, sectioning elements, phrasing elements, embedding elements, interactive elements, and form-related elements. It also includes text nodes (but not those that only consist of white space characters).</p>"""
21-
Image = "https://picsum.photos/200/300"
22-
}
23-
let Example3 = {
24-
Content = """<section aria-labelledby="sectioning_content"><h3 id="sectioning_content"><a href="#sectioning_content">Sectioning content</a></h3><div class="section-content"><p>Sectioning content, a subset of flow content, creates a <a href="/en-US/docs/Web/HTML/Element/Heading_Elements">section in the current outline</a> defining the scope of <a href="/en-US/docs/Web/HTML/Element/header"><code>&lt;header&gt;</code></a> and <a href="/en-US/docs/Web/HTML/Element/footer"><code>&lt;footer&gt;</code></a> elements.</p>
25-
<p>Elements belonging to this category are <a href="/en-US/docs/Web/HTML/Element/article"><code>&lt;article&gt;</code></a>, <a href="/en-US/docs/Web/HTML/Element/aside"><code>&lt;aside&gt;</code></a>, <a href="/en-US/docs/Web/HTML/Element/nav"><code>&lt;nav&gt;</code></a>, and <a href="/en-US/docs/Web/HTML/Element/section"><code>&lt;section&gt;</code></a>.</p></div></section>"""
26-
Image = "https://picsum.photos/200/300"
27-
}
28-
let Example4 = {
29-
Content = """<ul>
30-
<li><a href="/en-US/docs/Web/HTML/Element/a"><code>&lt;a&gt;</code></a>, if the <a href="/en-US/docs/Web/HTML/Element/a#href"><code>href</code></a> attribute is present</li>
31-
<li><a href="/en-US/docs/Web/HTML/Element/audio"><code>&lt;audio&gt;</code></a>, if the <a href="/en-US/docs/Web/HTML/Element/audio#controls"><code>controls</code></a> attribute is present</li>
32-
<li><a href="/en-US/docs/Web/HTML/Element/img"><code>&lt;img&gt;</code></a>, if the <a href="/en-US/docs/Web/HTML/Element/img#usemap"><code>usemap</code></a> attribute is present</li>
33-
<li><a href="/en-US/docs/Web/HTML/Element/input"><code>&lt;input&gt;</code></a>, if the <a href="/en-US/docs/Web/HTML/Element/input#type">type</a> attribute is not in the hidden state</li>
34-
<li><a href="/en-US/docs/Web/HTML/Element/object"><code>&lt;object&gt;</code></a>, if the <a href="/en-US/docs/Web/HTML/Element/object#usemap"><code>usemap</code></a> attribute is present</li>
35-
<li><a href="/en-US/docs/Web/HTML/Element/video"><code>&lt;video&gt;</code></a>, if the <a href="/en-US/docs/Web/HTML/Element/video#controls"><code>controls</code></a> attribute is present</li>
36-
</ul>"""
37-
Image = "https://picsum.photos/200/300"
38-
}
39-
40-
41-
let private createFrameSlide (slide: FrameSlide) =
9+
let private createFrameSlide (slide: Researchloader.FrameSlide) =
4210
let innerFlexBoxContainer = HtmlProperties.Style [Display "flex"; CSSProperties.Height "100%"; AlignItems "center"]
4311
li [Class "splide__slide"] [
4412
// container
@@ -47,7 +15,13 @@ let private createFrameSlide (slide: FrameSlide) =
4715
div [Class "cell research__cell"] [
4816
div [innerFlexBoxContainer] [
4917
div [] [
50-
img [Src slide.Image]
18+
img [
19+
match slide with
20+
| { Image = Some i} -> Src i
21+
| { ImageUrl = Some i} -> Src i
22+
| _ -> ()
23+
HtmlProperties.Style [MaxWidth "100%"]
24+
]
5125
]
5226
]
5327
]
@@ -61,18 +35,17 @@ let private createFrameSlide (slide: FrameSlide) =
6135
]
6236

6337
let generate (ctx : SiteContents) (_: string) =
64-
// section [Class "section research"; Id "research"] [
65-
// // createFrame [|ExampleBase; Example2; Example3; Example4|]
66-
67-
// ]
68-
let slides = [Example1; Example2; Example3; Example4]
38+
let researchList: Researchloader.FrameSlide list =
39+
ctx.TryGetValues<Researchloader.FrameSlide> ()
40+
|> Option.defaultValue Seq.empty
41+
|> Seq.toList
6942
div [HtmlProperties.Style [CSSProperties.Height "400px"]] [
7043
section [Class "splide"; HtmlProperties.Custom("aria-label","current research information")] [
7144
// div [Class "splide__slider"] [
7245
// ]
7346
div [Class "splide__track"] [
7447
ul [Class "splide__list"] [
75-
for slide in slides do
48+
for slide in researchList do
7649
createFrameSlide slide
7750
]
7851
]

src/loaders/bibloader.fsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ let loadFile (featured:bool) (bibFile: string) =
8080

8181
let loader (projectRoot: string) (siteContent: SiteContents) =
8282
let postsPath = Path.Combine(projectRoot, contentDir)
83-
printfn "%s" postsPath
8483
let options = EnumerationOptions(RecurseSubdirectories = false)
8584
let files = Directory.GetFiles(postsPath, "*", options)
8685
files

src/loaders/researchloader.fsx

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#r "../_lib/Fornax.Core.dll"
2+
#r "../_lib/Markdig.dll"
3+
4+
open System.IO
5+
open Markdig
6+
7+
let key_image = "img"
8+
let key_image_url: string = "img_url"
9+
10+
let contentDir = "content/research/"
11+
12+
let imgDir = "content/images/research/"
13+
14+
15+
module ContentReader =
16+
17+
let pipeline =
18+
let n = new MarkdownPipelineBuilder()
19+
n
20+
.UseAdvancedExtensions()
21+
.Build();
22+
23+
let isSeparator (input : string) =
24+
input.StartsWith "---"
25+
26+
///`fileContent` - content of page to parse. Usually whole content of `.md` file
27+
/// Returns map<string,string> with frontmatter and everything else as "content".
28+
let getData (fileContent : string []) =
29+
let fileContent = fileContent |> Array.skip 1 //First line must be ---
30+
let indexOfSeperator = fileContent |> Array.findIndex isSeparator
31+
let splitKey (line: string) =
32+
let seperatorIndex = line.IndexOf(':')
33+
if seperatorIndex > 0 then
34+
let key = line.[.. seperatorIndex - 1].Trim().ToLower()
35+
let value = line.[seperatorIndex + 1 ..].Trim()
36+
Some(key, value)
37+
else
38+
None
39+
let frontmatter, content =
40+
fileContent
41+
|> Array.splitAt indexOfSeperator
42+
frontmatter
43+
|> Seq.choose splitKey
44+
|> Map.ofSeq
45+
|> fun x -> x.Add(
46+
"content",
47+
content.[1..] //skip closing ---
48+
|> String.concat "\n"
49+
)
50+
51+
type FrameSlide = {
52+
Content: string
53+
Image: string option
54+
ImageUrl: string option
55+
} with
56+
static member create(content: string, ?image, ?imageurl) =
57+
{ Content = content; Image = image; ImageUrl = imageurl }
58+
59+
let getImageUrl (imageName: string) =
60+
imgDir + imageName
61+
62+
open Markdig
63+
64+
let loadFile (filePath: string) =
65+
let lines = File.ReadAllLines(filePath)
66+
let metadata = ContentReader.getData lines
67+
let content = metadata.["content"] |> fun c -> Markdown.ToHtml(c, ContentReader.pipeline)
68+
let image = metadata |> Map.tryFind key_image |> Option.map getImageUrl
69+
let imageUrl = metadata |> Map.tryFind key_image_url
70+
let index = metadata |> Map.tryFind "index" |> Option.map int |> Option.defaultValue System.Int32.MaxValue
71+
index, FrameSlide.create(content, ?image=image, ?imageurl=imageUrl)
72+
73+
let loader (projectRoot: string) (siteContent: SiteContents) =
74+
let postsPath = Path.Combine(projectRoot, contentDir)
75+
let options = EnumerationOptions(RecurseSubdirectories = true)
76+
let files = Directory.GetFiles(postsPath, "*", options)
77+
files
78+
|> Array.filter (fun n -> n.EndsWith ".md")
79+
|> Array.map (loadFile)
80+
|> Array.sortBy fst
81+
|> Array.map snd
82+
|> Array.iter siteContent.Add
83+
// siteContent.Add({disableLiveRefresh = false})
84+
siteContent

src/style/css/main.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/style/css/main.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/style/scss/sections/_research.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
background-color: white;
33
padding: 1rem;
44
max-height: 100%;
5-
5+
66
&:first-child {
7+
max-width: 50%;
78
border-top-left-radius: 8px;
89
border-bottom-left-radius: 8px;
910
}

0 commit comments

Comments
 (0)