"
^ opt_kv "Title:" text.title
^ opt_kv "Authors:" authors
@@ -81,9 +82,13 @@ let page htm conversion text =
^ opt_kv "Topics:" (topic_links (set "topics" text))
^ opt_kv "Id:" text.id
^ opt_kv "Refers:" (ref_links (set "references" text))
+ ^ opt_kv "In reply to:" (ref_links (set "in-reply-to" text))
^ opt_kv "Referred by:" (try
ref_links (Conversion.Id_map.find text.id conversion.Conversion.references)
with Not_found -> "")
+ ^ opt_kv "Replies:" (try
+ ref_links (Conversion.Id_map.find text.id conversion.Conversion.replies)
+ with Not_found -> "empty replies")
^ {|
|} in
wrap conversion htm text.title ((T.of_string text.body header) ^ "
")
diff --git a/lib/text.ml b/lib/text.ml
index 1b010fa..80fb192 100644
--- a/lib/text.ml
+++ b/lib/text.ml
@@ -22,11 +22,19 @@ let blank ?(id=(Id.generate ())) () = {
let compare = Stdlib.compare
let newest a b = Date.(compare a.date b.date)
let oldest a b = Date.(compare b.date a.date)
-let str key m = try String_map.find (String.lowercase_ascii key) m.string_map with Not_found -> ""
-let set key m = try String_map.find (String.lowercase_ascii key) m.stringset_map with Not_found -> String_set.empty
-let str_set key m = String_set.to_string @@ set key m
-let with_str_set ?(separator=String_set.of_csv_string) m key str = { m with
- stringset_map = String_map.add (String.lowercase_ascii key) (separator str) m.stringset_map
+
+let str key m =
+ try String_map.find (String.lowercase_ascii key) m.string_map
+ with Not_found -> ""
+
+let set key m =
+ try String_map.find (String.lowercase_ascii key) m.stringset_map
+ with Not_found -> String_set.empty
+
+let with_str_set ?(separator=String_set.of_csv_string) m key str =
+ { m with
+ stringset_map = String_map.add (String.lowercase_ascii key) (separator str)
+ m.stringset_map
}
let with_kv x (k,v) =
@@ -37,12 +45,12 @@ let with_kv x (k,v) =
| "id" -> (match v with "" -> x | s -> { x with id = s })
| "author"
| "authors" -> { x with authors = Person.Set.of_string (trim v)}
- | "date" -> { x with date = Date.{ x.date with created = Date.of_string v }}
- | "date-edited"-> { x with date = Date.{ x.date with edited = Date.of_string v }}
+ | "date" -> { x with date = Date.{ x.date with created = Date.of_string v }}
+ | "date-edited"-> { x with date = Date.{ x.date with edited = Date.of_string v }}
| "licences" | "topics" | "keywords" | "series" as k -> with_str_set x k v
- | "references" -> with_str_set
- ~separator:(fun x -> String_set.map (fun x -> String.(sub x 1 (length x-2)))
- (String_set.of_ssv_string x))
+ | "references" | "in-reply-to" -> with_str_set
+ ~separator:(fun x -> String_set.map
+ (fun x -> String.(sub x 1 (length x-2))) (String_set.of_ssv_string x))
x k v
| k -> { x with string_map = String_map.add k (trim v) x.string_map }
@@ -69,21 +77,26 @@ let of_string s =
if note.id <> Id.nil then Ok note else Error "Missing ID header"
with _ -> Error ("Failed parsing" ^ s)
-let to_string x =
+let str_set key m = String_set.to_string @@ set key m
+
+let to_string x =
let has_len v = String.length v > 0 in
let s field value = if has_len value then field ^ ": " ^ value ^ "\n" else "" in
- let a value = if Person.Set.is_empty value then "" else "Authors: " ^ Person.Set.to_string value ^ "\n" in
- let d field value = match value with "" -> "" | s -> field ^ ": " ^ Date.rfc_string s ^ "\n" in
+ let a value = if Person.Set.is_empty value then ""
+ else "Authors: " ^ Person.Set.to_string value ^ "\n" in
+ let d field value = match value with "" -> ""
+ | s -> field ^ ": " ^ Date.rfc_string s ^ "\n" in
let rows = [
s "ID" x.id;
- d "Date" x.date.Date.created;
- d "Edited" x.date.Date.edited;
- s "Title" x.title;
+ d "Date" x.date.Date.created;
+ d "Edited" x.date.Date.edited;
+ s "Title" x.title;
a x.authors;
s "Licences" (str_set "licences" x);
s "Topics" (str_set "topics" x);
s "Keywords" (str_set "keywords" x);
- s "References"(str_set "references" x);
+ s "References"(str_set "references" x); (*todo: add to output <>*)
+ s "In-Reply-To"(str_set "in-reply-to" x);
s "Series" (str_set "series" x);
s "Abstract" (str "abstract" x);
s "Alias" (str "Alias" x)
diff --git a/readme.txt b/readme.txt
index e211391..8594974 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,6 +1,5 @@
ID: ka4wtj
Title: Logarion
-References: <3sqd84>