aboutsummaryrefslogtreecommitdiff
path: root/lib/post.ml
diff options
context:
space:
mode:
authorMarc Coquand <marcc@fastmail.fr>2023-12-03 12:51:56 -0600
committerMarc Coquand <marcc@fastmail.fr>2023-12-03 12:51:56 -0600
commitf192457e19486cdfbc8ac62684d33ac4b6c82bc1 (patch)
tree3007a6ca6f5c15a1248964d9dd4353ba6d40e281 /lib/post.ml
parent0bc5b9db320a2f5b12f597dfc4fdf12671f58939 (diff)
downloadwormhole-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.ml33
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;