logarion-2021/app/atom.ml
orbifx 6c27c7c6fb Draft
Basic unit renamed from Note to Text.

New modular text-parser, internal to Logarion, for generic notation parsing. The default input format is now a much plainer text.

Eliminated Meta module and generally lib/ modules.

New Store interface, with additional information from Store. For example the converter can now check filesystem dates. Changed to filesystem hardlinks for tracking publications & indexing, instead of categories. New commands `publish [-i]` and `deindex [-u]`. Categories are ignored now.

Logarion created texts have part of the UUID instead of a counter in their filename. New -i, --interactive flag for interactive creation & publication.

Logarion's index re-written in Messagepack format. Removed `indices` command. They are generated during `convert`.
2021-03-31 19:14:58 +01:00

38 lines
1.6 KiB
OCaml

let esc = Converter.Html.esc
let element tag content = "<" ^ tag ^ ">" ^ content ^ "</" ^ tag ^ ">"
let opt_element tag_name content =
if content <> ""
then element tag_name content
else ""
module P = Parsers.Plain_text.Make (Converter.Html)
let entry base_url text =
let open Logarion in
let u = Text.alias text in
let authors elt a =
a ^ "<author>"
^ (opt_element "name" @@ esc elt.Person.name)
^ (List.fold_left (fun acc addr -> acc ^ element "uri" (Uri.to_string addr)) "" elt.Person.addresses)
^ "</author>"
in
"<entry><title>" ^ esc text.title ^ "</title><id>urn:uuid:" ^ Id.to_string text.uuid ^ "</id><link rel=\"alternate\" href=\""
^ base_url ^ "/" ^ u ^ ".html\" /><updated>"
^ Date.(text.date |> listing |> rfc_string) ^ "</updated>"
^ Person.Set.fold authors text.authors ""
^ (opt_element "summary" @@ esc @@ Text.str "abstract" text)
^ String_set.fold (fun elt a -> a ^ "<category term=\"" ^ elt ^ "\"/>") (Text.set "topics" text) ""
^ "<content type=\"xhtml\"><div xmlns=\"http://www.w3.org/1999/xhtml\">"
^ P.of_string text.body ""
^ "</div></content></entry>"
let feed title archive_id base_url texts =
{|<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:base="|} ^ base_url ^ {|"><title>|}
^ title ^ {|</title><link rel="alternate" type="text/html" href="|}
^ base_url ^ {|/"/><link rel="self" type="application/atom+xml" href="|}
^ base_url ^ {|/feed.atom" /><id>urn:uuid:|} ^ Logarion.Id.to_string archive_id ^ "</id><updated>"
^ Ptime.to_rfc3339 (Ptime_clock.now ()) ^ "</updated>"
^ List.fold_left (fun acc t -> acc ^ entry base_url t) "" texts ^ "</feed>"