diff --git a/db/database.ml b/db/database.ml index 91b1e19..f954751 100644 --- a/db/database.ml +++ b/db/database.ml @@ -1,6 +1,6 @@ open Lwt -module BlogPost = struct +module Blog_post = struct type t = { slug : string; title : string; @@ -14,7 +14,7 @@ module Q = struct open Caqti_type.Std let blog_post = - let open BlogPost in + let open Blog_post in let encode {slug; title; content; date} = Ok (slug, title, content, date) in let decode (slug, title, content, date) = Ok {slug; title; content; date} in let b_rep = Caqti_type.(tup4 string string string string) in diff --git a/db/database.mli b/db/database.mli index 5504589..428ad4c 100644 --- a/db/database.mli +++ b/db/database.mli @@ -1,4 +1,4 @@ -module BlogPost : +module Blog_post : sig type t = { slug : string; @@ -8,33 +8,6 @@ module BlogPost : } end -module Q : - sig - val blog_post : BlogPost.t Caqti_type.t - - val create_blog_post_table : (unit, unit, [ `Zero ]) Caqti_request.t - - val create_blog_post : - (string * string * string * string, unit, [ `Zero ]) Caqti_request.t - - val get_all_blog_posts : - (unit, BlogPost.t, [ `Many | `One | `Zero ]) Caqti_request.t - - val get_all_blog_posts_for_display : - (unit, string * string, [ `Many | `One | `Zero ]) Caqti_request.t - - val get_blog_post_by_slug : - (string, BlogPost.t, [ `One | `Zero ]) Caqti_request.t - - val update_blog_post_content : - (string * string, unit, [ `Zero ]) Caqti_request.t - - val update_blog_post_title : - (string * string, unit, [ `Zero ]) Caqti_request.t - - val delete_blog_post : (string, unit, [ `Zero ]) Caqti_request.t - end - module Db : Caqti_lwt.CONNECTION val create_blog_post_table : @@ -56,14 +29,14 @@ val update_blog_post_title : val get_blog_post_by_slug : string -> - (BlogPost.t option, [> Caqti_error.call_or_retrieve ]) Stdlib.result Lwt.t + (Blog_post.t option, [> Caqti_error.call_or_retrieve ]) Stdlib.result Lwt.t val get_all_blog_posts : unit -> - (BlogPost.t list, [> Caqti_error.call_or_retrieve ]) Stdlib.result Lwt.t + (Blog_post.t list, [> Caqti_error.call_or_retrieve ]) Stdlib.result Lwt.t val iter_blog_posts : - (BlogPost.t -> + (Blog_post.t -> (unit, [> Caqti_error.call_or_retrieve ] as 'a) Stdlib.result Lwt.t) -> (unit, 'a) Stdlib.result Lwt.t diff --git a/rawleydotxyz.ml b/rawleydotxyz.ml index 7b8659e..20a7022 100644 --- a/rawleydotxyz.ml +++ b/rawleydotxyz.ml @@ -18,7 +18,7 @@ let () = Dream.get "/resume" @@ Dream.from_filesystem "html" "resume.html"; Dream.get "/philosophy" @@ Dream.from_filesystem "html" "philosophy.html"; Dream.get "/web-ring" @@ Dream.from_filesystem "html" "web-ring.html"; - Dream.get "/blog" Render.render_blog_index; + Dream.get "/blog" (fun _ -> Render.render_blog_index ()); Dream.scope "/blog" [] [ Dream.get "/rss.xml" Render.render_rss_feed; Dream.get "/:post" (fun request -> Render.render_blog_post ~slug:(Dream.param request "post")) diff --git a/render/blog_index.eml.ml b/render/blog_index.eml.ml index e69de29..f5b2017 100644 --- a/render/blog_index.eml.ml +++ b/render/blog_index.eml.ml @@ -0,0 +1,17 @@ +let render ~posts = + let open Database in +
+% posts |> List.iter begin fun (post : Blog_post.t) -> +