diff options
author | Marc Coquand <marcc@fastmail.fr> | 2023-12-03 12:51:56 -0600 |
---|---|---|
committer | Marc Coquand <marcc@fastmail.fr> | 2023-12-03 12:51:56 -0600 |
commit | f192457e19486cdfbc8ac62684d33ac4b6c82bc1 (patch) | |
tree | 3007a6ca6f5c15a1248964d9dd4353ba6d40e281 /lib/post.ml | |
parent | 0bc5b9db320a2f5b12f597dfc4fdf12671f58939 (diff) | |
download | wormhole-f192457e19486cdfbc8ac62684d33ac4b6c82bc1.tar.gz wormhole-f192457e19486cdfbc8ac62684d33ac4b6c82bc1.tar.bz2 wormhole-f192457e19486cdfbc8ac62684d33ac4b6c82bc1.zip |
Add post and more
Diffstat (limited to 'lib/post.ml')
-rw-r--r-- | lib/post.ml | 33 |
1 files changed, 33 insertions, 0 deletions
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; |