add hostname to config

This commit is contained in:
Swrup 2022-02-27 19:44:19 +01:00
parent 1f54bfe9be
commit bff747b4ca
2 changed files with 14 additions and 11 deletions

View file

@ -42,6 +42,14 @@ let open_registration =
let () = Dream.log "open_registration: %b" open_registration let () = Dream.log "open_registration: %b" open_registration
let hostname =
match Scfg.Query.get_dir "hostname" config with
| None -> failwith "no `hostname` in configuration file"
| Some hostname ->
Result.fold ~error:failwith ~ok:Fun.id (Scfg.Query.get_param 0 hostname)
let () = Dream.log "hostname: %s" hostname
let port = let port =
match Scfg.Query.get_dir "port" config with match Scfg.Query.get_dir "port" config with
| None -> 8080 | None -> 8080

View file

@ -272,9 +272,6 @@ let get_markers () =
in in
Ok markers Ok markers
(* TODO get from config file? *)
let server_url = "http://localhost:3696"
(* RFC-3339 date-time *) (* RFC-3339 date-time *)
let pp_date fmt date = let pp_date fmt date =
let date = Unix.gmtime date in let date = Unix.gmtime date in
@ -285,7 +282,7 @@ let pp_feed_entry fmt post =
Format.fprintf fmt Format.fprintf fmt
{| {|
<entry> <entry>
<title>Atom-Powered Robots Run Amok</title> <title></title>
<id>urn:uuid:%s</id> <id>urn:uuid:%s</id>
<updated>%a</updated> <updated>%a</updated>
<author> <author>
@ -297,7 +294,7 @@ let pp_feed_entry fmt post =
|} |}
post.id pp_date post.date post.nick post.id pp_date post.date post.nick
(Dream.html_escape post.comment) (Dream.html_escape post.comment)
server_url post.parent_id post.id App.hostname post.parent_id post.id
let feed thread_id = let feed thread_id =
let* thread_data, op_post = get_op thread_id in let* thread_data, op_post = get_op thread_id in
@ -308,12 +305,11 @@ let feed thread_id =
let entries fmt () = let entries fmt () =
(Format.pp_print_list ~pp_sep:Format.pp_print_space pp_feed_entry) fmt posts (Format.pp_print_list ~pp_sep:Format.pp_print_space pp_feed_entry) fmt posts
in in
(*TODO different uuid for op and thread ..?*)
let feed = let feed =
Format.asprintf Format.asprintf
{|<?xml version="1.0" encoding="utf-8"?> {|<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"> <feed xmlns="http://www.w3.org/2005/Atom">
<title>%s | Permap </title> <title>%s</title>
<link rel="self" href="%s/thread/%s"/> <link rel="self" href="%s/thread/%s"/>
<updated>%a</updated> <updated>%a</updated>
<author> <author>
@ -321,9 +317,8 @@ let feed thread_id =
</author> </author>
<id>urn:uuid:%s</id> <id>urn:uuid:%s</id>
%a %a
</feed> </feed>|}
|} thread_data.subject App.hostname thread_id pp_date last_update
thread_data.subject server_url thread_id pp_date last_update op_post.nick op_post.nick op_post.id entries ()
op_post.id entries ()
in in
Ok feed Ok feed