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 /bin | |
parent | 0bc5b9db320a2f5b12f597dfc4fdf12671f58939 (diff) | |
download | wormhole-f192457e19486cdfbc8ac62684d33ac4b6c82bc1.tar.gz wormhole-f192457e19486cdfbc8ac62684d33ac4b6c82bc1.tar.bz2 wormhole-f192457e19486cdfbc8ac62684d33ac4b6c82bc1.zip |
Add post and more
Diffstat (limited to '')
-rw-r--r-- | bin/main.ml | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/bin/main.ml b/bin/main.ml index 4d12cee..29dea84 100644 --- a/bin/main.ml +++ b/bin/main.ml @@ -54,18 +54,46 @@ let actor = } |} +let actor_whitelist = + [ + "https://fosstodon.org/users/marcc"; + "https://universeodon.com/users/icecreambook"; + "https://mastodon.social/users/ronent"; + "https://graphics.social/users/theohonohan"; + ] + let () = - Post.add fake_post; - Post.add fake_post_2; let port = Sys.getenv_opt "PORT" |> Option.map int_of_string |> Option.value ~default:8080 in let env = Sys.getenv_opt "ENV" |> Option.value ~default:"PROD" in + let disable_auth = + Sys.getenv_opt "DISABLE_AUTH" |> Option.value ~default:"false" + in let interface = if env = "DEV" then "localhost" else "0.0.0.0" in + if env = "DEV" then Post.add fake_post; + if env = "DEV" then Post.add fake_post; + if env = "DEV" then Post.add fake_post; + if env = "DEV" then Post.add fake_post; Dream.run ~port ~interface @@ Dream.logger @@ Dream.router [ + Dream.get "/static/**" (Dream.static "./static"); + Dream.get "/feed.xml" (fun _ -> + let posts = Post.get_all () in + let maybe_latest_post = Post.latest_post () in + match maybe_latest_post with + | Some latest_post -> + let rss_posts = posts |> List.map Post.to_rss_entry in + let rss = + Xml.format_rss "https://galaxy.mccd.space" + (Post.published latest_post) + rss_posts + in + Dream.respond rss + ~headers:[ ("Content-Type", "application/rss+xml") ] + | None -> Dream.html "No posts hav been published!"); Dream.get "/actor" (fun _ -> Dream.log "Sending actor"; Dream.respond actor |