From f192457e19486cdfbc8ac62684d33ac4b6c82bc1 Mon Sep 17 00:00:00 2001 From: Marc Coquand Date: Sun, 3 Dec 2023 12:51:56 -0600 Subject: Add post and more --- lib/post.ml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'lib/post.ml') diff --git a/lib/post.ml b/lib/post.ml index 744e296..5c3d494 100644 --- a/lib/post.ml +++ b/lib/post.ml @@ -6,8 +6,41 @@ type t = { tags : string list; published : string; author : string; + author_link : string; } +let published t = t.published + +(* RSS *) + +let to_rss_entry post = + Xml.tag "entry" [] + [ + Xml.tag "title" [] [ Xml.entry (post.author ^ " - " ^ post.link) ]; + Xml.tag "id" [] [ Xml.entry post.link ]; + Xml.tag "updated" [] [ Xml.entry post.published ]; + Xml.tag "summary" + [ ("xml:lang", "\"en\""); ("type", "\"html\"") ] + [ Xml.entry post.summary ]; + ] + +(* DB *) + +let db = ref [] + +let add (entry : t) = + db := entry :: !db; + print_endline (entry.link ^ " added to db"); + print_endline ("New db size: " ^ string_of_int (List.length !db)) + +let get_all () = + print_endline ("db size: " ^ string_of_int (List.length !db)); + !db + +let latest_post () = match !db with [] -> None | x :: _ -> Some x + +(* Mastodon integration *) + type mastodon_tag = { kind : string; [@key "type"] name : string; -- cgit v1.2.3