simple-learning

Simple learning web program
git clone git://git.laack.co/simple-learning.git
Log | Files | Refs | README | LICENSE

commit 9c302a6c71ceeb04d14ea68306e0ed39535f9a9f
parent 5385f0c1a0e9efae0fafd479077ad76b9d6300d6
Author: Andrew Laack <andrew@laack.co>
Date:   Thu, 27 Aug 2026 10:12:40 -0500

Added a sidebar and basic site nav stuff

Diffstat:
Aexample/haskell.rl | 3+++
Mlearning/bin/main.ml | 31+++++++++++++++++++++++++++++--
Mlearning/static/styles.css | 27+++++++++++++++++++++++++++
Moutputs/out.html | 10+++++++++-
Moutputs/styles.css | 26++++++++++++++++++++++++++
5 files changed, 94 insertions(+), 3 deletions(-)

diff --git a/example/haskell.rl b/example/haskell.rl @@ -0,0 +1,3 @@ +# Haskell + +This is just some information from this site diff --git a/learning/bin/main.ml b/learning/bin/main.ml @@ -42,17 +42,44 @@ let basic_html_prefix = <link rel=\"stylesheet\" href=\"/static/styles.css\" type=\"text/css\"> </head> <body> + <div class=\"sidenav\"> + <a href=\"/\">Home</a> + <a href=\"#\">Services</a> + <a href=\"#\">Clients</a> + <a href=\"#\">Contact</a> + </div> + <div class=\"main\"> " let basic_html_suffix = "</body> + </div> </html>" + +let arr_to_string arr fn = + let rec go acc idx = + if idx < Array.length(arr) then + go (acc ^ (fn arr.(idx))) (idx + 1) + else acc + in go "" 0 + +let remove_file_extension file_name = + let fin_period_pos = String.rindex file_name '.' in + String.sub file_name 0 fin_period_pos + +let course_to_html name = + "<div> <a href=\"/course/" ^ (remove_file_extension name) ^ "\">" ^ (remove_file_extension name) ^ "</div>" + +let get_courses = + basic_html_prefix ^ arr_to_string (Sys.readdir "../example/") course_to_html ^ basic_html_suffix + let () = Dream.run @@ Dream.logger @@ Dream.router [ - Dream.get "/" - (fun _ -> Dream.html (basic_html_prefix ^ (readFile "../example/ocaml.rl" handle_normal_line) ^ basic_html_suffix)); + Dream.get "/course/:id" + (fun request -> Dream.html (basic_html_prefix ^ (readFile ("../example/" ^ Dream.param request "id" ^ ".rl") handle_normal_line) ^ basic_html_suffix)); Dream.get "/static/**" (Dream.static "./static"); + Dream.get "/" (fun _ -> Dream.html get_courses); ] diff --git a/learning/static/styles.css b/learning/static/styles.css @@ -29,3 +29,30 @@ content-block { display: block; color: #000000; } + +.sidenav { + height: 100%; /* Full-height: remove this if you want "auto" height */ + width: 160px; /* Set the width of the sidebar */ + position: fixed; /* Fixed Sidebar (stay in place on scroll) */ + z-index: 1; /* Stay on top */ + top: 0; /* Stay at the top */ + left: 0; + background-color: #111; /* Black */ + overflow-x: hidden; /* Disable horizontal scroll */ + padding-top: 20px; +} + +/* The navigation menu links */ +.sidenav a { + padding: 6px 8px 6px 16px; + text-decoration: none; + font-size: 25px; + color: #A18181; + display: block; +} + +.main { + margin-left: 160px; /* Same as the width of the sidebar */ + padding: 0px 10px; +} + diff --git a/outputs/out.html b/outputs/out.html @@ -1,4 +1,12 @@ <link rel="stylesheet" href="styles.css" type="text/css"> +<div class="sidenav"> + <a href="#">About</a> + <a href="#">Services</a> + <a href="#">Clients</a> + <a href="#">Contact</a> +</div> + +<div class="main"> <h1># OCaml</h1> <content-block></content-block> <h2>## History</h2> @@ -25,4 +33,4 @@ <content-block>```ocaml</content-block> <content-block>let x = 10</content-block> <content-block>```</content-block> - +</div> diff --git a/outputs/styles.css b/outputs/styles.css @@ -11,3 +11,29 @@ content-block { background-color: #f6f9fB; display: block; } + +.sidenav { + height: 100%; /* Full-height: remove this if you want "auto" height */ + width: 160px; /* Set the width of the sidebar */ + position: fixed; /* Fixed Sidebar (stay in place on scroll) */ + z-index: 1; /* Stay on top */ + top: 0; /* Stay at the top */ + left: 0; + background-color: #111; /* Black */ + overflow-x: hidden; /* Disable horizontal scroll */ + padding-top: 20px; +} + +/* The navigation menu links */ +.sidenav a { + padding: 6px 8px 6px 16px; + text-decoration: none; + font-size: 25px; + color: #A18181; + display: block; +} + +.main { + margin-left: 160px; /* Same as the width of the sidebar */ + padding: 0px 10px; +}