test out dream templates
This commit is contained in:
@@ -64,7 +64,6 @@ end
|
|||||||
module Db = (val Caqti_lwt.connect (Uri.of_string "sqlite3:database.db") >>= Caqti_lwt.or_fail |> Lwt_main.run)
|
module Db = (val Caqti_lwt.connect (Uri.of_string "sqlite3:database.db") >>= Caqti_lwt.or_fail |> Lwt_main.run)
|
||||||
|
|
||||||
(* Wrappers for the generic functions defined in Q *)
|
(* Wrappers for the generic functions defined in Q *)
|
||||||
module Database = struct
|
|
||||||
let create_blog_post_table () =
|
let create_blog_post_table () =
|
||||||
Db.exec Q.create_blog_post_table ()
|
Db.exec Q.create_blog_post_table ()
|
||||||
|
|
||||||
@@ -93,4 +92,3 @@ module Database = struct
|
|||||||
| Ok () -> Lwt.return_unit
|
| Ok () -> Lwt.return_unit
|
||||||
| Error err ->
|
| Error err ->
|
||||||
Lwt_io.eprintl (Caqti_error.show err)
|
Lwt_io.eprintl (Caqti_error.show err)
|
||||||
end
|
|
||||||
|
|||||||
@@ -37,8 +37,6 @@ module Q :
|
|||||||
|
|
||||||
module Db : Caqti_lwt.CONNECTION
|
module Db : Caqti_lwt.CONNECTION
|
||||||
|
|
||||||
module Database :
|
|
||||||
sig
|
|
||||||
val create_blog_post_table :
|
val create_blog_post_table :
|
||||||
unit -> (unit, [> Caqti_error.call_or_retrieve ]) Stdlib.result Lwt.t
|
unit -> (unit, [> Caqti_error.call_or_retrieve ]) Stdlib.result Lwt.t
|
||||||
|
|
||||||
@@ -74,4 +72,3 @@ module Database :
|
|||||||
('a -> ('c, 'b) Stdlib.result Lwt.t) -> ('c, 'b) Stdlib.result Lwt.t
|
('a -> ('c, 'b) Stdlib.result Lwt.t) -> ('c, 'b) Stdlib.result Lwt.t
|
||||||
|
|
||||||
val report_error : (unit, [< Caqti_error.t ]) Stdlib.result -> unit Lwt.t
|
val report_error : (unit, [< Caqti_error.t ]) Stdlib.result -> unit Lwt.t
|
||||||
end
|
|
||||||
|
|||||||
@@ -1,61 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<meta name="description" content="Rawley.xyz, Rawley Fowler's blog and personal website">
|
|
||||||
<title>rawley.xyz</title>
|
|
||||||
<link href="/static/index.css" rel="stylesheet">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<header>
|
|
||||||
<h1>
|
|
||||||
<a href="/">/home/rawley.xyz</a>
|
|
||||||
</h1>
|
|
||||||
<nav>
|
|
||||||
<li>
|
|
||||||
<a href="/blog">blog</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="/resume">resume</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="/philosophy">philosophy</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="/web-ring">web ring</a>
|
|
||||||
</li>
|
|
||||||
</nav>
|
|
||||||
</header>
|
|
||||||
<main>
|
|
||||||
<h3>Welcome!</h3>
|
|
||||||
<p>
|
|
||||||
Hi, I'm Rawley. I'm a software developer and self-proclaimed systems administrator
|
|
||||||
from Saskatchewan, Canada. I am experienced with a wide variety of technologies, including
|
|
||||||
but not limited to OCaml, Clojure, Scheme, GNU/Linux, OpenBSD, C/C++,
|
|
||||||
and Java. I am particularily interested in functional programming and
|
|
||||||
programming language theory.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
All of my personal projects are <a href="https://www.gnu.org/philosophy/philosophy.html">Free Software</a> and can be
|
|
||||||
found on <a href="https://git.rawley.xyz">my git server</a> or, on my <a href="https://github.com/rawleyfowler">github</a>.
|
|
||||||
I spend most of my free time working on personal projects,
|
|
||||||
writing blog posts, or listening to bluegrass music.
|
|
||||||
To top it all off, I am a free software advocate, digital minimalist, and a full time husband.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
If you need to contact me, please send me an email.
|
|
||||||
</p>
|
|
||||||
</main>
|
|
||||||
<footer>
|
|
||||||
<hr>
|
|
||||||
<p>
|
|
||||||
Copyright © Rawley Fowler 2022
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<b>Disclaimer</b>: All opinions on this site, are that of my own. They do not
|
|
||||||
reflect the opinions of any of my employers; past, present, or future.
|
|
||||||
</p>
|
|
||||||
</footer>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
open Lwt.Infix
|
open Lwt.Infix
|
||||||
open Database
|
|
||||||
open Render
|
|
||||||
|
|
||||||
let db_created = ref true
|
let db_created = ref true
|
||||||
|
|
||||||
@@ -16,7 +14,7 @@ let () =
|
|||||||
@@ Dream.logger
|
@@ Dream.logger
|
||||||
@@ Dream.router [
|
@@ Dream.router [
|
||||||
Dream.get "/static/**" @@ Dream.static "static";
|
Dream.get "/static/**" @@ Dream.static "static";
|
||||||
Dream.get "/" @@ Dream.from_filesystem "html" "index.html";
|
Dream.get "/" @@ (fun _ -> Render.render_index ());
|
||||||
Dream.get "/resume" @@ Dream.from_filesystem "html" "resume.html";
|
Dream.get "/resume" @@ Dream.from_filesystem "html" "resume.html";
|
||||||
Dream.get "/philosophy" @@ Dream.from_filesystem "html" "philosophy.html";
|
Dream.get "/philosophy" @@ Dream.from_filesystem "html" "philosophy.html";
|
||||||
Dream.get "/web-ring" @@ Dream.from_filesystem "html" "web-ring.html";
|
Dream.get "/web-ring" @@ Dream.from_filesystem "html" "web-ring.html";
|
||||||
|
|||||||
@@ -2,3 +2,9 @@
|
|||||||
(name render)
|
(name render)
|
||||||
(public_name rawleydotxyz.render)
|
(public_name rawleydotxyz.render)
|
||||||
(libraries dream lwt database))
|
(libraries dream lwt database))
|
||||||
|
|
||||||
|
(rule
|
||||||
|
(targets index.ml layout.ml)
|
||||||
|
(deps index.eml.ml layout.eml.ml)
|
||||||
|
(action
|
||||||
|
(run dream_eml %{deps} --workspace %{workspace_root})))
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
open Database
|
|
||||||
open Lwt
|
open Lwt
|
||||||
|
|
||||||
module Render = struct
|
module BlogPost = Database.BlogPost
|
||||||
|
|
||||||
|
module type SimpleRender = (sig val render : unit -> string end)
|
||||||
|
|
||||||
let header_template =
|
let header_template =
|
||||||
{eos|<!DOCTYPE html>
|
{eos|<!DOCTYPE html>
|
||||||
<head>
|
<head>
|
||||||
@@ -162,4 +164,9 @@ module Render = struct
|
|||||||
Dream.response
|
Dream.response
|
||||||
~headers:["Content-Type", "text/xml";]
|
~headers:["Content-Type", "text/xml";]
|
||||||
(Buffer.contents buff)
|
(Buffer.contents buff)
|
||||||
end
|
|
||||||
|
let render_simple (module R : SimpleRender) =
|
||||||
|
R.render () |> Layout.render |> Dream.html
|
||||||
|
|
||||||
|
let render_index () =
|
||||||
|
render_simple (module Index)
|
||||||
|
|||||||
@@ -1,16 +1,18 @@
|
|||||||
open Database
|
module BlogPost = Database.BlogPost
|
||||||
|
module type SimpleRender = sig val render : unit -> string end
|
||||||
module Render :
|
|
||||||
sig
|
|
||||||
val not_found_template : string
|
|
||||||
val error_template : string
|
|
||||||
val header_template : string
|
val header_template : string
|
||||||
val footer_template : string
|
val footer_template : string
|
||||||
|
val replace_sequence : string -> string -> string -> string
|
||||||
|
val html_unescape : string -> string
|
||||||
|
val not_found_template : string
|
||||||
|
val error_template : string
|
||||||
val render_page : string -> string
|
val render_page : string -> string
|
||||||
val generate_link : BlogPost.t -> string
|
val generate_link : BlogPost.t -> string
|
||||||
|
val generate_rss_item : BlogPost.t -> string
|
||||||
val handle_error : [< Caqti_error.t ] -> Dream.response Lwt.t
|
val handle_error : [< Caqti_error.t ] -> Dream.response Lwt.t
|
||||||
val handle_not_found : unit -> Dream.response Lwt.t
|
val handle_not_found : unit -> Dream.response Lwt.t
|
||||||
val render_blog_post : Dream.request -> Dream.response Lwt.t
|
val render_blog_post : Dream.request -> Dream.response Lwt.t
|
||||||
val render_blog_index : Dream.request -> Dream.response Lwt.t
|
val render_blog_index : Dream.request -> Dream.response Lwt.t
|
||||||
val render_rss_feed : Dream.request -> Dream.response Lwt.t
|
val render_rss_feed : Dream.request -> Dream.response Lwt.t
|
||||||
end
|
val render_simple : (module SimpleRender) -> Dream.response Lwt.t
|
||||||
|
val render_index : unit -> Dream.response Lwt.t
|
||||||
|
|||||||
Reference in New Issue
Block a user